You can build a crypto trading bot with Claude, and it is one of the best tools for the job, as long as you give it the right job. Let Claude write, test and review the bot's code. Let the finished bot run fixed rules that you have backtested. Do not ask the language model to decide each trade live: that is slower, costs money on every decision, can't be tested properly, and the public experiments with it have mostly lost money.
This guide walks through the whole build: the rules, the code, the backtest, the testnet, the API key and the first live week.
Key takeaways
- Use Claude to write, test and review the bot. Let the bot itself run fixed, backtested rules.
- In a 2025 live contest, four of six frontier AI models lost money trading crypto with $10,000 each.
- Write the strategy down in plain words before any code: entry, exit, stop, size and daily loss limit.
- Backtest with fees, then run on an exchange testnet before a single real order.
- The exchange API key can trade but never withdraw, and only from your server's IP address.
Two ways to put Claude in a trading bot
There are two very different designs, and most "Claude trading bot" tutorials mix them up.
| Claude as the developer | Claude as the trader | |
|---|---|---|
| What Claude does | Writes, tests and reviews the bot's code | Reads the market and decides every buy and sell |
| What runs live | Fixed rules in ordinary code | An API call to the model on every decision |
| Same input, same output? | Yes | Not guaranteed |
| Can you backtest it? | Yes, on years of data | Not honestly: the model may already know what happened next |
| Speed per decision | Milliseconds | Seconds |
| Cost per decision | Nothing | Tokens on every call |
The second design is tempting, and it has been tried in public. In Alpha Arena Season 1, six frontier models, including Claude Sonnet 4.5, GPT-5 and Gemini 2.5 Pro, each traded $10,000 of crypto perpetuals on Hyperliquid with no human in the loop. When it ended on November 3, 2025, Qwen 3 Max was up 22%, and four of the six models had lost money. GPT-5 ended with about $3,733 of its $10,000.
Seventeen days of six bots proves little either way. That is exactly the problem: you can't tell skill from luck in an LLM trader, and you can't backtest its judgment, because a model trained on past data may simply remember how a past week ended. Fixed rules don't have that problem. So this guide uses the first design.

