How to build a Trading Bot with an AI agent
Use your coding agent to write and backtest a strategy in an open-source framework like Freqtrade, then run it in dry-run mode with fake money. The agent writes the strategy file and runs the backtests for you. Treat it as a learning project. Results from a backtest do not predict real returns.
Checked against official docs on Oct 26, 2026.
Get the free starter kit. One short email a day when our setups change.
Free starter kit on signup: 2 Claude Code skills and 1 agent persona from our paid packs. By subscribing you agree to get The AI Loadout Daily, one email each morning. No spam, we never sell your email, and every email has a one-click unsubscribe link.
Claude Code
Install Freqtrade from its docs (freqtrade.io)freqtrade create-userdir --userdir user_datafreqtrade new-config --config user_data/config.json (keep dry_run on)Ask Claude Code: "Write a simple strategy in user_data/strategies/MyStrategy.py and explain every rule."freqtrade download-data -c user_data/config.jsonfreqtrade backtesting -c user_data/config.json --strategy MyStrategy
Codex
Same setup, then ask Codex to write the strategy and run the backtest commandAsk it to list the assumptions behind the result, like fees and slippage
Cursor
Open the user_data folder in CursorAsk the agent to write the strategy and add commentsRun freqtrade trade -c user_data/config.json --strategy MyStrategy with dry_run still true
Grok Bot
Ask Grok Bot to explain a strategy idea and check it against Freqtrade's docsHave it read your backtest output and point out overfitting
Gotchas
- Backtests overfit easily. A great backtest often fails live.
- Never give an agent exchange API keys with withdrawal rights.
- Freqtrade's own README says to start in dry-run and not risk money you cannot lose.
The loadout for this job
- Tools: Claude, Cursor
- Repo: OpenAI Codex CLI
- Model: Claude Opus 5.5
- Bot: Freqtrade
- Full setup: Best AI trading bot setup (paper trading first)
FAQ
Can an AI agent build a trading bot?
It can write and backtest strategy code in a framework like Freqtrade. That does not mean the bot will make money.
What is dry-run in Freqtrade?
A mode where the bot trades with simulated money so you can watch it without risk.
Related how-tos
Sources
Commands change. Check the linked docs before you run anything. All how-to guides