Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Place and manage orders on behalf of accounts via the Alpaca Broker API — order creation (qty vs notional, fractional shares, order types/TIF/classes), order status lifecycle, replace/cancel, positions, and trading-account buying power. Use when building trading, recurring-invest, or portfolio flows on Alpaca in any language.
.claude/skills/alpacahq-alpaca-broker-trading-orders/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 199% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 192% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 256% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 67% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 71% | 0% |
Place, modify, cancel, and track orders for an end-user account, and read positions & buying power. The defining feature of Broker API trading: account_id is in the path — you act for a user account, not your own.
> Read alpaca-broker-integration first. Broker API + HTTP Basic auth. (The standalone Trading API uses /v2/orders with no account in the path; everything else here transfers.)
https://docs.alpaca.markets/docs/orders-at-alpaca, https://docs.alpaca.markets/docs/fractional-tradinghttps://docs.alpaca.markets/reference/postorderalpaca-docs MCP → get-endpoint title "Broker API" path /v1/trading/accounts/{account_id}/orders| Method | Path | Purpose | |--------|------|---------| | POST | /v1/trading/accounts/{id}/orders | Create order | | GET | /v1/trading/accounts/{id}/orders | List orders (filter by status, symbols, after…) | | GET | /v1/trading/accounts/{id}/orders/{order_id} | Get order by ID | | GET | /v1/trading/accounts/{id}/orders:by_client_order_id?client_order_id=… | Get by your client ID | | PATCH | /v1/trading/accounts/{id}/orders/{order_id} | Replace (modify) order | | DELETE | /v1/trading/accounts/{id}/orders/{order_id} | Cancel one order (204) | | DELETE | /v1/trading/accounts/{id}/orders | Cancel all (207 Multi-Status) | | POST | /v1/trading/accounts/{id}/orders/estimation | Cost-estimate an order | | GET / DELETE | /v1/trading/accounts/{id}/positions[/{symbol_or_asset_id}] | List / close positions | | GET | /v1/trading/accounts/{id}/account | Trading-account details (buying power etc.) |
Schema-required: type and time_in_force. Conditionally required: symbol, side, and exactly one of qty/notional.
json// notional market buy (dollar-based, fractional) { "symbol": "AAPL", "notional": "25.00", "side": "buy", "type": "market", "time_in_force": "day", "client_order_id": "your-own-uuid" } // limit qty sell { "symbol": "AAPL", "qty": "3", "side": "sell", "type": "limit", "limit_price": "190.00", "time_in_force": "gtc" }
| Field | Values / notes | |-------|----------------| | symbol | required (except mleg multi-leg options) | | qty | decimal string, up to 9 dp. Fractional only for market+day | | notional | decimal string, up to 9 dp. Mutually exclusive with qty | | side | buy, sell (plus advanced: sell_short, …) | | type | market, limit, stop, stop_limit, trailing_stop | | time_in_force | day, gtc, opg, cls, ioc, fok | | limit_price / stop_price | required for limit/stop variants | | trail_price / trail_percent | one required for trailing_stop | | extended_hours | bool; only with type=limit and TIF day/gtc | | client_order_id | ≤128 chars; your idempotency key (auto-generated if omitted) | | order_class | simple (default), bracket, oco, oto, mleg | | take_profit / stop_loss | {limit_price} / {stop_price, limit_price?} for bracket/oco/oto | | position_intent | buy_to_open, sell_to_close, … |
qty XOR notional (verbatim rule): pass one or the other — supplying both → 400. In the response, whichever you didn't use comes back null.
fractionable: true (check the Assets API — see alpaca-broker-market-data), else requested asset is not fractionable.day for fractional/notional.market and limit (day); only limit for extended hours. Fractional qty additionally allows stop/stop_limit per the guide.qty and notional.OrderStatus (the order object's status): new, partially_filled, filled, done_for_day, canceled, expired, replaced, pending_cancel, pending_replace, accepted, pending_new, accepted_for_bidding, stopped, rejected, suspended, calculated.
> Order status ≠ trade-event event. The order object's status is the enum above. The SSE trade-update stream reports a richer event enum that adds operational events not present as a status — including held (multi-leg secondary legs awaiting trigger), trade_bust, trade_correct, restated, order_cancel_rejected, order_replace_rejected. So held exists as a trade event but never as an order status. See alpaca-broker-sse-events.
Terminal: filled, canceled, expired, rejected (and replaced for the original order). Everything else is in-flight.
Early-state distinctions (these trip people up):
accepted — received by Alpaca, not yet routed to a venue (common outside market hours).new — received and routed to exchanges; the usual initial live state.pending_new — routed but not yet accepted for execution (rare).So the typical opening sequence is accepted → pending_new → new, then fills. Lesson: treat new/accepted/pending_new as "exists but not done." Persist the order on submit, then update on fill/cancel/reject events — don't block the user waiting for a terminal state synchronously.
Position key fields: symbol, asset_id, qty, qty_available (free of open orders), side (long/short), avg_entry_price, market_value, cost_basis, unrealized_pl, unrealized_plpc, current_price, change_today.
TradeAccount key fields:
buying_power (with margin multiplier 1–4), cash, cash_withdrawable, equity, last_equity.trading_blocked, account_blocked, transfers_blocked, trade_suspended_by_user.multiplier, regt_buying_power, non_marginable_buying_power, long_market_value, initial_margin, maintenance_margin, sma.Lesson — check buying power before notional orders. For a "spend $X" UX, read buying_power/cash first and reject/notify on insufficient funds, rather than letting Alpaca reject the order. (Cache it per account within a batch run to avoid re-fetching.)
> PDT/day-trade fields are deprecated (since 2026-04-27, sunset 2026-07-06) following FINRA's intraday-margin rule change: daytrade_count, pattern_day_trader, daytrading_buying_power, bod_dtbp, plus config dtbp_check/pdt_check. They still exist in the schema today but stop relying on them.
bracket/oco/trailing_stop for simultaneous take-profit + stop-loss — they're exempt.take_profit.limit_price and stop_loss.stop_price; TP must be above SL for a buy; no extended hours; TIF day/gtc; child legs activate only after the entry fully fills; canceling one cancels the group.qty can't be changed on replace ("full shares only").200 from PATCH can still be rejected if the original fills first; watch the trade-updates stream. Can't replace while accepted/pending_new/pending_cancel/pending_replace.204, or 422 if no longer cancelable; cancel-all → 207 per-order results; close-all positions → 207. Close-single accepts mutually-exclusive qty or percentage.client_order_id from your own transaction record. It's your dedup key and lets you look the order up (orders:by_client_order_id) if the create response is lost. Note it dedups lookup, not necessarily replay — combine it with a local "already-submitted?" guard.notional market/day order per instruction → record the returned order → mark the instruction done only after a successful create. On insufficient funds, cancel the instruction and notify, don't silently skip. Schedule the batch shortly before market open and respect the market clock (alpaca-broker-market-data).alpaca-broker-sse-events.Related skills: prices/assets/clock → alpaca-broker-market-data; fills in real time → alpaca-broker-sse-events; rate limits on bulk placement → alpaca-broker-rate-limits-resilience; money formatting → alpaca-broker-money-precision.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 5,811 | 5,314 | -9% | 1 | 1 | 0% | 1,274 | 3,810 | +199% | 0 | 0 | — |
case-02 | fail→pass | 5,961 | 5,309 | -11% | 1 | 1 | 0% | 1,296 | 3,786 | +192% | 0 | 0 | — |
case-03 | pass→pass | 13,450 | 10,681 | -21% | 1 | 1 | 0% | 2,808 | 5,117 | +82% | 0 | 0 | — |
case-04 | pass→pass | 10,095 | 5,869 | -42% | 1 | 1 | 0% | 2,039 | 3,659 | +79% | 0 | 0 | — |
case-05 | pass→pass | 9,437 | 9,300 | -1% | 1 | 1 | 0% | 1,609 | 4,473 | +178% | 0 | 0 | — |
case-06 | fail→pass | 6,608 | 3,365 | -49% | 1 | 1 | 0% | 917 | 3,262 | +256% | 0 | 0 | — |
case-07 | pass→pass | 8,318 | 2,788 | -66% | 1 | 1 | 0% | 1,468 | 3,180 | +117% | 0 | 0 | — |
case-08 | pass→pass | 6,561 | 2,422 | -63% | 1 | 1 | 0% | 1,310 | 3,144 | +140% | 0 | 0 | — |
case-09 | pass→pass | 8,637 | 3,607 | -58% | 1 | 1 | 0% | 1,591 | 3,320 | +109% | 0 | 0 | — |
case-10 | pass→pass | 3,921 | 3,534 | -10% | 1 | 1 | 0% | 913 | 3,347 | +267% | 0 | 0 | — |
case-11 | fail→pass | 13,095 | 6,838 | -48% | 1 | 1 | 0% | 2,465 | 4,127 | +67% | 0 | 0 | — |
case-12 | fail→pass | 9,124 | 2,625 | -71% | 1 | 1 | 0% | 1,837 | 3,149 | +71% | 0 | 0 | — |
case-13 | pass→pass | 3,927 | 4,320 | +10% | 1 | 1 | 0% | 806 | 3,530 | +338% | 0 | 0 | — |
case-14 | pass→pass | 3,305 | 4,243 | +28% | 1 | 1 | 0% | 506 | 3,533 | +598% | 0 | 0 | — |
case-15 | fail→pass | 5,231 | 3,815 | -27% | 1 | 1 | 0% | 1,097 | 3,399 | +210% | 0 | 0 | — |
case-16 | fail→pass | 11,156 | 10,270 | -8% | 1 | 1 | 0% | 1,951 | 4,229 | +117% | 0 | 0 | — |
case-17 | fail→pass | 13,431 | 4,164 | -69% | 1 | 1 | 0% | 2,569 | 3,509 | +37% | 0 | 0 | — |
case-18 | pass→pass | 5,331 | 4,236 | -21% | 1 | 1 | 0% | 1,136 | 3,453 | +204% | 0 | 0 | — |
case-19 | fail→pass | 15,550 | 3,642 | -77% | 1 | 1 | 0% | 2,865 | 3,347 | +17% | 0 | 0 | — |
case-20 | pass→pass | 4,895 | 2,554 | -48% | 1 | 1 | 0% | 1,038 | 3,177 | +206% | 0 | 0 | — |
case-21 | pass→pass | 10,432 | 4,497 | -57% | 1 | 1 | 0% | 1,866 | 3,468 | +86% | 0 | 0 | — |
case-22 | pass→pass | 10,944 | 3,816 | -65% | 1 | 1 | 0% | 1,946 | 3,297 | +69% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +41 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.