Repository navigation
get_cot: overlap weeks keep the larger scaled open interest - #122
Merged
Merged
Conversation
Where a hist_codes predecessor and the primary code both report the same week, keep the row with the larger Open_Interest_All after the predecessor's scale is applied. Primary still wins ties; a frame with no OI column keeps the old primary-wins behaviour exactly. Measured reason: at the 2017 Russell 2000 hand-off from ICE (23977A) back to CME (239742), CME's first four weeks (2017-08-15 to 2017-09-05) reported 13k to 37k contracts against ICE's 545k to 567k, and primary-wins printed that slice as the market, including a +22% commercial net on 2017-08-15 that the 567k pool did not show. RTY now switches to CME on 2017-09-12; LBR stays on the random-length contract until it stops reporting on 2023-04-18 instead of switching on 2023-02-21 at 1,029 contracts. Only RTY and LBR carry hist_codes, so only those weeks change. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Oct 10, 2026
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
get_cotoverlap weeks (ahist_codeshand-off between listings) now keep the row with the larger scaledOpen_Interest_All, not the primary code. Primary wins ties; a frame with no OI column behaves exactly as before.23977A) back to CME (239742), CME's first four weeks (2017-08-15 to 2017-09-05) reported 13k to 37k contracts against ICE's 545k to 567k. Primary-wins printed that slice as the market, including a +22% commercial net on 2017-08-15 that the 567k pool did not show.RTYswitches to CME on 2017-09-12 (the week CME's OI reached 810k);LBRstays on the random-length contract through 2023-04-18 instead of switching on 2023-02-21 at 1,029 contracts. Only RTY and LBR carryhist_codes, so no other symbol changes.Unreleased / Changed; a paragraph indocs/design/reading-the-store.mdbeside the existing hand-off discussion.Test plan
tests/test_cot_stitch.py: predecessor wins when larger, primary wins when larger, tie goes to primary, no-OI fallback, re-labelling, sorted/unique indextests/test_cot.pyLBR stitch test rewritten to assert the new rule in both directionsruff check src tests scriptsclean~/code/cotdata_storefor RTY (legacy, tff) and LBR (legacy, disagg): no duplicate dates, switch weeks as stated aboveDownstream note:
COTMETRICS_CACHEentries for RTY or LBR carry the old weeks until rebuilt.🤖 Generated with Claude Code