Telegram /news command: net XAU/USD news sentiment score on demand
Owner-locked /news replies with the existing get_pair_sentiment() net score (XAU mean - USD mean, -1..+1) and its label; a caveat line marks the no-headlines case so a feed outage can't read as neutral. Fetch runs in the shared executor with a placeholder-then-edit reply. Display-only: news still never gates signals. Registered in handler block, command menu, help text, docstring, and user guide; 3 new builder tests (299). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017975c1TufZ3xRYAq8iWTCS
This commit is contained in:
+26
-1
@@ -1591,7 +1591,7 @@ print("\n═══ Module 7: telegram_bot.py ═══")
|
||||
|
||||
from telegram_bot import (
|
||||
_escape_md, _signal_label, _mtf_line, _indicator_summary,
|
||||
format_signal_message, _format_scan_summary,
|
||||
format_signal_message, _format_scan_summary, _news_text,
|
||||
_seconds_until_boundary, _check_level_breach,
|
||||
scan_keyboard, SCAN_BUTTONS, SCAN_LOOKUP,
|
||||
_update_level_cache, _last_prices, _level_cache, _level_cache_ts,
|
||||
@@ -1881,6 +1881,31 @@ def _():
|
||||
assert ws_to_pair["XAU/USD"] == XAUUSD
|
||||
|
||||
|
||||
@test("_news_text bullish score")
|
||||
def _():
|
||||
ctx = FundamentalContext(news_sentiment={"XAU": 0.5, "USD": -0.1})
|
||||
text = _news_text(ctx, NewsEngine(PlatformConfig().news))
|
||||
assert "+0.60" in text
|
||||
assert "Bullish" in text
|
||||
assert "no scored headlines" not in text
|
||||
|
||||
|
||||
@test("_news_text bearish score")
|
||||
def _():
|
||||
ctx = FundamentalContext(news_sentiment={"XAU": -0.4, "USD": 0.1})
|
||||
text = _news_text(ctx, NewsEngine(PlatformConfig().news))
|
||||
assert "-0.50" in text
|
||||
assert "Bearish" in text
|
||||
|
||||
|
||||
@test("_news_text degrades on empty context")
|
||||
def _():
|
||||
text = _news_text(FundamentalContext(), NewsEngine(PlatformConfig().news))
|
||||
assert "+0.00" in text
|
||||
assert "Neutral" in text
|
||||
assert "no scored headlines" in text
|
||||
|
||||
|
||||
# ══════════════════════════════════════════════════════════════════════
|
||||
# MODULE 8: Integration / Cross-module tests
|
||||
# ══════════════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user