Expand description
§Engine: from measurements to the SD number
This is the file to open if you want to know what the number on the chart means. Everything upstream measures; this file decides.
§What the backtests taught us (and why the engine looks like this)
sd_backtest study and sd_backtest grid asked, over 125 symbols and
25 years, trained before 2014 and graded after 2019:
- Can squeeze + momentum features call direction? Barely. Every
feature, alone or learned in combination, lands within a point or two
of a coin flip once the market’s upward drift is removed. Classic SD’s
+/-calls hit 50.5%, while “always up” hit 54-61%. - Can they call the size of the move? Yes. Predicted versus realized move size has a rank correlation of about 0.22 out of sample, and the effect is monotone in squeeze tier, stored energy and squeeze duration in both eras.
So SD v2 is built around the thing it can actually do. The SD number keeps its familiar shape (0 = bearish, 0.5 = nothing, 1 = bullish), but:
- how far SD sits from 0.5 is set by the expected movement (bigger expected move → further from 0.5), and
- which side of 0.5 it sits on is the best direction call the
walk-forward search (
sd_direction, chapter 8) could find: P(up) from drift plus the market’s weather. That is right about 58% of the time at 21 bars, the same as “always up”, because nothing beat drift. The momentum lean is still reported, but it no longer picks the side.
SD = 0.5 + 0.5 · side · strength · intensity
side ∈ {-1, +1} sign of P(up) − 0.5
strength ∈ [ 0, 1] time-decay strength of the squeeze
intensity ∈ [ 0, 1] where this bar's expected move ranksStructs§
- Sd2Model
- The frozen, fitted pieces SD v2 needs at run time. Produced by
sd_backtest fitand embedded in the binary fromsd2_model.json. - Sd2Reading
- One SD v2 reading.
Functions§
- apply_
weather - Re-decide a reading’s side with today’s market weather (SPY row from
crate::direction::MarketWeather; the first five columns). - reading_
at - sd2_
latest - Compute SD v2 for the last bar only.
- sd2_
series - Compute SD v2 for every bar of
bars. - sd2_
series_ market - SD v2 for every bar, with the market’s weather deciding the side.
- side_sd
- The SD number: side × how much to trust it now × how big the move will be.
- time_
strength - How much to trust the momentum lean at this point in the squeeze’s life.