Workflows¶
The workflows
package provides high-level classes that orchestrate
multi-step processes like daily model calibration and historical backtesting.
BacktestWorkflow ¶
Orchestrates a backtest for a single model over multiple historical snapshots.
This workflow iterates through available historical data, using each day's data to calibrate a model and the subsequent day's data to evaluate its out-of-sample performance.
Initializes the backtest workflow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ticker
|
str
|
The stock ticker to run the backtest for. |
required |
model_config
|
dict
|
A dictionary "recipe" defining how to calibrate the model. |
required |
Source code in src/optpricing/workflows/backtest_workflow.py
run ¶
Executes the full backtesting loop.
It fetches available dates, then for each calibration/evaluation pair,
it runs a DailyWorkflow
to calibrate the model and then evaluates
the out-of-sample RMSE on the next day's data.
Source code in src/optpricing/workflows/backtest_workflow.py
save_results ¶
Saves the collected backtest results to a CSV file in the artifacts directory.
Source code in src/optpricing/workflows/backtest_workflow.py
DailyWorkflow ¶
Orchestrates the calibration of a single model for a single snapshot of market data.
This class encapsulates the entire process for a given day: 1. Fits market-implied risk-free rate (r) and dividend yield (q). 2. Prepares initial parameter guesses, optionally using historical data. 3. Calibrates the model to front-month options. 4. Evaluates the calibrated model's performance (RMSE) on the full option chain.
Initializes the daily workflow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
market_data
|
DataFrame
|
A DataFrame containing the option chain for a single snapshot date. |
required |
model_config
|
dict[str, Any]
|
A dictionary defining how to calibrate the model. |
required |
Source code in src/optpricing/workflows/daily_workflow.py
run ¶
Executes the full calibration and evaluation workflow.
This method performs all steps in sequence and populates the self.results
dictionary with the outcome, including status, calibrated parameters,
and final RMSE. It includes error handling to ensure the workflow
doesn't crash on failure.
Source code in src/optpricing/workflows/daily_workflow.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|