trading/services/trade_executor/config.py
Viktor Barzin 065b634b99
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
feat(trade-executor): Slack bot-token transport + semver image tags
Two changes that ship together so a single CI run lands both:

1) SlackNotifier — support bot-token + channel transport
   - Previous version only supported a pinned webhook URL.
   - New mode uses chat.postMessage with bot_token + channel.
   - Channel can be changed via env var without rotating webhooks.
   - bot-token transport wins when both are set.
   - Fail-soft: ok=false (e.g. channel_not_found if the user
     hasn't created #trading-bot yet) is logged + skipped, not
     raised.
   - 5 new tests (10 total): bot-token wins, channel_not_found
     swallowed, headers/payload shape verified.

2) Image tags — switch from :${CI_PIPELINE_NUMBER} → :0.1.${N}
   - 3-part semver so Keel patch policy (cluster-wide default
     in inject-keel-annotations) is bounded to patch bumps
     within 0.1.x. Prior 1-part tags (:53) were technically
     parseable as major-only, which Keel patch wouldn't bump
     but could still resolve oddly under digest tracking.
   - Memory id=1935 documents Keel patch ≠ bulletproof for
     non-semver; semver tags are the safer mode.
   - update-deployment + verify-deploy steps updated to match.
   - :latest still pushed for cache-from + bootstrap.
2026-05-27 10:06:49 +00:00

33 lines
1.2 KiB
Python

"""Configuration for the trade executor service."""
from shared.config import BaseConfig
class TradeExecutorConfig(BaseConfig):
"""Extends BaseConfig with trade-executor-specific settings."""
max_position_pct: float = 0.05
max_total_exposure_pct: float = 0.80
max_positions: int = 20
default_stop_loss_pct: float = 0.03
cooldown_minutes: int = 30
alpaca_api_key: str = ""
alpaca_secret_key: str = ""
paper_trading: bool = True
# Kevin v2 risk caps — only applied when TradeSignal.strategy_id ==
# KEVIN_STRATEGY_UUID.
kevin_daily_trade_cap: int = 10
kevin_daily_alloc_cap_usd: float = 20_000.0
kevin_equity_drawdown_halt_pct: float = 0.20 # 20% drawdown → permanent pause
kevin_daily_loss_circuit_pct: float = 0.05 # 5% daily loss → 24h pause
# Slack notifications — pick ONE transport:
# 1. Bot token + channel (preferred) → chat.postMessage API
# 2. Webhook URL (legacy) → single-channel webhook
# If both set, bot-token wins. If neither, notifier is a no-op.
slack_webhook_url: str = ""
slack_bot_token: str = ""
slack_channel: str = ""
model_config = {"env_prefix": "TRADING_"}