Expand description
§Simulator: the honest bookkeeper
The simulator walks one underlying forward a day at a time. Each day it either asks the strategy whether to open a trade, or marks the open trade to market and asks whether to close it. Rules it enforces so strategies cannot cheat by accident:
- Decisions use the close of day
t; fills happen at that close. SD is computed from bars up to and includingtonly. - Every leg pays a spread on the way in and the way out, plus commission. Wider for names priced off the IV proxy (single stocks have wider option markets than SPY).
- Returns are on capital at risk: the debit for bought structures, (widest wing − credit) for sold ones. A 50% return means “made half of what could have been lost”.
- Noise only touches SD’s eyes. When the backtest adds Gaussian noise, SD sees the noisy history, but trades are priced and settled on the real prices and real implied volatility.
Structs§
- Costs
- Trading costs per share, per leg, per side.
- Summary
- Summary of a list of trades.
- Trade
- Underlying
- One underlying’s inputs to the simulator.
Constants§
- RATE
- Interest rate used for pricing. A constant 3% is a simplification; at one-month horizons its effect on straddles and spreads is tiny.
Functions§
- run
- Run one strategy over one underlying, over its whole history.
- run_
window - Run one strategy over bars
start..endonly (“trade a full period”). - run_
window_ open - Live replay: like
run_window, but trades may open even though their expiry lies beyond the last bar (that is what “today” looks like), and the trade still open on the last bar is returned too (marked, not closed): what a live runner holds right now. - summarize