← Projects

Project · Claude Code + Alpaca · Paper money only

AI Paper
Trading Bot

A day-trading bot that scans the market, plans every stop and target, replays each trade 10,000 times before risking a cent, and still asks you before it places an order. Follow the 11 steps below and copy each prompt as written.

$0real money used: fake paper money only
11steps, each with a copy button
~45 minfor the first-time setup

Disclaimer: read before you start

  • This uses paper money only. A paper account is a practice account filled with fake money. No real money is bought, sold or at risk.
  • This is not financial advice. It is a personal learning project about AI tools. Nothing on this page tells you to buy or sell any stock.
  • We are not responsible for any losses, damages or problems that come from using this guide, these prompts or this bot, including if you connect it to a real-money account.
  • Do not connect this to a live (real-money) account. Keep ALPACA_PAPER_TRADE=true at all times.
  • Simulated results do not predict real results. AI tools make mistakes. Check every order before you approve it.
  • Never share your API keys with anyone, and never paste them into a chat window.
How it works

What happens on every run

Each time the bot runs, it goes through these checks in order. If any check fails, it does nothing for that stock (it "holds") and writes the reason in a log file.

  1. Safety checks
  2. Scan charts + news
  3. 20-day trend filter
  4. Entry signal
  5. Set stop + target
  6. Time Machine odds
  7. You approve
  8. Write to log

Safety checks confirm the account is a paper account, the market is open, the daily order limit is not used up, and the bot has not lost more than 10%. Time Machine replays the trade 10,000 times on the stock's recent price data. The bot only continues if the odds are clearly better than a coin flip. Every position is closed by 3:55 PM Eastern Time (ET).

Before you start

What you need

Get these five things ready. Steps 1 and 2 show you how to set up each one.

A computer

Windows, Mac or Linux. The examples below use Windows. Mac and Linux commands are shown where they differ.

Claude Code

Needs a paid Claude plan (Pro or higher). Install it from claude.com/claude-code.

An Alpaca paper account

Free. Sign up at alpaca.markets. Step 1 covers this.

Python 3.8 or newer

Free from python.org. On Windows, tick "Add Python to PATH" during install.

Git

Free from git-scm.com. Used once, to download the trading tools.

How to read the steps: a ⌨ Terminal label means type the command in your computer's terminal (PowerShell on Windows, Terminal on Mac). A ✦ Claude Code label means paste the text into Claude Code after you start it with claude. Text highlighted like this inside a code box is a placeholder. Replace it with your own value.
Step by step

Build the bot in 11 steps

Do the steps in order. Finish each step and check that it worked before you move to the next one.

1

Create your Alpaca paper account and keys

5 min · browser

Alpaca is the broker. Its paper account gives you $100,000 of fake money to practice with.

  1. Go to alpaca.markets and sign up with your email.
  2. Log in. In the account switcher at the top left, choose your Paper account.
  3. On the paper account's home page, find API Keys and click Generate New Keys.
  4. Copy the API Key and the Secret Key into a private note on your computer. The secret is shown only once.

Check: a paper API key starts with the letters PK. If yours does not, you are in a live account. Switch to Paper and generate new keys.

2

Install uv

3 min · terminal

uv is a small program that downloads and runs Alpaca's connector for Claude Code.

⌨ Terminal · Windows (PowerShell)
Command
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
⌨ Terminal · Mac or Linux
Command
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Close the terminal and open a new one.
  2. Type the command below and press Enter.
Command
uvx --version

Check: it prints a version number, such as uv 0.13.7. If it says "not recognized", restart your computer and try again.

3

Make a folder and download the trading tools

2 min · terminal

This creates a folder named DayTrading and downloads the free day-trader skills (scanner, news, entry, exit, Time Machine) into it.

⌨ Terminal
Commands, run one line at a time
mkdir DayTrading
cd DayTrading
git clone https://github.com/Jakeschincariol/day-trader-skill.git github-daytrader/day-trader-skill

Check: the folder DayTrading/github-daytrader/day-trader-skill now exists and has folders whose names start with trader-.

4

Connect Alpaca to Claude Code

3 min · terminal

This gives Claude Code access to your paper account. Your keys stay on your computer.

  1. Copy the command below into a text editor first.
  2. Replace YOUR_API_KEY and YOUR_SECRET_KEY with the keys from step 1.
  3. Paste the finished command into your terminal and press Enter.
