解读回测成本:配置字段何时不起作用
代码 《交易机器学习》
总结
这篇配置说明区分了会出现在回测身份标识中的设置,以及实际影响模拟交易成本的设置。在所述案例中,所有已登记运行都采用向量化的持有至到期路径。配置中的执行价格、佣金率和滑点率字段并未传入该路径;报价侧成交则属于事件驱动经纪商,而向量化运行并未构建该经纪商。配置仍保留这些设置,因为删除它们会改变现有运行的哈希身份标识。
实际成本另从配置文件读取,包括期权进出场价差、每次再平衡时估算的对冲价差,以及按合约或按股收取的佣金。说明指出,尽管已计入成本,所述样本中记录的总滑点字段仍为空,因为该路径不会记录成本总额。这是一条有用的审计经验:仅凭配置值或缺失的成本指标,无法判断回测实际支付了什么成本。结论适用于指定实现;如果运行器或成本传递流程发生变化,就应重新检查。
核心观点
- 即使执行路径不使用某些配置字段,这些字段仍可能影响运行的哈希身份标识。
- 本文所述的向量化持有至到期路径不使用按费率配置的佣金和滑点字段。
- 实际模拟成本来自期权、对冲和清算等独立成本部分。
- 汇总滑点字段为空,并不能证明没有计入成本。
- 如何解读成本,取决于对具体运行器及其数据流的追踪。
标签
全文
# base.yaml ```yaml # Three fields below are inert on the path this case study runs: `execution.execution_price`, # `commission.rate` and `slippage.rate`. Every registered backtest here is `ret_to_expiry`, # which `case_studies/utils/backtest_runner.py` routes to `_run_htm_daily_mtm`, and that call # is not passed `cost_spec` - the only thing that carries these rates into a run. The # `quote_side` fill is read by the event-driven broker, which a `rebalance.mode: vectorized` # case study never constructs. They still reach the registered `backtest_config` and so the # hashed identity, which is why they stay: removing them would re-key 879 backtests to delete # values nothing reads. # # The costs this case study actually pays come from `_htm_backtest.py`, which reads # `config/setup.yaml::costs.components` directly - per-leg entry spread from the real option # quotes, `hedge_spread.estimate_bps_of_notional` on every hedge rebalance, # `commission.option_per_contract` and `commission.equity_per_share`, plus an exit spread on # liquidation. Verified 2026-09-12; `total_slippage` is NULL on all 879 rows because the # vectorized path records no cost totals, not because nothing was charged. account: allow_short_selling: true execution: execution_price: quote_side mark_price: price execution_mode: next_bar commission: model: percentage rate: 0.0005 slippage: model: percentage rate: 0.0002 calendar: calendar: NYSE timezone: UTC data_frequency: daily feed: timestamp_col: timestamp entity_col: symbol price_col: instr_mid close_col: close bid_col: instr_bid ask_col: instr_ask mid_col: instr_mid metadata: case_study: sp500_options ```
在遵守原作品许可的前提下,附作者信息全文展示。 许可协议: MIT
此摘要由 Stratmill 研究智能体根据原文撰写,并非原文副本。