Build and use a futures price series correctly — a continuous contract does not exist in the market, it is stitched, and the stitching method changes your answer. TRIGGER - futures, continuous contract, back-adjusted, Panama adjustment, ratio adjustment, roll, roll yield, contango, backwardation, front month, expiry, first notice day, open interest roll, CME, Globex, ES, CL, NG, VX, GC, ZN; joining futures bars to an equity calendar; "my futures backtest returns look wrong"; negative prices in a price series; norgatedata, databento continuous symbols, yfinance CL=F or ES=F. SKIP for Chinese futures and 夜盘 (china-trading-stack) and for crypto perpetuals, which have funding rather than rolls, and for dated crypto futures and basis trades (crypto-data-and-execution).
Ships in fin-futures-fx. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
There is no such thing as "the price of crude oil". There is a sequence of expiring contracts, and any long series is a construction you chose. Most of what follows was executed, not read.
This is a 2×2, not a preference. ✅ Measured over 180 rolls against true dollar P&L:
| Series | diff() | pct_change() |
|---|---|---|
| difference (Panama / back-adjusted) | ✅ exact — $0 error on true dollar P&L | 🚨 corr 0.97 in mild contango, −0.005 in backwardation |
| ratio (proportional) | 🚨 off by 36.9% of total P&L | ✅ exact — corr 1.000000, max err 0.000000 |
| unadjusted (spliced) | 🚨 wrong at every roll | 🚨 wrong at every roll |
difference +
diff()→ dollar P&L. ratio +pct_change()→ percentage returns. unadjusted → levels only (margin, tick value, limit moves). Never cross the pairs.
✅ Reproduced in scripts/continuous_contract.py: over 8 synthetic years the unadjusted series
implies +6.2%/yr against a true −12.9%/yr — 19 percentage points wrong, while ratio matches the
truth to +0.0 pp.
A difference-adjusted series adds the cumulative roll gap (P_new − P_old) to all older
history — that is what removes the jump at each roll and anchors the series at today's contract.
The direction of the drift is the term structure's: contango pushes history up, backwardation
pushes it down, and under sustained backwardation the downward shift eventually exceeds the price
level. This is the crude-oil case, and it is why back-adjusted continuous crude goes negative in the
deep past at most data shops.
🔑 Crossing time ≈ 1 / (annual roll yield) years — independent of the price level. At crude's
typical front-month backwardation the series crosses zero within a few years of history.
✅ Measured on the demo's backwardated market (scripts/continuous_contract.py, seed 5, 8 synthetic
years): 1,043 of 2,014 days are negative, and once the series is near zero pct_change()
detonates — it reports a 847% one-day "return" on a day the market moved 1.87%, and flips sign
outright. np.log() is NaN on every negative day. The mirror-image contango market in the same demo
never goes negative; it climbs from 165 to 339.
⚠️ An earlier version of this skill had the sign backwards — it subtracted the gap and therefore
showed contango going negative. The convention is: back-adjustment adds the gap, and backwardation
is what drives it below zero. diff() on the corrected series equals the true dollar P&L exactly
(§1), which is the check that pins the sign.
A negative price is not a bug in the data. It is the correct output of the construction. It means
pct_change(), log(), and every volatility estimate built on them are meaningless on that series.
✅ From pysystemtrade's source, _roll_in_panama:
adjusted_prices_values = [adj_price + roll_differential for adj_price in adjusted_prices_values]
Every prior value. And its incremental updater update_with_multiple_prices_no_roll returns an
empty series if a roll occurred — the reference implementation refuses to update across a roll
and forces a full rebuild. That is the honest design.
How far history moves per year of new data (✅ arithmetic from live roll yields):
| Contract | History moves |
|---|---|
| ES | ≈ +2.0% of level per year |
| NG | ≈ +25%/yr |
| VX front | ≈ +60%/yr |
| CL at 8% backwardation | ≈ −8%/yr |
Re-pull a back-adjusted series a year later and every historical level has moved by that much.
This is the same reproducibility failure as forward-adjusted equities
(../../../fin-core/skills/research-integrity-guards/references/adjustment-conventions.md) — snapshot
and hash what you used.
✅ Verified against Yahoo's own API: CL=F returns shortName = "Crude Oil Oct 26" and ES=F
returns "E-Mini S&P 500 Sep 26". They are an unadjusted front-month splice.
CL=F contains close = −37.63 on 2020-04-20 and +10.01 the next day — a raw roll discontinuity
of $47.64 sitting inside what people treat as a price series.
🚨 And you cannot rebuild it correctly, because Yahoo deletes expired contracts. CLV26.NYM,
ESZ26.CME, 6EZ26.CME all return data; CLZ20.NYM returns "Not Found… symbol may be
delisted". Live contracts only — so there is no path from yfinance to a correct historical
continuous series.
✅ Live, 2026-09-04: ES Sep26 7733.75 → Dec26 7801.25 = +0.873%/quarter ≈ +3.54%/yr contango. CL Oct26 90.84 → Nov26 87.97 = −3.16%/month ≈ −32%/yr backwardation, and CLV26 → CLZ27 is 90.84 → 70.89, −22% across 15 months.
🚨 A spot-price backtest of a long crude strategy misses roughly +30%/yr of roll return. "The index returned X" and "a futures position returned X" are different numbers, and for commodities the gap is usually larger than the alpha being claimed.
| Rolling ETF | vs the underlying | Gap |
|---|---|---|
| UNG −23.51%/yr | NG=F −0.26%/yr | −23.25 pp/yr |
| VIXY −47.74%/yr | ^VIX −1.84%/yr | −45.9 pp/yr |
| GLD −0.50 pp/yr vs GC=F | — | ✅ the control — gold is near-zero carry, so the method is not manufacturing the gap |
A strategy backtested on ^VIX and traded through VIXY loses ~46 percentage points a year to
something that never appears in the price series. The GLD row is what makes the other two
credible: the same method finds almost no gap where there should be none.
Calendar (N business days before expiry) · open-interest crossover · volume crossover · first notice
day. ✅ scripts/roll_schedule.py shows a Sharpe spread of 0.71 across four rules on one dataset
(volume +1.43 vs first_notice +0.72).
🚨 Each rule is a trial. Picking the one that backtests best is p-hacking, and first notice day
is a hard constraint for physically-settled contracts, not a preference — miss it and you are
liable for delivery. Record the rule in
../../../fin-core/skills/backtest-validation/scripts/trial_ledger.py.
✅ All executed against exchange_calendars 4.13.2:
2026-01-02 has
open = 2026-01-01 23:00 UTC, close = 2026-01-02 23:00 UTC — 24 hours spanning two dates.
Group intraday futures bars by .date() and every evening bar is mis-assigned.exchange_calendars does not model the CME daily maintenance halt — break_start/break_end
are NaT on every CMES session checked.Also see the four verified exchange_calendars defects in
../../../fin-asia/skills/asia-pacific-markets/SKILL.md §3 — including that its default date bounds
move with Timestamp.now().
| Source | Gives you | The catch |
|---|---|---|
| Databento | Individual contracts and roll rules (.c. calendar, .n. open interest, .v. volume, rank .0/.1/…) | ✅ prices are the raw prices of whichever instrument is current — you do the stitching. That is the right division of labour |
| Norgate | Pre-built continuous series | 🚨 The Python API cannot see or set the adjustment method. price_timeseries() exposes only stock_price_adjustment_setting (an equity enum) and padding_setting. The construction is configured in the desktop app (a local service on localhost:38889) — outside your code, your requirements file and your git history. |
| yfinance | CL=F, ES=F | 🚨 unadjusted front-month splice; expired contracts deleted (§4) |
| openbb futures | — | 🚨 ✅ source-verified: it is literally yfinance under the hood. Same splice, plus AGPL-3.0 |
🔴 quandl / nasdaq-data-link | continuous series | repo archived; last release 2022-08-29 |
IB / ib_async | Individual contracts, live | Contract definitions and pacing limits — see ../../../fin-core/skills/broker-execution-apis/references/interactive-brokers.md |
🔑 Prefer a source that gives you individual contracts. A pre-stitched series whose method you cannot see or record is not reproducible research, however good the data is.
The intuitive shortcut tick_value = multiplier x tick_size is wrong often enough to matter.
✅ Measured across 219 futures: 47 distinct multipliers, 28 tick sizes, 13 currencies.
price_magnifier of 100 — the quoted number is not the price.A P&L computed in "points" is meaningless across contracts. Look the spec up per contract; do not derive it.
⚠️ cmegroup.com returns HTTP 403 to all programmatic access, so the specs cannot be scraped —
get them from your broker's contract details (ib_async reqContractDetails) or your data vendor.
Margin is not a cost — it is collateral, and initial ≠ maintenance. Settlement is physical or cash, and first notice day binds before last trading day for physically-settled contracts. Limit moves halt trading. None of this is in a price series.
scripts/continuous_contract.py — all three stitchings plus true_roll_return() ground truth;
the demo shows the difference series going negative and unadjusted being 19 pp wrong.scripts/roll_schedule.py — four roll rules, and the Sharpe spread they produce on one dataset.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
2 skills in this plugin
/fin-futures-fx:futures-continuous-contractsfrom fin-futures-fx
npx claudepluginhub howard-lynn-ye/fin-rsi --plugin fin-futures-fx