feat: per-ticker fear-and-greed reading on replay rows - #112
Merged
Merged
Conversation
fear_greed(): the equal-weight 0-100 composite of RSI 14, the MACD (12, 26, 9) histogram's mid-rank percentile within the trailing 250 bars and Bollinger %B (20, 2) that the TradingView community indicators of that name share, with Wilder's RSI implemented in _rsi. Every replay row carries the composite and its components at the scan day and the composite at the pattern's last low; the outcome-by-feature table buckets them (extreme fear to extreme greed, RSI, %B against the bands, MACD percentile). Recorded to be tested; no rule uses it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Wiki 03 gains "Per-ticker fear and greed, tested" (runs 34267945406 to 34268343900): the greedier the stock at its breakout the lower the mean R, bases formed in fear paid about twice bases formed in greed, the stretch components (RSI, Bollinger %B) carry the effect and momentum does not, and a breakout closing above its upper Bollinger band ran +0.04 R on 453 signals with the upper-half bucket ahead in 10 of 11 years. The gate stays a hypothesis under the protocol. The changelog entry states the outcome. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A per-ticker fear-and-greed reading, recorded as a replay feature under the protocol of docs/wiki/03 and tested over the eleven yearly point-in-time runs from this branch. No rule changes.
fear_greed: the equal-weight 0-100 composite of the three price-based oscillators the TradingView community indicators of that name share: RSI 14 (Wilder's smoothing,_rsi), the MACD (12, 26, 9) histogram as its mid-rank percentile within the trailing 250 bars, and Bollinger %B over 20 bars and 2 standard deviations, clipped to 0-100 in the average.fg_score,fg_rsi,fg_macd_pct,fg_bb_pctb) and the composite at the pattern's last low (fg_base).Results (runs 34267945406 to 34268343900, tuned, 2016 to 2026):
The greedier the stock at its breakout, the lower the mean R; bases formed in fear paid about twice what bases formed in greed did. The stretch components carry it: RSI 30-50 at the breakout +0.55 R against +0.12 above 70; Bollinger %B lower half +0.53, upper half +0.26, a close above the upper band +0.04 R on 453 signals, the upper half ahead in 10 of 11 years. Momentum (MACD percentile) does not: +0.18 to +0.26 across buckets. Leaving out above-band breakouts would keep 1179 signals at +0.30 R against 1632 at +0.22, at a cost of 16 R of the ten-year 367. Still a hypothesis under the protocol: the gate has to be replayed as a rule on its own for its drawdown and per-pattern effect.
Verified:
ruffclean, 137 tests pass (the composite on accelerating, collapsing, flat and too-short series, Wilder's RSI by hand, %B outside the bands, the cup fixture's readings recomputed independently with the base more fearful than the breakout, rows and buckets rendered); a 30-ticker real-data run renders the buckets.Related Issues
Related: #99 and #101 (stock-level and market-level context), #108 (drawdowns), #96 (protocol)
Checklist
scan.py(no thresholds changed)python -m pytest -q)docs/wiki/CHANGELOG.mdupdated🤖 Generated with Claude Code