Repository navigation
Fetch the futures-and-options combined basis of Legacy, Disaggregated and TFF - #131
Merged
Merged
Conversation
… and TFF cotdata fetched one basis per report: futures-only for Legacy, Disaggregated and TFF, combined for the Supplemental (which has no other). The CFTC publishes the first three on both bases, so the combined files now land in three new store domains, cot_legacy_combined/, cot_disagg_combined/ and cot_tff_combined/, on the cot half of the manifest seam (ADR-0003). - Producers take combined=True, which selects zip name, cache directory and store writer together. Legacy combined runs from 1995 (deacom_xls_ before 2004, dea_com_xls_ after); Disaggregated and TFF use the com_* zips and their own 2006-2016 bundles, and refuse a file whose FutOnly_or_Combined column disagrees with the basis asked for. - cotdata-update gains --cot-legacy-combined, --cot-disagg-combined and --cot-tff-combined; --cot-all now runs all seven domains. - get_cot(name, report, combined=None): None is each report's natural basis, so every existing call is unchanged; combined=False on supplemental raises. - Vintage: annual_sources emits both bases of every zip, Source and every snapshot record carry a combined flag, the fetch default captures all seven current-week statics, ingest passes the basis to the Legacy canonicaliser and cross-checks the file flag for Disaggregated and TFF, and coverage/asof take a basis with the natural-basis artifact keeping its name. - --check widens the domain column to fit the new names. Measured 2026-10-27, combined against futures-only open interest: ES 2,843,639 vs 1,955,711, GC 518,784 vs 396,810, CL 2,606,478 vs 1,886,280. All three producers smoke-tested on both bases for 2026 against a scratch store. Co-Authored-By: Claude Fable 5.1 <[email protected]>
The Supplemental's _NoCIT buckets are Legacy combined's buckets with the index traders removed, so with the combined basis in the store the two reports join week by week into a partition neither publishes alone. cit.decompose(name) makes the join for one of the 13 markets and splits each Legacy bucket into its ex-index part and the index position carved from it (spreading as the residual: the store keeps no Legacy spread column); cit.check(name) counts how it holds. It never reads futures-only Legacy and refuses a market where open interest or non-reportable disagree, which on the combined basis is a basis, stitching or vintage error. Measured over the whole history from the store (scripts/ cit_legacy_decomposition.py, docs/analysis/2026-10-31-cit-legacy- combined-decomposition.md): the exact identities hold on 13,753 of 13,753 shared market-weeks; 187 carve-outs sit at -1 from rounding and none below; between a fifth and two thirds of Legacy's commercial longs in these markets is index money, and the Legacy commercial net is positive on average in ZW and GF only because of it. Corrects Soybean Meal's first Supplemental report to 2013-04-02 (the 2026-08-03 doc gave the 2013 file's first date). Co-Authored-By: Claude Fable 5.1 <[email protected]>
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.
Why
cotdata fetched one basis per CFTC report: futures-only for Legacy, Disaggregated and TFF, and combined for the Supplemental, which the CFTC publishes on no other basis. The CFTC publishes the first three on both bases. This closes that gap on the pattern ADR-0002 set for the fourth report: the boundary is "CFTC positioning", not the inventory we happened to have. Decision recorded in
docs/adr/ADR-0003-combined-basis-is-in-scope.md.What
cot_legacy_combined/,cot_disagg_combined/,cot_tff_combined/, all on thecothalf of the manifest seam. A directory per basis, never a column: the futures-only directories are byte-for-byte what they were, and no reader can return both bases in one frame.combined=True, which selects zip name, cache directory and store writer together. Legacy combined runs from 1995 (deacom_xls_before 2004,dea_com_xls_after). Disaggregated and TFF use thecom_*annual zips and their own 2006-2016 bundles, and_assert_basisrefuses a file whose ownFutOnly_or_Combineddisagrees with the basis asked for. The Legacy files carry no such column (checked on the 2026 and 2003 files: 126 columns, same names as futures-only), so there the URL is the only evidence and the two bases are separated by construction.--cot-legacy-combined,--cot-disagg-combined,--cot-tff-combined;--cot-allnow runs all seven. Every deployed launcher calls--cot-all, so the new domains appear on the next scheduled run after the producer pulls this. The first such run downloads the Legacy combined history and the two bundles once.get_cot(name, report, combined=None).Noneis each report's natural basis, so every existing call returns what it did.combined=Falseonsupplementalraises.annual_sourcesemits both bases of every annual zip (seven per year from 2010);Sourceand every snapshot record carrycombined; the fetch default captures all seven current-week statics (deafut,deacom,f_disagg,c_disagg,FinFutWk,FinComWk,deacit), each holding its report date in the fieldvintage_schedulealready reads. Ingest passes the snapshot basis to the Legacy canonicaliser and cross-checks the file's flag for Disaggregated and TFF.derive_coverage,write_coverage,read_coverageandasoftakecombined; the natural-basis coverage artifact keeps its filename,{report}_combined.parquetholds the other.cotdata-vintage coverage --combined.--checkwidens the domain column to fit the new names.docs/design/cot_vintage.md§3c anddocs/design/cross-report-comparability.md§4/§5.Measured
Open interest on 2026-10-27, all three producers run on both bases for 2026 into a scratch store, read back through
get_cot:The combined Disaggregated/TFF files read
FutOnly_or_Combined == "Combined"on every row and have the same 190 / 86 columns as the futures-only files.Tests
ruff check src tests scriptsclean. Newtests/test_cot_combined_basis.pypins the URL tables and the 2004 rename on both bases, domain isolation, reader dispatch per basis, the CLI flags and--cot-allmeaning seven, the both-bases vintage source set and start years, the seven statics, basis on snapshot and failure records, canonicaliser dispatch and mismatch refusal, and per-basis coverage.test_capture_includes_supplemental_from_2006): 2005 now has two Legacy sources, one per basis.Not in this PR
CLAUDE.mdline about cotdata is updated incrucible-stack/docs/workspace-CLAUDE.mdas a separate PR.dea_cit_txt_2006_2016.zipdoes exist today (no_hist). Left alone, the code works either way.Type of change
Checklist:
ruff check src tests scriptsclean)pytest, 259 passed) and they pass locallySecond commit:
cotdata.cit, the Supplemental joined to Legacy combinedWith the combined basis in the store, the Supplemental (whose
_NoCITbuckets are Legacy combined's buckets minus the index traders) joins Legacy week by week.cit.decompose(name)splits each Legacy bucket into its ex-index part and the index position carved from it;cit.check(name)counts how the join holds. It never reads futures-only Legacy and refuses a market where open interest or non-reportable disagree (a basis, stitching or vintage error on this basis). Measured over the full history (scripts/cit_legacy_decomposition.py,docs/analysis/2026-10-31-cit-legacy-combined-decomposition.md): exact on 13,753 of 13,753 shared market-weeks; 187 carve-outs at -1 from rounding, none below; a fifth to two thirds of Legacy "commercial" longs in these 13 markets is index money. Corrects Soybean Meal's first Supplemental report to 2013-04-02. 10 new tests (269 total), ruff clean onsrc tests scripts.🤖 Generated with Claude Code