⌨ Terminal
Command
claude mcp add alpaca --scope user -e ALPACA_API_KEY=YOUR_API_KEY -e ALPACA_SECRET_KEY=YOUR_SECRET_KEY -e ALPACA_PAPER_TRADE=true -- uvx alpaca-mcp-server
  1. Start Claude Code inside the folder: type claude and press Enter.
  2. In Claude Code, type /mcp and press Enter.

Check: alpaca appears in the list as connected. If it shows failed on Windows, run the command again but replace uvx with the full path, for example C:\Users\you\.local\bin\uvx.exe.

Never paste your keys into the Claude Code chat, and never change ALPACA_PAPER_TRADE to false.
5

Set up permissions, rules and the log

Prompt 1 of 6

This prompt locks down what Claude may do. Reading data is allowed, placing an order always asks you first, and options orders are blocked completely. It also creates the rules file and an empty trade log.

✦ Claude Code, inside the DayTrading folder
Prompt 1 · Setup
I'm setting up a paper-trading bot with Alpaca's MCP server. Paper money only, for learning.

1. Check the alpaca MCP server is connected and call get_account_info. Tell me the buying power, and remind me this should be a paper account.
2. Add these permission rules to .claude/settings.json in this folder (merge with anything already there):
   allow: mcp__alpaca__get_*
   ask: mcp__alpaca__place_stock_order, mcp__alpaca__place_crypto_order, mcp__alpaca__cancel_all_orders, mcp__alpaca__close_position
   deny: mcp__alpaca__place_option_order, mcp__alpaca__close_all_positions, mcp__alpaca__update_account_config
3. Create trading-rules.md with these rules for me to edit:
   - Watchlist: [e.g. 5 large, well-known stocks or ETFs]
   - Max 10% of the account in any one position
   - Every buy has a stop loss
   - At most 3 orders a day
   - No options, no shorting, no margin
   - Only trade while the market is open
4. Create an empty trades-log.md.
5. Explain each rule and permission back to me in plain English.

Never ask me for API keys and never change ALPACA_PAPER_TRADE.

Check: Claude reports your buying power, your account number starts with PA (paper), and the folder now has .claude/settings.json, trading-rules.md and trades-log.md.

6

Fill in the trading rules

Prompt 2 of 6

The rules file starts with blanks. This prompt fills them with exact numbers, so the bot never has to guess.

✦ Claude Code
Prompt 2 · Rules
Update trading-rules.md with these rules. Keep everything else in the file.

- Watchlist: SPY, QQQ, AAPL, MSFT, JPM
- Stop loss: 5% below the entry price, placed together with the buy order
- Buy signal: the last completed daily close is above the 20-day moving average
- Sell signal: the last completed daily close is below the 20-day moving average
- Take profit: none. The sell signal handles exits.
- Order type: limit orders, no more than 0.5% from the current price
- Approvals: keep order placement on "ask" so I approve every order
- Kill switch: if account equity drops below $90,000, place no new orders, send me a push notification and stop
- Push notifications: when an order is placed, a stop fills, the kill switch trips, or the account is not a paper account

Then explain each change back to me in plain English.

Check: open trading-rules.md. It lists the 5 symbols, the 5% stop, the 20-day average signals and the $90,000 kill switch.

7

Give the bot its own $50,000 budget

Prompt 3 of 6

This limits the bot to half of the paper account, so you can test a second bot on the same account later. Every order gets a name tag (ma20-) so the bot only touches its own trades.

✦ Claude Code
Prompt 3 · Budget
Change the rules so this bot, named "MA20", only uses a $50,000 budget instead of the whole $100,000 account. I want to run a second bot on the same account later.

- Position cap: 10% of $50,000 = $5,000 per position
- Kill switch: stop if this bot's own value drops below $45,000
- Tag every order this bot places with a client_order_id that starts with "ma20-"
- Never touch orders or positions whose client_order_id does not start with "ma20-"
- Never cancel all orders or close all positions, because that would hit the other bot too
- Move mcp__alpaca__cancel_all_orders from "ask" to "deny" in .claude/settings.json

Then explain each change back to me in plain English.

Check: trading-rules.md shows a $50,000 budget and a $45,000 kill switch. Type /permissions in Claude Code and confirm cancel_all_orders is under Deny.

8

