Repository navigation
refactor(cftc): build the FX market once for the vol surface and trade valuation - #7857
Open
artcashin wants to merge 1 commit into
Conversation
…e valuation The implied-vol surface and the forex valuations each built their own market, with a different notional floor, curve depth, forward-aware setting and spot rule. Both now call fx_vol.build_market: - $1,000 floor on every print that sets spot or a curve node - spot from the pair's forward curve, else its near prints, else deliverable forwards settling by the spot date (crossed through USD) - forward-aware discount curves, deepest swap family first, at the caller's min_trades A valued option now reads its vol from its own cell of the empirical surface (expiry bucket and strike-grid step), then the expiry bucket, then the nearest expiry as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This branch has not been deployed
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.
Description
The last two follow-ups from the #7750 review. Stacked on #7833, which covers the first two; this PR's own diff is the single commit on top of it.
One shared market builder
fx_implied_volandfx_marketeach built their own market. Both now callfx_vol.build_market, which owns:min_tradesmin_tradesstays a query parameter on both endpoints, so the defaults still differ (3 and 1). Say if you want one default.The
days > 2cut-off in_deliverable_spotnow usesFORWARD_MIN_DAYS.fx_spottakes the floor as an argument; its other callers pass none and are unchanged.A valued option reads its vol like the surface
option_volreads the option's own cell of the empirical surface: the same expiry bucket, strike-grid step and 0.5x to 2x trim, through a newsurface_pointsthatvol_surfacealso uses. If the cell is empty it takes the expiry bucket, and if that is empty the nearest expiry as before, so no option stops being valued. Pairs outside the surface's pip table use its moneyness grid.Effect on 2026-11-16 (53,375 forex prints)
Surfaces, empirical basis:
The deliverable spots move because the old rule took every forward with a near effective date, whatever its maturity, so the median carried forward points. The direction matches each pair's points (EURUSD down, USDJPY and USDCAD up).
Valuations (
value_fx_tradeover the whole file):Not included
ndf_forward_curve,observation_curveandois_discount_factorno longer have a caller outside the tests. I left them; say if you want them removed with their tests.fx_forward_pointsbuilds its own discount curves (min_trades=3, forward-aware). It was not part of the review and is unchanged.Tests
openbb_platform/providers/cftc: 1,254 passed locally (Python 3.12). New tests cover the builder's spot rule and floor, the cross through USD, forward-aware discount lookup, the surface and the valuation getting the same market, and the three levels of the option vol reading.ruff formatandruff checkare clean on the touched files. No CI run yet.🤖 Generated with Claude Code