trading/shared
Viktor Barzin f7ca671bf3
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was canceled
feat(phase2): BRACKET orders + Kevin risk caps (Tasks 18, 19)
Task 18 — OrderRequest + AlpacaBroker BRACKET support:
- OrderRequest gains order_class ("simple" | "bracket"),
  take_profit_price, stop_loss_price + model_validator that requires
  both legs when order_class == "bracket".
- AlpacaBroker._build_order_request branches to a MarketOrderRequest
  with OrderClass.BRACKET + TakeProfitRequest + StopLossRequest legs,
  TimeInForce.GTC so the bracket survives day boundaries.

Task 19 — RiskManager Kevin caps + circuit-breaker:
- TradeExecutorConfig gains 4 fields: kevin_daily_trade_cap,
  kevin_daily_alloc_cap_usd, kevin_equity_drawdown_halt_pct,
  kevin_daily_loss_circuit_pct.
- check_risk() applies the caps only when
  signal.strategy_id == KEVIN_STRATEGY_UUID; non-Kevin signals pass
  through the existing path unchanged.
- 4 new checks in order: drawdown halt (sets permanent
  trading:paused), daily-loss circuit (setex 24h), daily trade-count
  cap, daily allocation cap (rolling today's $ + this trade's
  notional).
- Counter keys: kevin:daily_trades:YYYY-MM-DD,
  kevin:daily_alloc_usd:YYYY-MM-DD, kevin:daily_pnl_usd:YYYY-MM-DD,
  kevin:starting_equity_usd. All read-only here; bridge + executor
  write them.

Tests: 5 bracket + 9 kevin-caps + 28 regression-safe. Total 67 + 14
new = 81 passing (excluding -m integration). No DB needed.
2026-05-26 21:03:59 +00:00
..
broker feat(phase2): BRACKET orders + Kevin risk caps (Tasks 18, 19) 2026-05-26 21:03:59 +00:00
constants feat(kevin): SA models for bridge audit + backtest persistence 2026-05-24 00:49:52 +00:00
fundamentals feat: add fundamentals DB model and cached provider 2026-02-23 21:49:31 +00:00
models feat(kevin): SA models for bridge audit + backtest persistence 2026-05-24 00:49:52 +00:00
schemas feat(phase2): BRACKET orders + Kevin risk caps (Tasks 18, 19) 2026-05-26 21:03:59 +00:00
strategies feat(kevin): mention-driven backtest mini-engine 2026-05-24 00:56:57 +00:00
__init__.py feat: project foundation — monorepo setup, shared config, redis streams, telemetry 2026-02-22 15:13:26 +00:00
config.py feat: project foundation — monorepo setup, shared config, redis streams, telemetry 2026-02-22 15:13:26 +00:00
db.py feat: database models and alembic migrations — all tables per design 2026-02-22 15:17:07 +00:00
redis_streams.py fix: resolve 13 important issues from code review 2026-02-22 17:58:01 +00:00
telemetry.py feat: project foundation — monorepo setup, shared config, redis streams, telemetry 2026-02-22 15:13:26 +00:00