Tips
Can ChatGPT or Claude write a trading algorithm?
Yes. A model can write working trading code in minutes. It cannot tell you whether the strategy makes money, and its typical mistakes look like profit in a backtest. Where we use AI on a trading bot, and where we stop trusting it.
Yes, ChatGPT or Claude can write a trading algorithm. Give either one a strategy in plain words and it can return working code in minutes. A data loader, a signal, an order call, a backtest. What it cannot do is tell you whether the strategy makes money. And some of the mistakes it makes look like profit in a backtest.
We build software with AI coding agents, trading bots included. This is how we use them on a bot, and where we stop trusting them.
What a model does well
A model is fast at the parts of a bot that are long but well known:
- API clients. Authentication, signing, pagination, retries and parsing for a venue’s REST and WebSocket feeds.
- Data work. Loading files, converting time zones, resampling, finding gaps and duplicates.
- Tests. Cases for a partial fill, a rejected order or a reconnect.
- Review. Reading code it did not write and pointing at a line that uses tomorrow’s data.
Each of those has a right answer someone can check. That is the condition for handing it over.
Where it goes wrong
It writes look-ahead without noticing. A signal computed on a bar’s close and traded at the same bar’s open. A rolling average that includes the current row. The code runs, the backtest looks good, and the result is impossible to trade.
It fills orders for free. Unless you ask for costs, a generated backtest can fill every order at the price it wanted. No fee, no spread, no slippage.
It treats every request to improve the result as a fresh start. “Make the backtest better” sends the model off to tune parameters. Ten rounds of that are ten trials, and the best of ten is partly luck. The model does not count the trials, so nobody corrects for them. The deflated Sharpe ratio exists for exactly this problem.
It writes calls to APIs it half remembers. Say, an endpoint from an old version of the API. Or a field that was renamed, or an order type the venue never had. These fail loudly in testing, which is the good case. The bad case is a call that works and does something slightly different.
It doesn’t know what it doesn’t know about the venue. How a prediction market settles a disputed outcome. When an exchange pauses for maintenance. What a betting exchange does to an in-play order. Those are in the venue’s rulebook. A model writes code for the venue it imagines.
How we use it on a trading bot
The rules stay with a person. A human writes the strategy as rules and signs them off. The model writes code against those rules and never decides what the rules are.
Every venue fact comes from the venue’s own documents, with the link kept next to the code that depends on it.
Limits live outside the strategy. Position size, daily loss and order rate are capped in a layer the generated strategy code cannot change. The kill switch is in that layer too.
A second agent reviews what the first one wrote, with one job: find leakage and free fills. Then a person reads the order path line by line, because that is where money leaves.
Every backtest run is logged with its parameters, so the number of trials is known at the end.
So should you use one to build your bot?
If you write code and you know these failure modes, a model makes you much faster. If you don’t, it will hand you a backtest you have no way to judge, with code that looks finished.
That is the part we do for clients. We build the bot to your strategy and test it with the costs and the trial count in. Then it runs in stages before it trades at size. More on that on our algorithmic trading page. Already have a backtest written with an AI? Checking whether to trust it is a backtest audit.