quantwave
quantwave copied to clipboard
options: implied_vol edge cases (return None/NaN on zero price and intrinsic without time value)
Problem
Observed in trade_backtest 5/6-DTE strangle rebuild:
implied_vol(0.0, ...)returns0.0on OTM options instead ofNone/NaN. A zero price is not a valid market quote, and a 0.0 vol can erroneously pass a naiveiv > 0check.- For deep ITM options quoted at or below intrinsic (e.g.
F=8000, K=7500, r=0.065, T=1.2/365, call price499.893where undiscounted price is499.9998vs intrinsic500.0094), time value is near zero or negative, making IV undefined.implied_volreturned0.153instead ofNone/NaN.
Ask
Return None (or NaN in vectorized / Polars outputs) whenever:
market_price <= 0.0undiscounted_price <= intrinsic(i.e. zero or negative time value)t <= 0.0or non-positive spot/strike/forward.
Resolved in v0.10.2: implied_vol returns None/NaN when price <= 0.0, t <= 0.0, or quote is at/below intrinsic without time value.