Backtest a futures strategy
run_backtestSaves a futures strategy to the user's CubeLV account and backtests it on 1 to 5 TAIFEX continuous codes with daily or intraday bars, waiting up to about 90 seconds for the result. Returns total and annual return, max drawdown, win rate and trade count, or the backtest id when it is still running. The strategy stays in CubeLV (without notifications) and can be deleted there or with delete_alert.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"symbols": "<symbols>",
"entry_rule": "<entry_rule>",
"from_date": "<from_date>"
},
"name": "run_backtest"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lang | No | Language for data labels (industries, statement items, categories) and links: en, ja, ko or vi; default en | |
| name | No | Name shown in CubeLV | |
| side | No | long, short (entry_rule opens shorts) or both (needs short_entry_rule); default long | |
| exits | No | Intrabar exits: {"stop_loss": {"percent": 1.5}, "take_profit": {"risk_reward": 2}, "trailing_stop": {"atr": 2}} | |
| sizing | No | Position sizing, default {"initial_cash": 10000000, "type": "quantity", "value": 1, "max_positions": 1} (contracts, TWD; a position uses the full contract value, e.g. TXF about 200 TWD per point) | |
| session | No | Trading session of the bars; default all | |
| symbols | Yes | 1 to 5 TAIFEX continuous codes, e.g. ["TXF1"] or ["MXF1"] | |
| to_date | No | End date YYYYMMDD; default the latest trading day | |
| interval | No | Bar interval; default 1d | |
| exit_rule | No | Exit conditions, e.g. {"any": [{"indicator": "return_since_entry", "op": "<=", "value": -2}]} | |
| from_date | Yes | Start date YYYYMMDD | |
| entry_rule | Yes | Entry conditions on bar indicators, e.g. {"all": [{"indicator": "close", "op": "cross_above", "value": {"indicator": "ma", "params": {"n": 20}}}]}; indicators include close, ma (params n), rsi, return_since_entry and bars_since_entry; rules nest with all/any (no rank or percentile) | |
| short_exit_rule | No | side both: exit conditions for shorts | |
| short_entry_rule | No | side both: entry conditions for shorts |