Event-Driven Market Probability Engine
A reproducible research pipeline that estimates next-day market move probabilities, validates that estimate under conditions that do not flatter it, and reports the honest conclusion: the model has no tradeable edge.
Summary
A layered PostgreSQL warehouse and a walk-forward-validated probability model, built to answer one question honestly: is there a tradeable edge in next-day ETF moves? The measured answer is no, and reporting that is the point. Most of the engineering exists to make the verdict trustworthy rather than to make it flattering.
The result
Five expanding walk-forward folds with a 60-day embargo, then a backtest with transaction costs, benchmarked against simply holding the market. No strategy beats the benchmark.
The finding worth reporting
A real signal that still loses money
Next-day direction has no signal: ROC-AUC ~0.51, straddling chance, exactly as market efficiency predicts for price-only features on liquid ETFs. Large moves are genuinely predictable at ~0.57, in 14 of 15 instruments.
And it still does not convert. The label is unsigned: it knows a big move is coming but not which way, so stepping aside forgoes as much upside as downside. Being right about volatility is not the same as having an edge, and only a backtest could have shown that.
Calibration: ranking is not probability
The model sorts days correctly but exaggerates the gap: it claims its most turbulent tenth is 5.1x riskier than its calmest, where only 2.6x occurred. A threshold rule needs the ranking to be right; a sizing rule needs the value to be right. This model has the first and not the second.
Bugs that passed every test
Three of these four went straight through the test suite. In a data pipeline a wrong number looks exactly like a right one, so each failure below is paired with the guard that now fails the build if it comes back.
One ticker's prices, fifteen times
yf.download() stages results in module-level state and resets it on entry, so
concurrent calls overwrite each other's accumulator and every task can receive the same
wrong frame. The warehouse ended up holding one ticker's prices under all fifteen symbols.
Nothing failed. A duplicated series is internally consistent, so every per-asset assertion held, row counts were right and no nulls appeared. The only symptom was the model getting better, which is the most dangerous symptom there is.
It was caught by noticing that SHY, a one to three year Treasury fund, reported the same volatility as XLE, an energy fund, to five decimal places.
Guard: a cross-asset fingerprint in sql/10_validations.sql hashes each
symbol's whole series and rejects any two that match. Every other check in the project
validates within one asset; this is the only one that looks across them.
A day that hadn't ended yet
Yahoo serves the session in progress as an ordinary bar, with a partial close and partial volume. Two rebuilds an hour apart disagreed, and one label per asset was measured against a close that had not happened.
Guard: only settled sessions are ingested. The rule keys on the calendar date rather than on whether 16:00 has passed, because a time-of-day rule would make a 15:00 run and a 17:00 run disagree, which is the non-determinism being fixed.
A ticker that quietly disappeared
Each fetch is wrapped so one bad symbol cannot abort the batch, which makes a failed download survivable and therefore silent. The asset still arrives with zero price rows, and zero rows satisfy every row-level check vacuously. Fifteen instruments could become fourteen with every metric still reporting cleanly.
Guard: every symbol declared in config/assets.csv must have at least one
price row.
Drawdown that started too late
Drawdown compares equity to the highest equity so far. The running peak started at day one's close instead of the starting capital, so day one's own loss was never counted. Start at 100, fall 10%, recover 2%: the peak becomes 90 and the reported drawdown is 0% rather than 10%.
Each of the five walk-forward folds is backtested separately, so each had its own day one. The error only ever ran one way, making strategies look safer than they were.
Guard: the running peak is floored at the starting capital, pinned by a case in
tests/test_backtest.py with a hand-computed answer.
How it is built
raw as ingested, staging cleaned and re-keyed onto surrogate ids, analytics for features, labels, predictions and backtest results. A validation gate between raw and staging fails the build on bad input before it can reach a feature.