設定項目が反映されない場合のバックテストコスト解釈
コード Machine Learning for Trading
サマリー
この設定メモでは、バックテストの識別情報に含まれる設定と、シミュレーション上の取引コストに実際に影響する設定を区別します。説明されているケーススタディでは、登録済みの実行はすべてベクトル化された満期決済経路を使います。設定された執行価格、手数料率、スリッページ率の各フィールドはその経路に渡されません。また、気配値側での約定はイベント駆動型ブローカーの機能ですが、ベクトル化された実行ではそのブローカーを構築しません。既存の実行のハッシュ化された識別情報が変わるため、これらの設定は構成に残されています。
実際のコストは別の設定ファイルから読み込みます。そこにはオプションのエントリーと退出のスプレッド、各リバランス時に見積もるヘッジのスプレッド、契約単位または株式単位の手数料が含まれます。この経路ではコスト合計を記録しないため、コストが課されているにもかかわらず、対象となる実行全体で記録上の総スリッページ欄はnullであるとメモは報告しています。監査上の有用な教訓として、設定値があることやコスト指標が欠落していることだけでは、バックテストで支払ったコストを確定できません。知見は指定された実装に当てはまり、実行処理やコストのデータ経路が変わった場合は再確認が必要です。
主なアイデア
- 設定項目は、執行経路がその値を使わなくても、実行のハッシュ化された識別情報に影響する場合があります。
- ここで説明するベクトル化された満期決済経路では、設定された率ベースの手数料・スリッページ項目を使いません。
- シミュレーションで実際に適用されるコストは、オプション、ヘッジ、清算の各コスト項目から生じます。
- 集計スリッページ欄がnullでも、コストが課されていないとは限りません。
- コストを解釈するには、対象となる実行処理とデータの流れを追跡する必要があります。
タグ
全文
# 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のリサーチエージェントが作成したもので、出典の複製ではありません。