Commit 6e1a66c
fix(futures): stop truncating a commodity code into a different contract (#111)
`normalize_futures_slug` split on the first separator and kept the leading
token, discarding the geography and the currency -- the two fields that
distinguish these instruments. A caller asking for one thing received another
contract's curve, with no error.
Measured against all 604 live catalog codes on 2026-09-13: 586 raised
(correct), 18 silently rewrote.
LNG_NW_EUROPE_EUR -> lng-jkm NW Europe LNG in EUR -> Japan/Korea Marker in USD
LNG_SOUTH_EUROPE_EUR -> lng-jkm
LNG_EU_AVERAGE_EUR -> lng-jkm
WTI_MIDLAND_USD -> wti Permian basis grade -> Cushing WTI
WTI_SPOT_CUSHING_USD -> wti spot -> futures curve
BRENT_SPOT_EUROPE_USD -> brent
Reachable from every method in resources/futures.py (lines 340-411). Same class
as the mcp-server substitution shipped as v3.3.0 today.
The suffix stripping exists for a real reason -- month and order markers on
contract codes ("CL.1", "CL1!", "BZ-2025-12") -- so it is kept, but the
discarded tail must now actually look like a month/order marker. Alphabetic
tails carrying geography and currency are no longer thrown away, and an
unrecognised input raises ValueError as it already did for the other 586.
After the fix all 604 live codes raise and none are rewritten; the four
contract-code forms still resolve.
Red before: 6 failed, 34 passed. Green after: 40 passed.
Wider unit suite unchanged at 109 pre-existing failures, verified identical on
clean origin/main.
Claude-Session: https://claude.ai/code/session_015ao5paex73xXvuM424Libo
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 31b8d80 commit 6e1a66c
2 files changed
Lines changed: 72 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
73 | 84 | | |
74 | 85 | | |
75 | 86 | | |
| |||
104 | 115 | | |
105 | 116 | | |
106 | 117 | | |
107 | | - | |
108 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
109 | 133 | | |
110 | 134 | | |
111 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
112 | 139 | | |
113 | 140 | | |
114 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
0 commit comments