Fix chart pattern alert Markdown

This commit is contained in:
root
2026-08-20 21:03:30 -04:00
parent ac575b4ddc
commit 6c5e58f1c3
2 changed files with 13 additions and 1 deletions
+4 -1
View File
@@ -341,7 +341,10 @@ def format_signal_message(report: SignalReport) -> str:
f"📊 Regime: {regime_str} · Vol: {vol_str}", f"📊 Regime: {regime_str} · Vol: {vol_str}",
] ]
if report.action_recommendation: if report.action_recommendation:
lines.append(f"_{_escape_md(report.action_recommendation)}_") # Pattern identifiers use underscores, which legacy Telegram Markdown
# can misparse even when escaped inside this italicized action line.
action = report.action_recommendation.replace("_", " ")
lines.append(f"_{_escape_md(action)}_")
if report.trade_setup and sig not in (SignalStrength.NEUTRAL,): if report.trade_setup and sig not in (SignalStrength.NEUTRAL,):
ts = report.trade_setup ts = report.trade_setup
+9
View File
@@ -1685,6 +1685,15 @@ def _():
assert "Not financial advice" in msg assert "Not financial advice" in msg
@test("format_signal_message makes chart pattern actions Markdown-safe")
def _():
report = SignalReport(symbol="XAU/USD", display_name="XAU/USD", timestamp="now")
report.action_recommendation = "BUY — double_bottom pattern completion"
msg = format_signal_message(report)
assert "_BUY — double bottom pattern completion_" in msg
assert "double_bottom" not in msg
@test("format_signal_message renders stamped per-TF trail plan") @test("format_signal_message renders stamped per-TF trail plan")
def _(): def _():
def _setup(**extra): def _setup(**extra):