feat: route trades to Alpaca (paper-default) instead of the mock store #13
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
pregno/polymarket-screener!13
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/alpaca-trading-integration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Replaces the simulated, spot-priced position store with real Alpaca orders (paper by default). Alpaca is now the source of truth for orders/fills/positions; the SQLite
positionstable is a thin mirror reconciled on a 30s timer + at startup.ALPACA_NOTIONAL_USD, default 1000), via Alpaca notional market orders.priceSourcegate);POST /api/positionsreturns 503,GETstill serves with null marks. A startup log announcestrading: ENABLED env=… notional=$…/DISABLED.ALPACA_ENV=paper|live(defaultpaper); only an exactlivereaches the live endpoint.pending → open → closing → closed | rejected, one active position per symbol (partial unique index). Optimistic record +Reconcilerresolves fills/rejections/drift.equity/equity_etf→ stock orders (day);crypto→BASE/USDorders (gtc);commodity/nullskipped; crypto shorts refused.priceSource(Binance/Yahoo) retained only for the OutcomeTracker — trading no longer depends on it.New:
AlpacaBroker(+Brokerseam),alpaca-symbols,Reconciler,create-broker, migration0010. Spec & plan underdocs/superpowers/.Test Plan
pnpm typecheckclean (shared + server + web)pnpm test— 408 passing across 71 files (broker guards, symbol mapping, position-service, auto-trader mode gating + deferred REVERSE, reconciler transitions/drift, API marks + 503 gating, config)pnpm --filter @pmsd/server buildsucceedspendingthenopenwith a live mark within ~30s; confirm order in the Alpaca paper dashboardFollow-ups (deliberately out of scope)
ALPACA_ENVswitch + startup log)GET /api/positionsfetches Alpaca's full position list once per distinct symbol rather than once per request (perf nicety)