Skip to content

Fix forwards - #90

Merged
lsbardel merged 3 commits into
mainfrom
ls-surface
Aug 2, 2026
Merged

Fix forwards#90
lsbardel merged 3 commits into
mainfrom
ls-surface

Conversation

@lsbardel

@lsbardel lsbardel commented Aug 2, 2026

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings August 2, 2026 14:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reworks forward and discount-curve calibration for option surfaces so that option pricing uses per-maturity forwards calibrated from put-call parity, while discount curves are derived from those parity forwards using selectable curve models. It also exposes curve-model selection through the API and frontend, adds a full tutorial + example, and updates fixtures/tests accordingly.

Changes:

  • Add parity-based forward calibration (calibrate_forwards) and make surfaces price off parity forwards via pricing_forward.
  • Rework curve calibration to fit quote/asset discount curves from parity-implied discount factors (with a short-maturity exclusion) and support “fixed” curves (e.g. no-discount).
  • Add API/frontend curve selection, new Deribit offline loader builder, and extensive documentation/examples/tests.

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
quantflow/rates/no_discount.py Removes the no-op calibration wrapper and documents that NoDiscountCurve.calibrator() is None.
quantflow/rates/interpolated.py Seeds interpolated curves from an observation grid and averages duplicate TTMs into single nodes.
quantflow/rates/calibration.py Adds YieldCurveCalibration.prepare() and calls it before joint optimisation.
quantflow/options/surface.py Introduces parity_forward / pricing_forward, parity-forward calibration, and parity-forward-based curve calibration.
quantflow/options/ssvi.py Adds fallback behavior in anchored eSSVI slice fitting when no feasible rho is found (uses previous slice when possible).
quantflow/options/parity.py Adds weighted parity regression utilities to calibrate forwards and quote discount factors with a forward held fixed.
quantflow/data/deribit.py Refactors Deribit loader creation into a reusable loader_from_book() for offline rebuilding.
quantflow_tests/test_vasicek_curve.py Updates tests for the new “no calibrator” behavior on NoDiscountCurve.
quantflow_tests/test_surface_methods.py Adds tests validating pricing_forward propagation into pricing + term-structure outputs.
quantflow_tests/test_surface_calibration.py Adds coverage for new curve calibration modes and parity-forward calibration behavior.
quantflow_tests/test_app.py Updates API tests to build a loader via mocked Yahoo data and verifies per-curve-selection caching.
mkdocs.yml Adds the new curve calibration tutorial to mkdocs navigation.
frontend/src/volatility-surface.md Adds UI controls for curve-model selection and updates curve labeling/display.
docs/tutorials/index.md Links the new “Discount Curves from Option Prices” tutorial.
docs/tutorials/curve_calibration.md New tutorial explaining parity-forward calibration and discount-curve derivation workflow.
docs/glossary.md Expands put-call parity glossary entry to include spot/discount-factor form.
docs/examples/curve_calibration.py New reproducible example generating figures and structured outputs for the tutorial.
docs/examples/_utils.py Adds helper to rebuild BTC Deribit loader from recorded fixture (offline).
dev/tools/record_fixtures.py Adds Deribit fixture recording to support the new tutorial/example workflow.
app/api/volatility.py Adds query params for curve selection, updates caching key, and returns parity-forward term structure.
app/api/docs/volatility_surface.md Documents parity-forward pricing and curve-model selection behavior in the API.

Comment on lines +1648 to +1650
forward = parities.calibrate_forward(band=band, min_pairs=min_pairs)
section.parity_forward = to_decimal(round(forward, 8)) if forward else None
if section.parity_forward is not None:
@codecov-commenter

codecov-commenter commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.33333% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.03%. Comparing base (5e16f37) to head (82d48d2).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
quantflow/options/parity.py 90.90% 5 Missing ⚠️
quantflow/options/surface.py 92.85% 4 Missing ⚠️
quantflow/rates/interpolated.py 75.00% 2 Missing ⚠️
app/api/volatility.py 87.50% 1 Missing ⚠️
quantflow/options/ssvi.py 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #90      +/-   ##
==========================================
+ Coverage   88.75%   89.03%   +0.27%     
==========================================
  Files          84       85       +1     
  Lines        5142     5483     +341     
==========================================
+ Hits         4564     4882     +318     
- Misses        578      601      +23     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI review requested due to automatic review settings August 2, 2026 14:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 25 changed files in this pull request and generated no new comments.

Suppressed comments (1)

quantflow/options/surface.py:1580

  • In calibrate_curves, the per-maturity quote_discount() regression is run unconditionally and must succeed to include a maturity (dq is None -> continue). When quote_curve is None (treated as known per docstring), this can still drop all maturities and raise ValueError("No parity forwards available..."), even though discounting can be taken directly from the existing self.quote_curve and only the asset curve needs fitting. Consider bypassing the regression when quote_curve is known and sourcing dq from self.quote_curve.discount_factor(ttm) instead.
            parities = section.put_call_parities(
                spot, ref_date=ref_date, max_pairs=max_pairs
            )
            forward = float(section.parity_forward / spot)
            if (dq := parities.quote_discount(forward)) is None:

@lsbardel
lsbardel merged commit 57be1c7 into main Aug 2, 2026
8 checks passed
@lsbardel
lsbardel deleted the ls-surface branch August 2, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants