How to Backtest a Trading Strategy With AI
A backtest replays a trading strategy on past prices to see how it would have done. An AI assistant can write the code, explain the results and flag mistakes such as lookahead bias. Past results do not predict future returns. Moby does not run backtests. You can hand a tested strategy to a capped agent afterward.
What a backtest tells you (and what it does not)
A backtest shows whether a set of rules would have made or lost money on prices that already happened. It is a check, not a forecast. A strategy that looks strong on an old chart can fail when spreads, fees or the next market are different. Use it to reject weak rules before any live order.
Moby itself has no backtesting feature. The test runs in tools you choose. The agent, if you use one later, only places live swaps inside caps you set.
Step by step with an AI assistant
- Write the rules in plain words: what to buy, when to sell, and how large each trade is.
- Get historical prices for the market you care about. For Solana tokens, use that token's own trades, not a stock index.
- Ask the model to write the test. Python with backtesting.py is a common start. Qlib and TA-Lib are research libraries you can read beside it.
- Read the output: how many trades, how deep the loss got, and whether a few lucky trades carry the result.
- Put fees and slippage in the test. A curve that ignores them is not a result you can trade.
The model writes and explains code. It does not hide a backtest inside Moby. You still decide whether the rules are sound.
Common traps
- Lookahead bias. The test uses a price or a signal that was not known yet. Fix: the code may only see data from before the bar it trades.
- Overfitting. The rules were tuned until the past looks perfect. Fix: keep a stretch of data you did not use to pick the rules, and see if they still hold.
- Survivorship bias. The test only includes tokens that still exist. Fix: include names that went to zero if your rules would have bought them.
- Ignoring fees. The curve looks fine until the swap fee and onchain fees are in it. Fix: put both in the test before you trust it.
From backtest to a live agent
A backtest is not a live agent, and a clean chart of the past is not permission to size up. When you try the rules with real money, start small. You set your agent's limits on max per trade, daily buy volume and market-cap range from the Moby app, and Moby checks them server-side on every buy your agent makes.
How large a position should be, and what to do when a trade goes against you, is on AI trading risk management. Setup for the agent is on Moby Agents.
Frequently asked questions
Can ChatGPT backtest a strategy?
ChatGPT can draft the code and explain a result you paste in. It does not run a hidden backtest inside Moby. A clean chart of the past is not a forecast of the next trade.
Is backtesting with AI accurate?
Only as accurate as the data, the fees, and the checks for lookahead and overfitting. The model can miss a bug. Read the code. Past results do not predict future returns.
What should I test before letting an agent trade?
Test the rules, the fees, and a stretch of data you did not use to tune the rules. Then set caps before the first live buy. You set your agent's limits on max per trade, daily buy volume and market-cap range from the Moby app, and Moby checks them server-side on every buy your agent makes.
What does Moby charge?
Moby does not charge for a backtest, because Moby does not run one. For a live swap, a 0.75% swap fee (minimum $0.90 per swap), plus onchain fees. The agent wallet is funded in USDC, and agent trading is Solana only for now.
Try it with a Moby Agent
Set up a Moby Agent with its own wallet and your spending guardrails, then connect it to the AI you use.
You set your agent's limits on max per trade, daily buy volume and market-cap range from the Moby app, and Moby checks them server-side on every buy your agent makes.
Moby Agents connect from Codex, Claude Code (CLI), Gemini CLI (with a paid Gemini API key or enterprise access) and Grok CLI, with the agent key. In ChatGPT, paste your personal Moby connector URL from the app. ChatGPT: works on Business, Enterprise and Edu workspaces that allow custom MCP servers (web).
Each user gets one agent, with its own wallet separate from the main wallet in the app. The wallet is funded in USDC. The agent cannot withdraw or send funds. Agent trading is Solana only for now. Agent trading on Base, BNB Chain and Robinhood Chain is coming soon.
A 0.75% swap fee (minimum $0.90 per swap), plus onchain fees
Start at Moby Agents. How the agent sits next to trades you place yourself is agentic trading.