tool_run_backtest
Execute a trading-strategy backtest by defining entry/exit rules, indicators, and risk settings; returns a backtest ID to retrieve performance results.
Instructions
Define and execute a trading strategy backtest.
The strategy object must include:
name: Strategy name
direction (optional): "long" (default), "short", or "both"
"long": entry_rules trigger buys, exit_rules trigger sells
"short": entry_rules trigger short entries, exit_rules trigger short covers
"both": uses entry_rules/exit_rules for longs, plus short_entry_rules/short_exit_rules for shorts
entry_rules: List of rules that trigger entry
exit_rules: List of rules that trigger exit
short_entry_rules (required when direction="both"): Rules for short entries
short_exit_rules (required when direction="both"): Rules for short exits
stop_loss (optional): Stop loss as fraction (0.05 = 5%)
take_profit (optional): Take profit as fraction (0.15 = 15%)
Each rule has:
indicator: SMA, EMA, RSI, MACD, or BB
params: Indicator parameters (e.g. {"period": 50})
condition: crosses_above, crosses_below, greater_than, less_than, equals
compare_to: Another indicator object or a numeric value
Returns a backtest_id. Use get_backtest_status to poll for completion, then get_backtest_results for the full results.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | ||
| end_date | No | ||
| strategy | Yes | ||
| timeframe | Yes | ||
| commission | No | ||
| start_date | Yes | ||
| initial_cash | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||