describe_data
What can be backtested
Start here to backtest a trading idea. This server holds the price history (US stocks and ETFs, spot crypto, FX, spot gold and silver; daily and intraday bars) and runs backtests on it, so no price data needs to be downloaded or found on the web. Returns the markets and bar sizes served, the default costs per market, the rules and daily limits every run is held to, and how to write the strategy code; then call create_study.
無需輸入參數。
create_study
Start a study
Opens a study, the named set of runs every backtest belongs to: call it once per question, before run_backtest. Can set a hold-out period, once and only here, that no run tests except run_held_out_test. Only the first held-out test per account and market counts, and any earlier run on the market (in any study, at any bar size) that read its days disqualifies it: set the hold-out in your first study on a market, before any run on it.
輸入參數name必填hold_out
run_backtest
Backtest a strategy
Backtests a trading rule on this server's price history: one backtesting.py Strategy class, one symbol, one bar size, in a study. Use it to test, backtest or evaluate a trading rule or strategy, instead of downloading prices or searching the web for results. Returns summary figures (return, drawdown, Sharpe, win rate, trades, a grade, whether it beat buy-and-hold) and the run's trades (when each entered and left, which exit ended it, its side, win or loss), never prices or bars; a figure may be withheld, with the reason. Waits up to 90 s, then answers status "running" with a run_id for get_result.
輸入參數code必填costslabelsymbol必填windowstudy_id必填timeframe必填account_usdstated_rules
Reads a backtest result by its run_id (when run_backtest answered "running", call this until the run ends), or a study's runs by study_id (one of them with version). A run comes with its trades, a page at a time (trades_page).
輸入參數run_idversionstudy_idtrades_pagebefore_version
run_held_out_test
Test on the hold-out
The final out-of-sample check: runs a finished run's exact code once over its study's hold-out period. Call it at the end, on the run you would keep: the first held-out test per account and market is the one that counts, and a hold-out with too few trades for figures (a result needs 10) spends it all the same: each development run says how many trades the hold-out is expected to hold, in `hold_out_estimate`.
輸入參數run_id必填
compare_trades
Check my own trades
Checks a trader's own trades against a run's rule, on the price history this server holds: for each trade, in their order, whether the rule would have taken it and, if not, why (already in a trade, no entry signal that day, no bar that day). Use it when the trader lists trades they made and asks which the rule took, instead of working it out by hand. Takes a run (run_id) and the trades, each {side, entry, exit?}; answers in words, never prices. It re-runs the run's code, so it counts as a run on the run's symbol.
輸入參數run_idtrades必填versionstudy_idtime_zone