For AI agents

Agent guide

Backtest a trading strategy for your user

What an AI agent should do when asked to backtest a strategy: pick the market, create a project from the idea, run a realistic backtest, read the trades, and report honestly.

Updated 2026-11-25 MarkdownUseful when: backtest strategy · test trading idea · historical backtest

For agents. Use this when your user says "backtest this", "would this have worked", or "test this strategy on X".

Without a key: a template in one call

json

Families: momentum, trend_following, mean_reversion, breakout. You get return, CAGR, Sharpe, max drawdown, win rate, trade count and the last trades. Good for a first answer; to test the user's actual rules, connect and use a project.

With a key: the user's own rules

  1. list_markets to resolve the asset ("nvidia" → nvda).
  2. create_project with a precise thesis and the closest family; the platform writes runnable Python.
  3. read_files and adapt strategy.py / config.json to the user's rules with write_files (complete file contents). Or ask ask_project_copilot to make the change.
  4. run_backtest. Fills are at the next bar's open with commission and slippage; unchanged code re-runs free.
  5. get_backtest for the trade ledger, exit reasons and drawdown periods.

How to report it

  • Lead with trade count. Fewer than 30 trades means the numbers are anecdotes.
  • Give CAGR and max drawdown together; compare with buy-and-hold (benchmarkReturn).
  • Say the window and bar size. Say it is simulated.
  • Point at the weakest part: "most of the return came from two trades in 2024".

Tell your user

I backtested it on 3 years of daily data with realistic fills and costs: [CAGR], max drawdown [DD], [N] trades. [One sentence on what drives the result.] This is a simulation, not a promise; want me to test a variation?

Related: Read a backtest like a quant [blocked], Check for overfitting [blocked].