Connect the day-trading tools

Prompt 4 of 6

This switches the bot to day trading. It adds the scanner, the news monitor, the exit planner and the Time Machine (from step 3) to every run.

✦ Claude Code
Prompt 4 · Connect tools
The day-trader skills are in github-daytrader/day-trader-skill. Connect them to my MA20 bot by rewriting trading-rules.md so every run does this:

1. Read trading-rules.md and the log, and check the market clock (as before).
2. Run the scanner and news monitor to find candidate setups.
3. Use the exit planner to set the stop and target. The stop comes from each trade's own chart. Keep 5% below the entry as the widest stop allowed.
4. Run the Time Machine on the plan. Only proceed if the odds are clearly better than a coin flip. Otherwise hold.
5. If it passes, place the order through Alpaca (still on "ask"), and log the reason plus the Time Machine result.

Run the tools from this folder so their files go to the trader/ folder here. Close every position by 3:55 PM ET. Do not place any orders yet. Explain the new run order back to me in plain English.

Check: trading-rules.md now has a "Run order" section with the scanner, entry, exit planner and Time Machine commands.

9

Turn on SEC filings in the news check

Prompt 5 of 6

The SEC asks every program that reads its filings to send a name and email. Replace both placeholders with your own.

✦ Claude Code
Prompt 5 · SEC identity
Create trader/config.json in this folder with "sec_user_agent": "Your Name you@example.com" so the news monitor can read SEC filings. If the news command in trading-rules.md has --no-sec, remove it.

Check: the file trader/config.json exists and contains your name and email.

10

Do one supervised run

Prompt 6 of 6

This is the prompt the bot runs every time. Run it once yourself while you watch, before you schedule it.

  1. Replace YOUR FOLDER PATH on the first line with the full path of your DayTrading folder.
  2. Run it on a weekday between 10:00 AM and 3:30 PM ET, when the market is open.
  3. When Claude asks to place an order, read the ticket. Click Allow once only if it matches your rules. Otherwise click Deny.
✦ Claude Code
Prompt 6 · The bot run
You are the "MA20" paper-trading bot. Working folder: YOUR FOLDER PATH, for example C:\Users\you\DayTrading
Run every command from that folder so the tools' files go to DayTrading\trader\ (never github-daytrader\trader\).

1. Read trading-rules.md and trades-log.md. trading-rules.md is the source of truth. If anything below conflicts with it, follow the rules file.

2. Safety checks, in this order:
   - get_account_info: the account number must start with "PA". If it doesn't, log it, send a push notification and stop.
   - Work out bot value from this bot's own orders (client_order_id starting with "ma20-"). If it's below $45,000, log KILL SWITCH, send a push notification and stop.
   - get_clock: if the market is closed, log "market closed" and stop.
   - Count today's ma20- orders from Alpaca's order history. If there are already 3, place nothing new (closing a position at 15:55 is still allowed).

3. If it's 15:55 ET or later: close every open ma20- position. Cancel only that symbol's own ma20- bracket legs with cancel_order_by_id, then place a sell limit. Log it and stop. Never use cancel-all or close-all.

4. Scan and news (no new entries after 15:30 ET):
   python github-daytrader/day-trader-skill/trader-scanner/scan.py orb --symbols SPY,QQQ,AAPL,MSFT,JPM
   python github-daytrader/day-trader-skill/trader-news/news.py --tickers SPY QQQ AAPL MSFT JPM
   Also call Alpaca get_news for these symbols. Only scanner hits are candidates. Bad news means HOLD. News alone is never a reason to buy.

