Whole file
SilentFleetKK/ai-market-pulse
The author described this change as “fix: use is-not-None checks in scoring so zero-valued indicators aren't skipped”. It counts as a record because the check below fails on the code as it stood at 7f773c9c1 and passes on 9add4d681, with nothing else changed between the two runs.
Fix saved2026-07-09
Sharing licenceMIT · LICENSE
Change size+4 −4
What the code was meant to do, written into the code itself as a save note
fix: use is-not-None checks in scoring so zero-valued indicators aren't skipped
The change
| 20 | 20 | atr_pct = _num(metrics.get("atr_pct")) | |
| 21 | 21 | volume_ratio = _num(metrics.get("volume_ratio_20d")) | |
| 22 | 22 | ||
| 23 | - | if last and sma20: | |
| 23 | + | if last is not None and sma20 is not None: | |
| 24 | 24 | if last > sma20: | |
| 25 | 25 | score += 8 | |
| 26 | 26 | reasons.append("Price is above the 20-day average.") | |
| 27 | 27 | else: | |
| 28 | 28 | score -= 6 | |
| 29 | 29 | reasons.append("Price is below the 20-day average.") | |
| 30 | - | if last and sma50: | |
| 30 | + | if last is not None and sma50 is not None: | |
| 31 | 31 | if last > sma50: | |
| 32 | 32 | score += 8 | |
| 33 | 33 | reasons.append("Price is above the 50-day average.") | |
| 34 | 34 | else: | |
| 35 | 35 | score -= 7 | |
| 36 | 36 | reasons.append("Price is below the 50-day average.") | |
| 37 | - | if last and sma200: | |
| 37 | + | if last is not None and sma200 is not None: | |
| 38 | 38 | if last > sma200: | |
| 39 | 39 | score += 5 | |
| 40 | 40 | reasons.append("Long-term trend remains above the 200-day average.") | |
| 41 | 41 | else: | |
| 42 | 42 | score -= 8 | |
| 43 | 43 | reasons.append("Long-term trend is below the 200-day average.") | |
| 44 | - | if sma20 and sma50: | |
| 44 | + | if sma20 is not None and sma50 is not None: | |
| 45 | 45 | if sma20 > sma50: | |
| 46 | 46 | score += 5 | |
| 47 | 47 | reasons.append("Short trend is stronger than medium trend.") |
The check that tells the two apart
fail→pass·tests/test_scoring.py::test_zero_sma200_is_treated_as_a_valid_value_not_missing
Check file tests/test_scoring.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it7f773c9c111e573ba4aa7643d2ebf6a61cdaaed1
Broken version dated2026-07-09
Moduleai_market_pulse.scoring
Units changedscore_asset
Fingerprintdc3896d26eda489a
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.