/news: normalize rounded-zero score so "-0.00" renders as "+0.00"
A balanced feed (XAU and USD means nearly cancelling) yields a tiny negative net that "+.2f" rendered as "-0.00" — seen live 2026-08-03. Regression test uses that day's actual per-currency means (300 tests). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017975c1TufZ3xRYAq8iWTCS
This commit is contained in:
+11
@@ -1898,6 +1898,17 @@ def _():
|
||||
assert "Bearish" in text
|
||||
|
||||
|
||||
@test("_news_text never renders negative zero")
|
||||
def _():
|
||||
# Balanced feed: XAU and USD means nearly cancel → net -0.0035,
|
||||
# which "+.2f" would render as "-0.00" without normalization.
|
||||
ctx = FundamentalContext(news_sentiment={"XAU": 0.0238, "USD": 0.0273})
|
||||
text = _news_text(ctx, NewsEngine(PlatformConfig().news))
|
||||
assert "-0.00" not in text
|
||||
assert "+0.00" in text
|
||||
assert "Neutral" in text
|
||||
|
||||
|
||||
@test("_news_text degrades on empty context")
|
||||
def _():
|
||||
text = _news_text(FundamentalContext(), NewsEngine(PlatformConfig().news))
|
||||
|
||||
Reference in New Issue
Block a user