5. For each candidate the bot doesn't already hold:
   a. Trend filter: the last completed daily close must be above the 20-day average (average of the last 20 completed daily closes, via get_stock_bars). Otherwise HOLD.
   b. python github-daytrader/day-trader-skill/trader-entry/entry.py check SYMBOL --write
      Continue only if the status is "triggered".
   c. python github-daytrader/day-trader-skill/trader-exit/exit.py plan --stop or-mid --target 2R --flat-by 15:55 --write
      HOLD if the planner refuses or the stop is more than 5% below the entry.
   d. python github-daytrader/day-trader-skill/trader-timemachine/timemachine.py run --until 15:55 --write
      Proceed ONLY if all three hold:
        - the verdict starts with "Leans toward the target" or "Strongly toward the target"
        - the average R is above 0
        - the history has at least 10 fires and more target hits than stop hits
      Anything else ("Close to a coin flip", "Close to break-even", leaning toward the stop, too little history, the tool refusing) means HOLD.
   e. Get the current quote. Buy limit = no more than 0.5% above the ask. Skip if the limit is more than 0.5% above the plan's entry.
      Shares = floor(5000 / limit). The cost must fit within both bot cash and the account's actual cash.
   f. Place ONE order with place_stock_order: side buy, type limit, time_in_force day, no extended hours,
      order_class "bracket", stop_loss_stop_price = the plan's stop, take_profit_limit_price = the plan's target,
      client_order_id "ma20-SYMBOL-YYYYMMDD-buy".
      If approval is denied or not available (unattended run), do NOT retry. Log "PROPOSED (not placed)" with the full order details and send a push notification.
      Stop placing orders once today's ma20- order count reaches 3.

6. Append one line per watchlist symbol to trades-log.md:
   date time ET | SYMBOL | ACTION | qty | price | stop | target | close vs 20MA | TM: verdict, target% / stop% / neither%, avg R, history W-L | bot value | one-sentence reason (say so when it's weak)
   Use "-" for any step a symbol never reached.

7. Send a push notification when an order is placed or proposed, a stop or target fills, the kill switch trips, or the account isn't paper.

Never: options, shorting, margin, extended hours, symbols outside the watchlist, or touching any order or position without the ma20- prefix.

Check: open trades-log.md. It has one new line for each of the 5 symbols, each with an action (BUY, HOLD or PROPOSED) and a reason. "HOLD" on every symbol is a normal result. It means no setup passed every check.

11

Schedule it to run on weekdays

10 min · optional

The bot can run by itself at set times. Run it at these 5 times. The first run must be after 9:50 AM ET, when the first breakout signal can appear. Keep the 3:55 PM run, because it closes open positions.

Eastern (ET)Central (CT)Pacific (PT)Purpose
10:00 AM9:00 AM7:00 AMFirst scan
11:00 AM10:00 AM8:00 AMScan
12:30 PM11:30 AM9:30 AMScan
2:00 PM1:00 PM11:00 AMScan
3:55 PM2:55 PM12:55 PMClose all bot positions
  1. Save the prompt from step 10 (with your folder path filled in) as a file named run-prompt.txt inside your DayTrading folder.
  2. Test it once. Open Command Prompt (Windows) or Terminal (Mac), go to the folder with cd, and run:
⌨ Command Prompt (Windows) or Terminal (Mac)
Command
claude -p < run-prompt.txt
  1. Windows: open Task Scheduler and click Create Basic Task.
  2. Name it MA20 bot 10am. Choose Weekly, tick Monday to Friday, and set the start time from the table above in your own time zone.
  3. Choose Start a program. In Program/script, type cmd.exe.
  4. In Add arguments, paste the line below. In Start in, paste your DayTrading folder path.
Add arguments
/c claude -p < run-prompt.txt >> run-output.txt 2>&1
  1. Click Finish. Repeat steps 3 to 6 for the other 4 times.
  2. Mac or Linux: type crontab -e and add one line per time. This example runs at 10:00 AM on weekdays, if your computer clock is on Eastern Time:
Cron line
0 10 * * 1-5 cd /full/path/to/DayTrading && claude -p < run-prompt.txt >> run-output.txt 2>&1
Your computer must be on and awake at each scheduled time, or the run is skipped.
Orders still need your approval. A scheduled run has nobody to click "Allow", so the bot writes the order in trades-log.md as PROPOSED (not placed) instead. Read the log after each run and place the order by hand if you agree with it.
The 3:55 PM close also needs approval. If nobody approves it, the position stays open overnight. Its stop-loss order stays in place.
Stopping the bot

How to turn it off

Stop scheduled runs

Windows: open Task Scheduler, right-click each "MA20 bot" task and click Delete. Mac: run crontab -e and delete the lines.

Close open trades

Log in to Alpaca, open your Paper account, go to Positions and close them by hand.

Remove Alpaca access

In the terminal, run claude mcp remove alpaca --scope user. Then delete the keys on Alpaca's API Keys page.

Reminder

Paper money. Real lessons. No promises.

This bot trades fake money for learning only. It is not financial advice, and we are not responsible for any losses or problems from using it.