Skip to content

Exposure: a share is not denominated in anything - #65

Merged
mspinola merged 1 commit into
mainfrom
claude/share-axis-and-lookback
Aug 24, 2026
Merged

Exposure: a share is not denominated in anything#65
mspinola merged 1 commit into
mainfrom
claude/share-axis-and-lookback

Conversation

@mspinola

Copy link
Copy Markdown
Owner

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

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 for base and got it wrong.

There are now two variables 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. 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_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 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 risk with ticks at 0, 20, 40, and panel 1 still reads Index 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:

median gap mean |gap| > 15 points
share of OI +5 +6.5 17 markets
dollars -1 +3.6 22 markets

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

…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>
@mspinola
mspinola merged commit c9b8c51 into main Aug 24, 2026
3 checks passed
@mspinola
mspinola deleted the claude/share-axis-and-lookback branch August 24, 2026 21:55
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