trading/alembic/versions
Viktor Barzin 82dc622544 feat(kevin): reconcile Alpaca bracket auto-closes + order status
Bracket stop-loss/take-profit legs fill at Alpaca without passing through the executor, so those closes (and their P&L) were invisible locally.

- broker: add get_order(nested) + list_orders to BaseBroker/AlpacaBroker (+ SimulatedBroker); BrokerOrder carries child legs

- Trade gains broker_order_id (migration f6a7b8c9d0e1); executor stamps the entry order id

- new api_gateway trade-reconcile loop: books a closing SELL + realized P&L when a bracket leg fills (idempotent on the leg order id), syncs PENDING->terminal status, logs drift; runs alongside portfolio_sync

[ci skip]

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 22:31:24 +00:00
..
a1b2c3d4e5f6_initial_schema.py fix: make hypertable creation conditional on TimescaleDB extension 2026-02-25 21:03:31 +00:00
b2c3d4e5f6a7_add_fundamentals_table.py feat: add fundamentals DB model and cached provider 2026-02-23 21:49:31 +00:00
c3d4e5f6a7b8_add_meet_kevin_tables.py feat: add Alembic migration for Meet Kevin tables 2026-05-21 19:31:21 +00:00
d4e5f6a7b8c9_kevin_v2_trading_tables.py feat(kevin): alembic migration for v2 trading tables 2026-05-24 00:50:00 +00:00
e5f6a7b8c9d0_kevin_expected_move.py feat(meet-kevin): prompt v2 — forward-looking action + expected_move field 2026-05-28 21:40:07 +00:00
f6a7b8c9d0e1_add_trade_broker_order_id.py feat(kevin): reconcile Alpaca bracket auto-closes + order status 2026-06-04 22:31:24 +00:00