Guide

How to build a trading bot with AI

You can build a trading bot without writing the code yourself. Describe your rules in plain words, and Claude writes them as a Python program, backtests it on past markets and runs it in your own brokerage account. This guide walks through each step on Retro, which is free to start.

What you are building

A trading bot on Retro is a program: one Python file that looks at the market, decides, sends orders and prints what it did. A timetable starts it again every 1, 5, 15, 30 or 60 minutes, in market hours or around the clock, and each run lasts up to a minute.

Because the bot is ordinary code, nothing about it is hidden. You can read every line, change it yourself or ask Claude to change it, and every save is kept as a version you can go back to.

What you need

  • A Retro floor. It's free: a name, an email and a password, or your Google account.
  • A brokerage account. You link it to your floor with OAuth: you sign in at your broker and approve Retro, and no key is pasted anywhere.
  • Claude, with Retro added as a connector: Claude Desktop, claude.ai, the mobile apps or Claude Code. Claude does the writing on your own Claude plan, so Retro never calls a model for you.

Step by step

  1. Make your floor and link your brokerage account

    Sign up, then link your account from the Broker window. Signup also offers example programs: sample code at a risk level you pick, which shows what a finished bot looks like before you build your own.

  2. Connect Claude

    Add Retro's address to Claude as a custom connector. It takes about two minutes, and the quickstart has the steps for each Claude app. Claude can then read your floor and write, test and run programs. It can't move money, link an account or switch on real money: only you can.

  3. Describe the strategy

    Say what you want the way you would explain it to a friend. A clear description names five things: the market, when to buy, when to sell, how much each trade puts at risk, and when not to trade at all.

    • “Write a program that buys SPY when it closes above its 20-day high and sells under its 10-day low. Run it once and show me what it printed.”

    Claude writes the program, saves it in Programs and runs it once. That run is a test: prices and the clock are real, and any order the program sends is refused, so nothing reaches your account.

  4. Backtest it

    • “Backtest it over the last month and tell me honestly how it did.”

    A backtest runs the same file, unchanged, over past days, once for every minute of its timetable, with a simulated clock and account. Orders fill against real one-minute bars. On the free plan a backtest covers up to two months of history, and Retro Data covers up to two years.

    Read the trades as well as the total: how often it traded, its largest loss, and whether one lucky day carried the result. How to backtest a trading strategy goes further.

  5. Make it a trader

    • “Make it a trader with $10,000.”

    A trader runs the program on its timetable in a machine of its own, trading your brokerage account with the money you give it. One switch stops it, and webhooks can post each trade to your Discord or Slack the moment it happens. Real money trades only on a floor you link to a live account and arm yourself, and is open by invitation for now.

Make it better

Your first version will rarely be your best. Change one thing at a time and backtest the same days again, so you know which change did what.

  • “That lost money. Try a wider stop and a trend filter, then backtest both and compare.”

Watch for overfitting. A rule tuned until it looks perfect on the days you tested often fails on days it has never seen. Keep a stretch of days aside, tune on the rest, and test on the kept days once at the end.

Rather write the code yourself?

Open Programs on your floor to write a program in the editor, upload a file, or bring a broker API script you already have. Programs run Python 3.13 with pandas, numpy and requests, and Retro's own library makes backtests faster. The developer docs cover the details.

More guides