跳到正文
TikTok · 搜「ai tools」· laeshaai_·· 2 天前精选AI 评分58

用 Claude Code 和 Alpaca MCP 从零搭建模拟盘交易机器人

In this video, I show you how to build a trading bot with Claude step-by-step from scratch. This is gonna be the full set up on how to get the app how to connect it to alpaca paper trading, and a simple beginner strategy. Comment “trade” for the prompts #aitrading #tradingbot #aitools Disclaimer: this video is for educational purpose only and it is absolutely not financial advice. I’m not a financial advisor. Trading involves a lot of risk so never try with money you can’t afford to lose. everything that is being shown in this video is with paper trading and with fake money, wherever you do is at your own risk.

AI 导读

作者演示用 Claude Code 从零搭建交易机器人,通过 Alpaca MCP 连接模拟盘账户,并用 5 万美元虚拟资金验证下单。

打开原文tiktok.com
选题角度

作者完整演示用 Claude Code 加 Alpaca MCP 搭模拟盘交易机器人,可跟拍从装应用到下单验证的全流程。

博主

粉丝 7597

互动数据
浏览
5.3万
点赞
4098
评论
1507
分享
1054
收藏
5007

数字来自平台,为最近一次抓取时的数据。

正文 · 原文

以下是视频口播的自动转写,可能有错字。

In this video, i'm gonna show you how to build a trading bot step by step from scratch using Claude Code. And the best part is you don't need to be technical at all, because it's as simple as talking to cloud.

I'll show you the exact tools, how to connect them so they talk to each other, and how to build a bot with a simple beginner strategy that checks the market automatically.

So before jumping in, here's what an ai trading bot actually is, and why i am building one. At its core, a trading bot does two things.

It runs a plan on repeat, and it follows that plan better than a person can. Here's where most people go wrong with trading.

They have the right idea, but they mess up the execution. They get into a good trade and forget to check on it, or they panic sell.

That's the value of a bot. It follows the exact set of rules that you set, and follows through at time. It doesn't hesitate or get scared.

Emotion is what trips up most traders, and a bot doesn't have it. And even better, your bot can watch the market while you're sleeping.

So you don't miss a trade. Just because you weren't staring at a screen all day. So let's go ahead and build this whole thing out together.

Just a quick disclaimer, this is not financial advice. I'm not a financial advisor. I'm just showing you a cool way to use ai.

Ok, so step one, get the cloud desktop app. Search cloud desktop app or use the link in the description. Download it from mac or windows, whatever one you have.

Once it's installed, it looks something like this. Make sure your computer is up to date, so you have every feature available.

And ideally, you're on the pro or the max plan. And a quick reminder, every prompt i use in this video is free. Just comment trade, and i'll send it to you.

If you're on youtube, check the description. Now click on code up here. Claude Code is what actually builds the bot. So step two, let's make a folder for your bot.

Click this folder icon above the chat. I keep all my cloud projects in one projects folder, but you can just make one on your desktop.

Make a new folder, call it trading bot, and hit open. Now you can see above the chat that cloud is working inside the trading bot.

Folder. So every file cloud makes will go in there. Okay, step three, you need a brokerage account and for that i'm using alpaca search alpaca trading, click on alpaca and sign up for a trading api account.

It takes a few minutes. Once you've entered your information, you'll see this dashboard. Now, click on the account in the top left everything in this video is paper money.

So we need a paper trading account. It's really easy. Make a new one and call it something like what paper trading and pick how much fake money you want.

You can pick a million but i'm picking 50,000 hit save and there it is a paper account with 50,000 dollars of fake money.

So we can get some practice in in the real stock market. All right, step four, we're gonna connect alpaca to cloud. We're gonna do this so cloud can trade for you.

You will need your alpaca keys for this. But first, go back to the cloud desktop app, click your account in the bottom left, then settings, then developer.

This is where you connect the alpaca mcp and mcp is. Just a plug that lets cloud use another app. Click edit config, a window pops up with your config file highlighted.

Open it. This is where you'll paste the alpaca mc. To find it, go back to your browser and search alpaca mcp. Click the link, scroll down to the cloud desktop option, and click install.

That takes you to a github page with the code ready to copy. Now, for the pasting part, if your config file is empty, just copy and paste all the code in.

If you already have another mcp in there like i do, add a comma after the second to last curly bracket, start a new line, and paste everything from alpaca down to its closing curly bracket.

If there's other text in the file, but no mcp's, paste the code at the top, and add a comma after its last curly bracket, or you'll get an error.

Next, the keys. Go back to alpaca, click generate new keys, and you'll get a key and a secret. Save the secret somewhere right away, because it disappears, and you can't see it again.

Copy the key, go back to the config file, and paste it. Inside the quotes where it says to then do the same for the secret key.

Now save and close the config file, then fully close the cloud app and reopen because the mcp only shows up after a restart.

Go back to settings, then developer, and you should see alpaca in the list and it should be running. All right, so for step five, we're gonna test this out.

Check that cloud can actually see your account. Click code, start a new session, and make sure you're in the trading bot folder.

Then ask, i want to test the connection to my alpaca account. Can you please tell me how much money i have and whether i own any stock?

I'm using sonnet 5.5 for this part because it's a simple task and it saves you your usage. And there it is, 50,000 dollars, no stocks, which is correct.

Now that it's connected, you can ask cloud to place a trade without even opening alpaca. Buy one share of apple, and cloud says the order went through.

It's the weekend right now, so the market's closed and the order is pending. It will fill when the market opens. If you refresh your alpaca account and scroll down, you.

Can see the order right there waiting for you. So now you can just tell claude to buy or sell whatever you want. But the whole point of this video is a bot that trades for you automatically, so you don't have to do it yourself.

And for that, the bot needs rules for when to buy, sell or hold. Otherwise, it won't know when to act. Those rules are your strategy.

Now, there are a ton of trading strategies out there, and you can use whichever one you like. But for this video, i'm using the simplest one that actually makes sense for a beginner.

It's called the moving average crossover. So here's what that means. A moving average is just the average price of a stock over a set number of days.

A 50 day moving average is the average closing price over the last 50 days. Every day a new price comes in, and the average updates, which is why it's called moving.

So the bot uses two of them, a fast one, the 20 day average, which reacts quickly to new price changes, and a slow one, the 50 day average, which reacts slowly.

Now that we have a strategy in mind, building it out is. be simple. you just need to prompt cloud. this is an example one i'm gonna use.

Now, if you want to take this further, I have resources in my bio for all of this, and as always, thank you so much for watching and subscribe if you want more AI related content.

来源:TikTok · 搜「ai tools」 · tiktok.com