Split a Contract Dataset in Time Before Tuning
If you tune a strategy on the same data you later use to judge it, your judgment is already compromised. The general argument for holdout discipline lives in our post on avoiding overfitting in strategy backtests. This post is narrower and more practical: how to produce a dated split manifest for a contract dataset, and how to handle the awkward fact that a single market exists across a span of time, not at a single row.
Why random row splits leak
A naive split shuffles rows and assigns, say, 70 percent to training and 30 percent to testing. For independent, identically distributed rows that is fine. Prediction-market data is neither. One Kalshi market produces many rows over its life: order book snapshots, trade prints, candlesticks. Those rows are all tied to the same underlying event and the same eventual result.
A Kalshi market moves through a defined lifecycle. After a market closes and the outcome is known, it is determined with a result of yes, no, or scalar, a settlement timer runs, and the market ends up finalized. Every row from that market shares that single outcome. If you shuffle rows, pre-settlement ticks from one contract land in your training set while other ticks from the same contract land in your test set. The label is the same for both. Your model can memorize the event instead of learning a generalizable signal, and your test score reports that memorization as skill.
The fix is to split on time, and to keep each contract whole within a single interval.
Three intervals, defined by date
Build three non-overlapping, contiguous date ranges, ordered forward in time:
- Development: where you iterate, feature-engineer, and fit. Touch this freely.
- Validation: where you compare candidate configurations and select hyperparameters. Touch this rarely and deliberately.
- Evaluation: untouched until the very end. One look. If you peek and then change the strategy, it is no longer an evaluation set.
Forward ordering matters because a strategy you intend to run later will only ever see the past. Training on August to predict July is a leak you would never get in production. Keep development earliest, evaluation latest.
Which timestamp defines membership
A contract is not a point in time, so you have to pick the field that assigns it to an interval. Kalshi market objects expose several time fields, including open_time, close_time, and, once settled, settlement_ts, alongside settlement_timer_seconds. Candidate anchors and their trade-offs:
- Settlement time: the outcome becomes known here. Anchoring on settlement keeps all of a contract's rows in the interval where its label was resolved, which is the cleanest defense against label leakage.
- Open or creation time: useful if your features are about early-life behavior, but a long-dated market opened in the development window can still be resolving inside your evaluation window.
- Close time: a reasonable middle ground for short-lived daily markets where open, close, and settlement are near each other.
There is no universally correct anchor. Pick one, write it down in the manifest, and apply it consistently. The point is that the choice is explicit and reproducible, not implicit in whatever your query happened to return.
Contracts that span a boundary
Some contracts open in one interval and settle in another. You must decide their fate explicitly rather than let row-level filtering silently scatter them. Three defensible policies:
- Assign by anchor: the contract belongs entirely to the interval containing its chosen anchor timestamp. Simple and keeps each contract whole.
- Embargo and drop: discard contracts whose life straddles a boundary, trading some data volume for a clean separation. Useful when boundary contamination worries you more than sample size.
- Assign and truncate: place the contract by anchor, but drop any of its rows that fall in a neighboring interval, so no row ever appears outside its contract's assigned set.
Whichever you choose, record it. A split manifest that cannot explain where a boundary-spanning contract went is not reproducible.
A manifest is data, not a vibe
Write the split to a file you can version and diff. Store dates as explicit UTC date ranges, record the anchor field and the boundary policy, and list the contract tickers in each bucket. An exact ticker matters: discovery results shift over time, so capturing the resolved ticker rather than a query is what makes the split reproducible later.
# Illustrative manifest only. Dates, anchor, and policy are chosen,
# not calibrated, measured, or recommended.
{
"anchor_field": "settlement_ts",
"boundary_policy": "assign_by_anchor",
"timezone": "UTC",
"intervals": {
"development": {"start": "2026-01-01", "end": "2026-06-30"},
"validation": {"start": "2026-07-01", "end": "2026-08-31"},
"evaluation": {"start": "2026-09-01", "end": "2026-10-31"}
},
"buckets": {
"development": ["KX-EXAMPLE-26JAN01-A"],
"validation": ["KX-EXAMPLE-26JUL15-B"],
"evaluation": ["KX-EXAMPLE-26SEP20-C"]
}
}Treat the tickers above as placeholders. Replace them with the exact tickers your own query resolves, and keep that resolved list, not the query, as the record of what you tested.
Use Decimal for the prices you carry along
Binary floats do not represent most decimal fractions exactly. The Python standard library makes this concrete: in decimal floating point, 0.1 + 0.1 + 0.1 - 0.3 is exactly zero, while in binary floating point it is not. For money and for equality checks on prices, use decimal.Decimal, which supports correctly rounded decimal arithmetic. Construct Decimals from strings, not from floats, so you preserve the digits you actually wrote. This is also why Banger's tick prices are Decimal rather than float.
If you fit a calibrator, keep its data disjoint too
The same leakage logic applies inside modeling. If you map raw model scores to probabilities with a calibrator, scikit-learn is explicit that the samples used to train the calibrator should not be used to train the underlying classifier. When you pass a prefit estimator, the docs note you must take care manually that the fitting and calibration data are disjoint. A time split gives you a natural place to do this: fit on development, calibrate on validation, and leave evaluation untouched.
Where Banger fits
Banger is a paper-only research beta. Hosted historical backtesting currently supports Kalshi binary markets, which is exactly the kind of dataset this manifest organizes. The workflow is unchanged by the tool: build the manifest, iterate on development, select on validation, and run the untouched evaluation interval once. A paper result is evidence under a specific data, fill, fee, and valuation model. It is not proof of real venue execution, and a clean time split does not change that. It only makes the evidence honest about what it measured.
Primary reference for the market fields used here: the Kalshi market lifecycle documentation at docs.kalshi.com. If you want to iterate on strategies against this kind of split in paper mode, you can explore it at bangertrades.com/sign-up. No fills, returns, or outcomes are promised.
Sources
- Market Lifecycle - Kalshi API Documentation
- Get Market - Kalshi API Documentation
- decimal — Decimal fixed-point and floating-point arithmetic — Python documentation
- CalibratedClassifierCV — scikit-learn documentation
- 1.16. Probability calibration — scikit-learn documentation
- bangertrades 0.1.7 · PyPI
- Banger - Polymarket & Kalshi Paper Strategies