When to Use
Invoke this skill before loading historical OHLCV data into a backtest when corporate actions, vendor adjustment factors, or mixed price-series conventions may affect signals, returns, liquidity, or universe comparisons.
Declare the intended SeriesAdjustmentMode explicitly:
UNADJUSTED: historical prices retain split and cash-dividend ex-date moves; model splits and dividends separately.SPLIT_ADJUSTED: split history is normalized, while cash dividends remain explicit events unless the vendor contract says otherwise.TOTAL_RETURN_ADJUSTED: split and dividend effects are embedded for return analysis; validate the factor methodology and point-in-time availability.UNKNOWN: audit continuity and actions, but do not infer provenance merely because no discontinuity is found.
When NOT to Use
- Do not infer vendor adjustment provenance from a smooth series alone; continuity is not evidence of correct adjustment factors.
- Do not treat every ex-dividend price drop as look-ahead bias. A raw price series can legitimately drop by the cash dividend amount; the portfolio must separately receive the dividend.
- Do not use a price-only audit to satisfy point-in-time or vendor-revision requirements. Those require as-of corporate-action snapshots and adjustment-factor history.
- Do not apply split adjustment to data already adjusted by the vendor without recording the factor source and convention.
- Do not use adjusted close as a substitute for executable OHLC, intraday prices, quotes, or volume without validating the vendor's field definitions.
Prerequisites
- Historical dates, closes, volumes, and preferably actual next-session opens.
- Corporate-action records with ISO dates, action type, and ratio convention:
SPLITratio is post-split shares per pre-split share;DIVIDENDratio is cash per share. - A declared
SeriesAdjustmentModeand documented vendor/factor provenance. - A point-in-time policy for when corporate actions and adjustment factors become available to the backtest.
- A tolerance policy for price, volume, and notional reconciliation.
Workflow
- Declare semantics: Select
UNADJUSTED,SPLIT_ADJUSTED,TOTAL_RETURN_ADJUSTED, orUNKNOWNbefore auditing. Do not let the auditor guess the series mode. - Validate inputs: Confirm strictly increasing ISO dates, aligned lengths, finite positive prices, non-negative volumes, and valid corporate-action records.
- Scan the correct boundary: Provide
opensso discontinuities are measured from prior close to next open. If opens are unavailable, the auditor falls back to the next close, logs a warning, and recordsboundary_source="PRIOR_CLOSE_FALLBACK"on the report. Treat any audit carrying that value as provisional. - Match actions: The auditor builds one composite expected price ratio per ex-date — split factors (
1 / ratio) multiplied together and multiplied by the cash factor(prev_close - total_dividend) / prev_close— and compares it with the observed ratio usingprice_match_tolerance_pct(default 5%). Volume scaling is compared separately against the split ratio usingvolume_ratio_tolerance_pct(default 25%). Keep these two tolerances distinct: the ex-date price factor is mechanical, traded volume is not. - Interpret the report:
is_consistentmeans no detected discontinuity, not that adjustment provenance is proven.unexplained_discontinuitiesidentifies jumps not explained by the declared mode and known actions.expected_price_ratioon each event exposes the composite factor the jump was tested against;Nonemeans no expectation could be formed.detected_adjustment_typereports only what the jumps prove: a matched split jump givesUNADJUSTED, a matched cash-dividend jump only givesNOT_TOTAL_RETURN_ADJUSTED(raw and split-adjusted remain indistinguishable), and no matched evidence givesUNKNOWN.has_look_ahead_bias_riskis raised for dividend discontinuities that conflict withTOTAL_RETURN_ADJUSTED; point-in-time availability still requires an external audit.
- Transform only with provenance: Use
apply_split_adjustmentfor a documented split ratio and index convention. It adjusts prices before the split by dividing by the ratio and volumes by multiplying by the ratio, without lossy rounding. - Validate the universe: Run
validate_universe_consistencyand reject mixed declared series modes or incompatible detected types before calculating cross-asset signals. - Persist evidence: Store raw data identifiers, action records, series mode, factor source/version, as-of timestamp, tolerance settings, audit report, and transformation parameters.
Common Pitfalls
- Close-to-close substitution: Using a close value while labeling it
next_opencan miss overnight gaps and misclassify actions. - Dividend semantic collapse: Cash dividends, split-adjusted prices, and total-return prices answer different research questions.
- Ratio convention mismatch: A
2.0split means two post-split shares per old share; a0.5reverse split doubles historical prices under backward adjustment. - Lossy rounding: Rounding every adjusted bar to four decimals can accumulate tracking error in long histories and volume-weighted calculations.
- Multiple same-day actions: A split and dividend can share an ex-date. Testing the jump against either action alone is wrong — the factors multiply, so a 2-for-1 split plus a $10 dividend on a $100 close expects
0.5 * 0.9 = 0.45, not0.5. Same-date cash dividends are summed before the cash factor is formed. - Tolerance conflation: A loose volume tolerance applied to the price ratio silently explains away real data errors. At a 25% price tolerance a 42% overnight crash "matches" a 2-for-1 split; keep the price tolerance tight and reconcile against vendor factors rather than widening it.
- False provenance: No detected jump does not prove a series is adjusted, correctly adjusted, or point-in-time safe.
Verification
Run the focused tests:
python -m unittest discover -s skills/adjusted-vs-unadjusted-price-series-pitfalls/scriptsThe tests cover split and dividend semantics, close/open detection and boundary provenance, composite same-ex-date factors, price-match tolerance behavior, total-return risk, no-jump ambiguity, provenance inference limits, forward and reverse splits, precision, ISO date canonicalization, invalid inputs, and universe-mode consistency. Production sign-off additionally requires replaying vendor factors and comparing raw versus transformed price, volume, dividend, and total-return ledgers.