Fix 3 bugs (swing NaN, ROC div-by-zero, currency matching) and add 77 new tests

Bug fixes:
- Swing point detection: false positives when all neighbors are NaN (all([]) == True)
- ROC indicator: division by zero when historical close price is zero
- News currency extraction: substring matching ("usd" in "usda") replaced with word-boundary regex
- ADX DX calculation: use epsilon instead of NaN to avoid cascade
- Signal aggregator: refactor ternary append, add pip_value<=0 guard

New tests (77) cover: swing point edge cases, ROC/ADX/RSI/MACD/BB boundaries,
regime classification, composite scoring, quality grade thresholds, EUR filter
pipeline, trade setup edge cases, MTF agreement, weekend filter, and integration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
harwinder
2026-05-18 17:25:52 -04:00
parent 08d7c9ade1
commit e6e09c587e
4 changed files with 1002 additions and 24 deletions
+3 -2
View File
@@ -497,11 +497,12 @@ class NewsEngine:
found = []
for currency, keywords in self.CURRENCY_KEYWORDS.items():
if currency.lower() in headline_lower:
if re.search(r'\b' + re.escape(currency.lower()) + r'\b', headline_lower):
found.append(currency)
continue
for kw in keywords:
if kw in headline_lower:
kw_stripped = kw.strip()
if kw_stripped and re.search(r'\b' + re.escape(kw_stripped) + r'\b', headline_lower):
found.append(currency)
break