Sell by qty instead of notional, poll for buy fill

The buy order can return before filling, giving null price/qty. Now
buy polls getOrder until filled. Sell takes the actual qty from the
buy fill instead of the original dollar amount, which avoids the
"insufficient qty" error when the price moves between buy and sell.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jon
2026-02-11 12:37:12 -07:00
parent 7b1a20c768
commit 4ca7073d77
7 changed files with 102 additions and 40 deletions

View File

@@ -14,6 +14,7 @@ function mockAlpaca(overrides: Partial<Alpaca> = {}): Alpaca {
getLatestTrades: vi.fn(),
buy: vi.fn(),
sell: vi.fn(),
getOrder: vi.fn(),
...overrides,
} as unknown as Alpaca;
}