feat(notify): Telegram alerts on trade open and close
CI/CD / build-and-push (push) Successful in 7s
CI/CD / build-and-push (push) Successful in 7s
New module bot/notify/telegram.py — httpx async, fire-and-forget via asyncio.create_task, swallows all errors so notifications never affect trade execution. Three alert types: 📈/📉 TRADE ABIERTO — direction, size, edge_net (in execute()) ✅/❌ GANADO/PERDIDO — approx PnL (in close_position()) 🔒 LEGACY CLOSE — recovered capital + reason (in close_legacy_position()) close_position() and close_legacy_position() gain an optional question="" param so the message shows the market name instead of market_id. bot/main.py updated to pass question= to close_legacy_position(). Credentials (TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID) read from env vars injected via bot-secrets k8s secret. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -347,7 +347,7 @@ async def run_legacy_scan(
|
||||
log.warning("PAPER MODE: auto-closing %d CLOSE_RECOMMENDED position(s)...", n_close)
|
||||
for p in enriched:
|
||||
if p["recommendation"] == "CLOSE_RECOMMENDED":
|
||||
recovered = await executor.close_legacy_position(p["market_id"], p["rec_reason"])
|
||||
recovered = await executor.close_legacy_position(p["market_id"], p["rec_reason"], question=p["question"])
|
||||
log.warning(
|
||||
" AUTO_CLOSED market=%s | $%.2f returned to cash | %s",
|
||||
p["market_id"], recovered, p["question"][:60],
|
||||
|
||||
Reference in New Issue
Block a user