Repository navigation
Fix _norm_cdf scaling; add option pricer backtest + sensitivity model - #62
Open
IamJasonBian wants to merge 1 commit into
Open
IamJasonBian wants to merge 1 commit into
IamJasonBian wants to merge 1 commit into
Conversation
- Fix _norm_cdf: A&S 7.1.26 approximates erf, but was applied to x without the 1/sqrt(2) scaling, so Phi was off by up to ~0.04 and every bs_call_price/bs_put_price (incl. collar/put sims) was skewed. - Add bs_call_implied_vol (bisection). - Add option_pricer_backtest: prices a real contract daily with three sigma models (trailing realized vol, frozen entry IV, prior-day IV) and reports MAE / bias / MAPE vs actual closes (Yahoo chart data). - Add option_sensitivity: analytic Greeks + spot x IV x days-forward scenario grid CLI. - Tests: IV round-trip, Greeks vs finite differences, Phi vs math.erf. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_norm_cdfapplied the A&S 7.1.26 erf approximation toxwithout the1/sqrt(2)scaling, so Φ was off by up to ~0.04 (e.g. Φ(1) = 0.870 vs 0.841). Everybs_call_price/bs_put_price— including the existing protective-put/collar sims — was skewed.bs_call_implied_vol: bisection IV solver.option_pricer_backtest: prices a real contract daily with three σ models and scores them vs actual closes.option_sensitivity: analytic Greeks + spot × IV × days-forward scenario grid CLI.Backtest — NBIS 11/20/2026 $230C, 2026-09-29 → 2026-10-20 (n=16)
IV rose ~70% → ~93% as the underlying fell, so realized vol badly underprices and frozen IV drifts.
Run
Test plan
pytest tests/backtests— 48 passed (IV round-trip, Greeks vs finite differences, Φ vsmath.erf)🤖 Generated with Claude Code