Skip to content

fix(cftc): value each FX forward against the pair's other prints - #7833

Open
dlee-bq wants to merge 5 commits into
developfrom
bugfix/cftc-fx-own-print-exclusion
Open

dlee-bq wants to merge 5 commits into
developfrom
bugfix/cftc-fx-own-print-exclusion

Conversation

@dlee-bq

@dlee-bq dlee-bq commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

  • Follow-up to #7750, which values each forward against a curve that includes the print itself.
  • Each forward is now valued against the pair's other prints. ObservationCurve.curve(without=<dissemination identifier>) leaves that print's observation out of its tenor node and the near-tenor spot pool in O(tenor nodes). fx_market uses it for every forward.
  • Options, prints below the $1,000 floor, and prints with a blank or repeated identifier use the shared curve, as in perf(cftc): build each FX pair's forward curve once per day, shared with the vol surface #7750.
  • fx-pair and fx-df memo keys carry the curve date.
  • observation_curve wraps ObservationCurve; ndf_forward_curve and the vol surface are unchanged.
  • Observations carry dissemination_identifier.

CI fixes (own commits)

  • tests/conftest.py: scrub_string assigned the return value of dict.update (None) to the header. vcrpy 9 cannot replay a None header, which failed test_cftc_cot_fetcher and test_cftc_cot_sarch_fetcher and left cot.py below the 100% coverage gate.
  • pyproject.toml: ty 0.0.100 renamed unresolved-import to import-not-found and exits 1 on the old name.

Evidence

Data: DTCC forex and rates slices for 2026-11-05, 11-06, 11-09, 11-10 (downloaded) and 2026-10-09 (local cache): 220,285 forwards and 4,777 options. Every priceable print is valued with one memo per day, as _keep_priceable_forex does. CNY curve extras are not fetched.

Reference ("exact"): the same code with that print's own record removed from the pair's records. It covers every forward on 2026-10-09 and a random 21% to 59% of the other days (99,568 of 220,285 forwards, 45%).

Market rate against the reference, pooled over the 98,794 checked forwards, by number of prints at the forward's tenor:

Prints at tenor Checked #7750 median / max error (bp) This PR Zero marks #7750 / this PR / exact
1 (alone) 565 11.48 / 639 identical 547 / 7 / 7
2 402 1.72 / 1,953 identical 120 / 120 / 120
3 271 2.30 / 100 identical 142 / 22 / 22
4-5 548 0.89 / 77 identical 151 / 83 / 83
6-10 1,148 0.50 / 421 identical 250 / 176 / 176
11-50 5,006 0.15 / 34 identical 802 / 630 / 630
over 50 90,854 0.00 / 2.9 identical 690 / 531 / 531

"Identical" is bit-identical floats on all 98,794. A zero mark is a market rate equal to the traded rate.

All 220,285 forwards, #7750 against this PR:

Other checks:

Known limits

  • Exact for the observation, not for re-extraction. The extraction anchor (median of all candidate rates) still includes the valued print and gates which peers pass the carry bound. On the real data this changed no result (98,794 of 98,794 identical). On synthetic wide-spread records it differs for 0.5% (realistic mix) to 5% (stress mix) of observation prints.
  • Blank or repeated identifiers are not left out. There are none among the 220,285 forwards.
  • Package legs stay in the curve, as in perf(cftc): build each FX pair's forward curve once per day, shared with the vol surface #7750.
  • Cost per forward grows with the number of prints at its tenor (a list slice and a median).

…its tenor

- A print that is the only observation at its tenor no longer supplies its own node, so it cannot force flat extrapolation or a zero mark
- A print that shares its tenor keeps the pair's shared curve
- Observations carry the dissemination identifier
- observation_curve builds the curve from extracted observations; ndf_forward_curve delegates to it
- fx-pair and fx-df memo keys carry the curve date

Signed-off-by: dlee-bq <325002271+dlee-bq@users.noreply.github.com>
- scrub_string assigned the return value of dict.update, which is None, so every scrubbed header became None
- vcrpy 9 cannot replay a None header value, which failed test_cftc_cot_fetcher and test_cftc_cot_sarch_fetcher and left cot.py below the 100% coverage gate

Signed-off-by: dlee-bq <325002271+dlee-bq@users.noreply.github.com>
- ty 0.0.100 renamed the rule and exits 1 on the old name, which failed the Lint (ruff + ty) job

Signed-off-by: dlee-bq <325002271+dlee-bq@users.noreply.github.com>
- ObservationCurve builds a pair's forward curve once and leaves one print's observation out in O(tenor nodes)
- fx_market leaves the valued print out of the curve for every forward, not only prints alone at their tenor
- A print whose identifier is blank or repeated is not left out
- observation_curve wraps ObservationCurve; the vol surface is unchanged

Signed-off-by: dlee-bq <325002271+dlee-bq@users.noreply.github.com>
@dlee-bq dlee-bq changed the title fix(cftc): leave a print out of its own FX curve when it is alone at its tenor fix(cftc): value each FX forward against the pair's other prints Nov 11, 2026

This branch has not been deployed

No deployments
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.

1 participant