trading/tests
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
..
api_gateway feat(api): /api/meet-kevin/strategy/* routes 2026-05-24 01:12:16 +00:00
backtester feat(backtester): extend compute_metrics with alpha/beta/winners/best 2026-05-24 00:57:42 +00:00
fixtures feat(meet-kevin): caption extractor via yt-dlp 2026-05-21 19:40:52 +00:00
integration feat: integration tests, seed data, and smoke test script 2026-02-22 16:02:44 +00:00
services feat(phase2): BRACKET orders + Kevin risk caps (Tasks 18, 19) 2026-05-26 21:03:59 +00:00
shared feat(phase2): BRACKET orders + Kevin risk caps (Tasks 18, 19) 2026-05-26 21:03:59 +00:00
__init__.py feat: project foundation — monorepo setup, shared config, redis streams, telemetry 2026-02-22 15:13:26 +00:00
conftest.py feat(kevin): SA models for bridge audit + backtest persistence 2026-05-24 00:49:52 +00:00
test_backtester.py feat: backtesting engine — historical replay with shared strategies 2026-02-22 15:43:19 +00:00
test_broker.py feat: brokerage abstraction layer with Alpaca implementation 2026-02-22 15:26:41 +00:00
test_fundamentals.py refactor: reconcile FundamentalsSnapshot to use canonical schema from trading.py 2026-02-23 21:45:18 +00:00
test_indicators.py feat: add MACD, Bollinger, VWAP, ATR, EMA, SMA-200 indicator computations 2026-02-23 21:49:26 +00:00
test_models.py test(kevin): fix enum assertion + mark Postgres-dependent tests as integration 2026-05-26 20:01:37 +00:00
test_new_strategies.py feat: add 6 new strategies (value, MACD, Bollinger, VWAP, liquidity, MA stack) 2026-02-23 21:50:52 +00:00
test_redis_streams.py feat: project foundation — monorepo setup, shared config, redis streams, telemetry 2026-02-22 15:13:26 +00:00
test_schemas.py fix(schemas): use enum types as field types + enforce symbol length 2026-05-21 19:15:59 +00:00
test_strategies.py feat: productionize local service — fix signal pipeline, lower thresholds, add company-name ticker extraction 2026-02-22 22:17:26 +00:00