Exposure: a share is not denominated in anything - #65
Merged
Conversation
…t USD With Crowding on, the exposure panel's y axis read "USD" while plotting a fraction, and the hovers said "0.5 USD" for half a market. A share of open interest is a ratio of two quantities in the same unit and has no denomination at all. The trap that made this survive review is that the SAME figure has a panel which legitimately is in dollars. Panel 1 is the price composite and follows the numeraire, so it is right to say "Index in USD (=100)" over panels 2 and 3 showing a percentage. The fix could not be swapping one string everywhere, which is presumably why the original reached for `base` and got it wrong. Two variables now, named for what they are. `base` is the price composite's denomination. `hover_unit` is the short form the hovers append to a number, deliberately not called `measure` because that name was already taken further down for the chart title, which builds from UNIT_LABELS and wants the long form. Getting that collision wrong is how the axis title started reading correctly by accident during this fix rather than on purpose. Shares are also drawn in percentage POINTS now, so the axis runs 0 to 60 rather than 0.0 to 0.6 and agrees with the headline, which already prints 32.0% for the same week. The factor lives in build_figure rather than in unit_scale because the headline reads that function too and multiplies by 100 itself, so moving it there would print "3,200% of open interest". Four tests, including one that panel 1 KEEPS its currency, since relabelling it alongside the exposure panel would have been the opposite error. Verified in the running app, not only in tests: with Crowding on the axis reads "share of open-interest risk" with ticks at 0, 20, 40, and panel 1 still reads "Index in USD (=100)". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
One bug fix, and one proposed change that the measurement says not to make.
The bug: a share was labelled USD
With Crowding on, the exposure panel's y axis read
USDwhile plotting a fraction, and the hovers said "0.5 USD" for half a market. A share of open interest is a ratio of two quantities in the same unit and has no denomination at all.Why it survived review. The same figure has a panel that legitimately is in dollars: panel 1 is the price composite and follows the numeraire, so it is correct to say
Index in USD (=100)over panels 2 and 3 showing a percentage. The fix could not be swapping one string everywhere, which is presumably why the original reached forbaseand got it wrong.There are now two variables named for what they are.
baseis the price composite's denomination.hover_unitis the short form the hovers append to a number, deliberately not calledmeasure, because that name was already taken further down for the chart title, which builds fromUNIT_LABELSand wants the long form. That collision is worth naming: during this fix the axis title briefly started reading correctly by accident rather than on purpose, which is exactly the class of thing that looks fixed and is not.Shares also draw in percentage points now, so the axis runs 0 to 60 rather than 0.0 to 0.6 and agrees with the headline, which already prints 32.0% for the same week. The factor lives in
build_figurerather than inunit_scalebecause the headline reads that function too and multiplies by 100 itself, so moving it there would print "3,200% of open interest".Four tests, including one asserting that panel 1 keeps its currency, since relabelling it alongside the exposure panel would have been the opposite error.
Verified in the running app rather than only in tests: axis reads
share of open-interest riskwith ticks at 0, 20, 40, and panel 1 still readsIndex in USD (=100).The change not made: the Lookback default
I opened this intending to also change the Lookback default when Crowding is on. Copper reads 88th percentile against all history and 98th to 99th against 5 years, because its spec share of open interest genuinely shrank (median 12.4% in the first half of its history against 3.1% in the second). That looked like a defect in the default view of a just-shipped feature.
Measured per market across 45 markets, gap between the 5-year rank and the all-history rank:
The dollar view is more lookback-sensitive than the share view, not less, and the largest share gaps track their dollar counterparts closely (2-Year Note +59 against +61, Palladium +57/+57, Live Cattle -44/-48). So lookback sensitivity is a general property of ranking against long history rather than anything specific to the share basis, and copper is not representative.
No default change. Recorded here because the proposal was reasonable and the measurement is the only reason not to act on it.
Verification
461 tests pass, ruff clean on
src tests.🤖 Generated with Claude Code