feat(notify): Slack message for reconcile-booked closes (realized P&L)
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was canceled

Entries, deferrals and rejections posted to #trading-bot, but exits booked by the reconcile loop (bracket stop/take-profit legs that fill at Alpaca) were silent — the two Jun 9 stop-outs produced no message. Viktor asked for a Slack message on each position execution.

- move SlackNotifier to shared/ (now used by trade-executor AND api-gateway)

- add notify_close (ticker/qty/price/realized P&L/reason, win-loss emoji)

- reconcile loop notifies on each booked close, fail-soft; api-gateway config gains slack fields (channel defaults to trading-bot since the env carries only the bot token; chat:write.public covers posting)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Viktor Barzin 2026-06-10 20:44:35 +00:00
parent c6ad39310c
commit 6fec9963fb
6 changed files with 516 additions and 25 deletions

View file

@ -25,6 +25,13 @@ class ApiGatewayConfig(BaseConfig):
paper_trading: bool = True
snapshot_interval_seconds: int = 60
# Slack — close notifications from the trade-reconcile loop. The channel
# defaults here (rather than "") because the deployment env carries only
# the bot token; chat:write.public lets the bot post without an invite.
slack_webhook_url: str = ""
slack_bot_token: str = ""
slack_channel: str = "trading-bot"
# CORS settings
cors_origins: list[str] = ["http://localhost:5173"]