trading/services/api_gateway
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
..
auth fix: resolve all remaining TODOs, add dev mode auth bypass 2026-02-25 22:02:25 +00:00
routes feat(backtest): wire real Alpaca historical fetcher 2026-05-26 21:09:40 +00:00
tasks feat(kevin): reconcile Alpaca bracket auto-closes + order status 2026-06-04 22:31:24 +00:00
__init__.py feat: API gateway with passkey (WebAuthn) authentication 2026-02-22 15:53:48 +00:00
config.py fix: resolve all remaining TODOs, add dev mode auth bypass 2026-02-25 22:02:25 +00:00
main.py feat(kevin): reconcile Alpaca bracket auto-closes + order status 2026-06-04 22:31:24 +00:00
ws.py feat: API gateway trading endpoints, controls, backtest, WebSocket 2026-02-22 15:54:20 +00:00