trading/services/api_gateway/config.py
Viktor Barzin 6fec9963fb
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was canceled
feat(notify): Slack message for reconcile-booked closes (realized P&L)
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>
2026-06-10 20:44:35 +00:00

41 lines
1.4 KiB
Python

"""API Gateway configuration — extends shared BaseConfig with JWT, CORS, and WebAuthn settings."""
from shared.config import BaseConfig
class ApiGatewayConfig(BaseConfig):
"""Configuration for the API Gateway service.
All settings can be overridden via environment variables
prefixed with ``TRADING_``.
"""
# Dev mode — bypasses authentication (set TRADING_DEV_MODE=true)
dev_mode: bool = False
# JWT settings — TRADING_JWT_SECRET_KEY must be set in environment
jwt_secret_key: str = "dev-secret-not-for-production"
jwt_algorithm: str = "HS256"
access_token_expire_minutes: int = 15
refresh_token_expire_days: int = 7
# Alpaca brokerage credentials (for portfolio sync)
alpaca_api_key: str = ""
alpaca_secret_key: str = ""
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"]
# WebAuthn (passkey) relying party settings
rp_id: str = "localhost"
rp_name: str = "Trading Bot"
rp_origin: str = "http://localhost:5173"