Backtest AI Agent BETA
Backtest AI Agent BETA turns a plain-English trading idea into a replay-ready strategy, then optionally runs it across historical resolved markets.Backtest AI Agent BETA is available on Pro and Enterprise plans only. Pro includes the beta free with 5 strategy generations per month.
Authentication
Backtest AI Agent endpoints are authenticated dashboard endpoints. Use the same logged-in session or bearer token used by the PolyHistorical dashboard.Bearer token for a logged-in Pro or Enterprise customer.
Must be
application/json for POST requests.Endpoints
| Method | Endpoint | Description | Consumes AI quota |
|---|---|---|---|
POST | /v1/backtest-ai/generate | Generate a replay-ready strategy from a prompt | Yes |
POST | /v1/backtest-ai/strategy | Generate a strategy and backtest it across markets | Yes |
POST | /v1/backtest-ai/run | Run an already-generated strategy or strategy code | No |
GET | /v1/backtest-ai/quota | Get monthly Backtest AI Agent quota | No |
Generate a strategy
POST /v1/backtest-ai/generate returns a normalized strategy object that can be inspected, copied, or sent to /v1/backtest-ai/run.
Body parameters
Natural-language strategy description.
Optional preset identifier, such as
mean_reversion, dip_buying, momentum_entry, or quick_scalp.Market coin. Allowed values include
BTC, ETH, and SOL.Market timeframe, such as
5m, 15m, 1h, 4h, or 24h.Number of resolved markets to target when running the strategy. Must be between
1 and 100.Number of shares to simulate per trade. Must be between
1 and 10000.Stop-loss percentage from
1 to 100.Order type. Allowed values:
MARKET, LIMIT.Example
cURL
Response
Generate and backtest
POST /v1/backtest-ai/strategy accepts the same body as /generate, then immediately runs the generated strategy across the requested resolved markets.
The response includes:
generated_strategy— normalized replay-ready rulesaggregate— combined performance summary across tested marketsresults— per-market replay results or errorsquota— updated monthly Backtest AI Agent quota
Run a generated strategy
POST /v1/backtest-ai/run runs an existing generated strategy without consuming another AI generation.
You can send either:
generatedStrategy— the generated strategy object returned by/generatestrategy_code— copied strategy code generated by the dashboard
Example
cURL
Get quota
GET /v1/backtest-ai/quota returns the current monthly Backtest AI Agent usage.
cURL
Errors
| Code | HTTP Status | Description |
|---|---|---|
BACKTEST_AI_REQUIRED | 403 | Customer is not on Pro or Enterprise |
BACKTEST_AI_QUOTA_EXCEEDED | 429 | Monthly Backtest AI Agent quota has been reached |
AI_STRATEGY_GENERATION_FAILED | 502 | Strategy generation failed |
NO_BACKTEST_MARKETS | 404 | No resolved markets matched the request |