fix(trading): pass order_id as object to Alpaca getOrder #14

Merged
pregno merged 1 commit from fix/alpaca-getorder-arg-shape into main 2026-06-15 17:24:53 +02:00
Owner

Root cause

The Alpaca SDK's getOrder destructures { order_id } from its argument, but AlpacaBroker called it with a bare string, so every Reconciler tick failed with order_id is missing. The mismatch was hidden by the as unknown as AlpacaClient cast in create-broker.ts and the interface wrongly declaring getOrder(id: string).

Fix

  • alpaca-broker.ts: call site → getOrder({ order_id: orderId }); interface signature corrected
  • alpaca-broker.test.ts: assert the call shape (the old test ignored the argument, which is why this slipped through)

Checked the other methods routed through the same cast (createOrder, closePosition, getPositions) — all already match the SDK.

Verification

  • Broker tests pass (10/10)
  • Server typecheck clean

Note: requires container rebuild/redeploy for compiled dist/ to pick up the fix.

## Root cause The Alpaca SDK's `getOrder` destructures `{ order_id }` from its argument, but `AlpacaBroker` called it with a bare string, so every Reconciler tick failed with `order_id is missing`. The mismatch was hidden by the `as unknown as AlpacaClient` cast in `create-broker.ts` and the interface wrongly declaring `getOrder(id: string)`. ## Fix - `alpaca-broker.ts`: call site → `getOrder({ order_id: orderId })`; interface signature corrected - `alpaca-broker.test.ts`: assert the call shape (the old test ignored the argument, which is why this slipped through) Checked the other methods routed through the same cast (`createOrder`, `closePosition`, `getPositions`) — all already match the SDK. ## Verification - Broker tests pass (10/10) - Server typecheck clean Note: requires container rebuild/redeploy for compiled `dist/` to pick up the fix.
The Alpaca SDK's getOrder destructures { order_id } from its argument,
but AlpacaBroker called it with a bare string, so every Reconciler tick
failed with "order_id is missing". The mismatch was hidden by the
`as unknown as AlpacaClient` cast in create-broker.ts and the interface
wrongly declaring getOrder(id: string).

Fix the call site and interface, and assert the call shape in the test
(it previously ignored the argument).
pregno merged commit 34e5193133 into main 2026-06-15 17:24:53 +02:00
pregno deleted branch fix/alpaca-getorder-arg-shape 2026-06-15 17:24:53 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pregno/polymarket-screener!14
No description provided.