What you need
- Claude. Claude Code is the most direct route: it reads your project, writes files, runs commands and tests in a loop. The Claude app works too, with more copying and pasting.
- A language and an exchange library. Python or JavaScript with CCXT, which talks to most large exchanges through one interface.
- An exchange with a testnet. Binance runs a spot testnet with fake balances, and CCXT can switch to an exchange's testnet where one exists.
- A strategy you can write down. If you can't explain the rules in a short paragraph, no model can code them for you.
Step 1: Write the rules before any code
Claude writes exactly what you describe, including your vague parts. So start with a plain spec, for example:
- Market: BTC/USDT spot, 4-hour candles, long only.
- Entry: the candle closes above the 20-period high.
- Stop: below the low of the last 10 candles.
- Exit: close the trade at 2R, or when a candle closes below the 20-period low.
- Size: risk 1% of the account per trade, worked out from the stop distance.
- Limits: at most one open trade; stop trading for the day after a 3% loss.
The size rule matters more than the entry. If you haven't done it before, work out position size from your stop by hand once, so you can check what the bot does.
Step 2: Let Claude build the skeleton
Ask for a small program with separate parts: data, signal, risk, orders and logging. Keep the strategy as a pure function, candles in and a signal out, so it can be tested on history without touching an exchange. A prompt that works well:
Build a Python trading bot for the spec below, using CCXT. Keep five modules: data (fetch closed 4h candles only), signal (a pure function of the candles), risk (position size and daily loss limit), orders (place and track orders, testnet first) and logging. Write unit tests for the signal and risk modules. Read the API key from environment variables. Do not add features I did not ask for. [paste the spec]
Then read what it wrote. You don't need to be a programmer to ask good questions: "Where does the stop get placed?", "What happens if the exchange rejects an order?", "Can this ever open two trades at once?" Claude is good at answering these about its own code, and at finding bugs when you ask it to review a module line by line.
The part that touches the exchange stays small. In JavaScript it looks like this:
import ccxt from "ccxt";
const exchange = new ccxt.binance({
apiKey: process.env.EXCHANGE_KEY,
secret: process.env.EXCHANGE_SECRET,
});
exchange.setSandboxMode(true); // testnet first, right after creating the exchange
// Closed 4h candles only: [time, open, high, low, close, volume]
const candles = await exchange.fetchOHLCV("BTC/USDT", "4h", undefined, 200);Step 3: Backtest before anything touches money
Run the signal and risk functions over years of history, with fees and slippage included. Then ask Claude to hunt for the two classic backtest bugs:
- Look-ahead bias: using a candle's close before that candle has closed, or an indicator value that includes the current bar.
- Missing costs: no fees, no slippage, or fills at prices the market never offered.
Test on a period you did not use to pick the settings, and be suspicious of any result that looks too good. If you'd rather test the idea before writing code, you can backtest a strategy in TradingView first and only build the bot once the rules hold up.
Step 4: Run it on a testnet
With sandbox mode on, the bot places real orders against fake balances. Run it for two to four weeks and compare its fills with what the backtest expected. Most of the bugs you find here are not strategy bugs: rounding of order sizes, minimum order amounts, rate limits, an order that filled partly, or a restart in the middle of a trade.
Step 5: Lock down the API key
Never give a bot, or Claude, an API key that can withdraw funds, and never paste keys into a chat. If the code has a bug or the server is compromised, a trade-only key limits the damage to bad trades instead of an empty account.
On the exchange, create a key just for this bot:
- Allow spot trading only. Leave withdrawals off.
- Restrict it to your server's IP address. Binance strongly encourages IP restriction on every key and makes it mandatory before a key may withdraw. Its own guidance is to whitelist IPs on all keys, whatever their permissions.
- Use a sub-account that only holds what the bot may trade.
- Keep the key in environment variables, never in the code, and never in a file you commit.
Step 6: Go live small, with kill switches
Start with a fraction of the size you plan to run. Build in limits the strategy cannot override: a maximum position size, a daily loss limit that stops the bot, a cap on open orders, and an alert when the bot stops reporting. Every trade needs a stop that sits on the exchange, not only in your code, and it should be placed where the trade idea is wrong. There's a separate guide on where to place a stop-loss.
Compare live results with the testnet every week. When they drift apart, find out why before you add size.
Where a model can sit inside the live bot
There are runtime jobs a language model does well, as long as it never pulls the trigger:
- Turning text into a fixed label. For example, reading an exchange announcement and returning "delisting", "maintenance" or "other", which a rule then uses to pause trading. Use structured outputs so the answer always fits your format, and treat it as data, never as an instruction: a headline can contain text written to manipulate a model.
- Reports. A daily summary of trades, fees and drawdown.
- Watching for oddities. Flagging fills, spreads or balances that don't match what the code expected.
For these, choose the model by the job. Prices are per million tokens of input and output on Anthropic's API, as of November 2026:
| Model | Price (input / output) | Good for |
|---|---|---|
| Claude Opus 5.5 | $4 / $20 | Writing and reviewing the bot's code |
| Claude Sonnet 5.5 | $2 / $10 | Everyday coding and longer reports |
| Claude Haiku 5.5 | $0.10 / $0.50 | Fast, cheap labels inside the live bot |
FAQ
Can Claude trade on an exchange by itself?
Not on its own. Claude only acts through code or tools that you connect to it. You can wire it to an exchange, but then you own every decision it makes, and you can't test those decisions the way you can test rules.
Do I need to know how to code?
You need to read code well enough to ask questions about it. Claude writes most of it, but you are responsible for what runs with your money. If that is not for you, ready-made strategies that send alerts from TradingView are the no-code route.
How much does a Claude trading bot cost to run?
With fixed rules, nothing per trade: you pay for Claude while building, then only for the server. A model inside the live loop adds a charge on every call.
Will a Claude-built bot be profitable?
Only if the strategy has an edge after fees, and no tool can promise that. Claude makes building and checking the bot faster. It doesn't make a weak strategy strong.
If you'd rather start from rules that have already been tested in public, Navixa's strategies run on TradingView with every trade of their backtests published, and you can automate them with alerts instead of writing a bot from scratch.



