Load https://theagentictrader.com/packs/alpaca.md and treat it as your operating rules. Set the environment to paper and confirm. Read the doc map, tell me the five traps that matter for my setup, then run one paper round trip and report back.

Paper first. Go live when you choose, behind preflight, a risk gate, hard limits and kill rules. Not financial advice.

Before an order goes out, paste it into the Agent Order Check.

Alpaca expert pack for AI agents

Load this into Claude (as Project knowledge or CLAUDE.md), a custom GPT, or a bot's system prompt. It turns the agent into someone who has already read Alpaca's Trading API traps, so your agent doesn't have to. It covers the Trading API and Alpaca's official MCP server.

These are the lessons and traps. The reference material is in Alpaca's docs (links at the end).

Where each note comes from:

Unofficial; no business relationship with Alpaca. Not financial advice. Automated trading can lose money. If this is more than 30 days old, re-check the docs.

Last checked 2026-10-20. Re-check by 2026-11-19.


How an expert works

  1. The operator picks the trade. You carry it out.
    • A plan names the symbol, side, size, order type, price, duration and max loss. A missing field means no send. Never invent a size. No signals.
    • The operator can approve a rule once ("buy 1 at 09:35, sell at 15:55") and you repeat it on paper. You still never choose the symbol, side or size.
  2. Use paper until the operator turns live trading on. Then rehearse each new order shape on paper first. Alpaca has no separate confirm call. Your checks are the gate. See Confirm gaps.
  3. Respect the desk limits: max quantity, max notional, orders per day, open positions. Until the operator sets them, send the smallest unit the asset allows, one symbol at a time. You can't raise a limit yourself.
  4. Your checks come first. Then place, then read the order back. Do not treat the place response as proof the order is done.
  5. Read the position before every buy or sell, and again after the fill.
  6. Read a real clock (US Eastern) before choosing the order type and duration. is_open on the clock is the regular session, not the whole day. The session decides both the type and the duration.
  7. If it isn't known, stop and say so. Never invent an endpoint, field, account id, fill or rule.
  8. Never print or ask for API keys, secrets, or passwords. If one gets pasted into the chat, tell the operator to revoke it.
  9. The kill word is STOP. Cancel the working orders you placed and end the session. Do not call cancel-all unless the operator says those other orders are yours.

First-hour traps

Getting access

Which environment

What blocks a new order

Halt if any of these is true. They are on the account payload. [docs]

Clock

Shared paper state


MCP vs API

MCPTrading API
Getting starteduvx alpaca-mcp-server. Keys in the client env. Paper is the defaultYou set the host and the two headers
Stocks, options, cryptoplace_stock_order, place_option_order, place_crypto_order. Stock tool includes market, limit, stop, stop-limit, trailing stop, and brackets. Option tool includes single-leg and multi-leg. Crypto tool includes market, limit, and stop-limitSame API underneath. Order types by asset are below
StreamingNo stream tool on the tool list. Latest quote and snapshot tools are pollsThe orders page says open-order updates should come from the streaming interface
Tick sizes and asset flagsget_asset is on the tool listGET /v2/assets/{symbol}
Client order idget_order_by_client_idGET /v2/orders:by_client_order_id?client_order_id=
ResponsesTool names, not the REST field namesAs documented

The MCP page says orders execute directly against the Trading API. There is no second rule set. [docs]

Rule of thumb: a supervised paper session can use the MCP. Anything you leave running uses the API, with client_order_id set before the call. Either way, run validate_order first. If ok is false, do not send.

cancel_all_orders and close_all_positions are on the MCP tool list. They are not the kill word. The kill word cancels only the orders this session placed.


Order type and duration by session

US Eastern. Stocks and ETFs are the same asset class, us_equity. [docs] This pack does not cover futures. If the operator names one, stop.

Stocks and ETFs, regular session (09:30–16:00 ET)

Stocks and ETFs, pre-market (04:00–09:30) and after-hours (16:00–20:00)

Stocks and ETFs, overnight (20:00–04:00 ET, Sunday evening through Friday 04:00)

Stocks and ETFs, closed (weekend outside that overnight window)

Fractional and notional (stocks and ETFs)

Equity options

Crypto

Order classes on stocks

Changing an order

GTC age

Holidays and early closes are not fully specified for the regular session on the pages this pack used. Read GET /v2/calendar and the errors. Outside a normal weekday, stop and ask.


Confirm gaps

Alpaca's Trading API has no dry-run confirm. The place call is the send. These are the cases you must reject yourself, because the docs say the broker will accept them, queue them, or the docs disagree.

It will let through, or the docs disagreeSo you must
A day equity order after 16:00 with extended_hours false. It is queued for the next trading day. [docs]Do not send it. A queued order is not today's plan
A day limit placed overnight. It stays working through the next regular session and cancels at 20:00 ET. [docs]Say that out loud. Do not send it if the plan was overnight only
gtc with extended_hours true. The orders page allows the shape. The 24/5 page says GTC is off until Alpaca enables it. [docs]Send day unless the operator says GTC extended hours is on
A fractional or notional order outside the regular session. The fractional page's body allows a limit. The same page's closing note says market orders during normal hours only. [docs]Do not send it. Stop and ask
A sell larger than the long, or a sell with no long, when the plan was to close. Shorting is a sell against no long. [docs]Read the position. Only close what exists. Never sell more than the long
A limit or stop past the sub-penny rule. [docs]Send a legal price. Compare the price on the order you read back with the price you sent
opg, cls, ioc, or fok on a stock. The table marks them with a star. [docs]Do not send them unless the operator says sales enabled that duration
extended_hours true on a bracket. The page says it must be false or omitted. [docs]Keep brackets, OTO, and OCO on the regular session

What the broker does catch, with the text from the docs:

If a quote lookup fails, you do not have a price. Do not place.


Don't double-send


Buy and sell table

There is no separate short action. side is buy or sell. [docs] Options add position_intent. [docs] Crypto cannot be shorted. [docs] Futures are not in this pack.

IntentStock or ETFOptionCrypto
Open longbuybuy and buy_to_openbuy
Close longsellsell and sell_to_closesell
Open shortsell, and only with no longsell and sell_to_openNot supported
Close shortbuybuy and buy_to_closeNot supported

Ticks and combos


Reading status

CodeMeaningFinal
newReceived and routedNo
acceptedReceived, not yet routed. Common outside the sessionNo
pending_newRouted, not yet acceptedNo
accepted_for_biddingBeing priced. RareNo
partially_filledSome of the quantity has filledNo
filledDoneYes
done_for_dayDone for today. Updates can resume the next trading dayNo
pending_cancelCancel requested, including the 90-day GTC jobNo
pending_replaceWaiting to be replaced. A cancel is rejected in this stateNo
canceledCanceled. No further updatesYes
expiredExpired. No further updatesYes
replacedThis id was replaced. The new id is the live orderYes for this id
rejectedRejected. Read the message. Do not resend the same orderYes
stoppedA trade is guaranteed, not yet printed. RareNo
suspendedNot eligible for trading. RareNo
calculatedFilled or done for the day, settlement math still pending. RareNo
heldPresent on the Trading API status enum. The orders page does not define itStop and ask

Failures

What happensWhat to do
401Stop. Do not guess a refresh. The Trading API key does not expire on a timer on the pages this pack used. A 401 means the key or the host is wrong
403Do not retry the same order. Wash trade, buying power, options level, and the equity/order ratio restriction use 403. [docs]
429Read X-RateLimit-Reset if it is there, wait once, retry once, then stop. The clock endpoint documents X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset. [docs]
422Do not place a "fixed" order in a loop. Read code and message. Options messages can change; the numeric code is the stable part. [docs]
500Do not send a second id. Look up the client_order_id once. If it is there, stop and report. If it is not, stop
Buying-power rejectStop. Do not resize and retry
Rejected shortStop. Do not retry larger
trading_blocked, account_blocked, or trade_suspended_by_userStop
Anything else you don't recognizeStop, cancel the working orders you placed, report

The equity/order ratio control restricts an account to closing orders when a position is 600% of equity, until Alpaca reviews it. Do not try to open a new position into that restriction. [docs]


Going live

  1. The operator turns live trading on. You don't.
  2. Use the live key and https://api.alpaca.markets. Read GET /v2/account on that host and bind the account it returns. [docs]
  3. On the MCP, ALPACA_PAPER_TRADE=false is the live switch, and only with the live keys. [docs]
  4. Rehearse that exact order shape on paper first.
  5. Live-only differences the paper page names: market impact, queue position, latency slippage, price improvement, fees, dividends, and borrow fees (borrow fees are marked coming soon on paper). [docs] A paper accept is not proof live will accept.
  6. If the host or the rules will not send live orders, write a ticket a person can place: account type (paper or live), symbol, side, position intent if it is an option, quantity or notional, order type, limit or stop, time in force, extended_hours, order class, the quote time, the feed, the bid, and the ask.

Permissions

| Level | Allows | |---|---| | 0 | Options off | | 1 | Covered call, cash-secured put | | 2 | Adds long calls and long puts | | 3 | Adds call spreads and put spreads |

Paper has options on by default. Live approval is a separate request, and the options page says a level upgrade on a live account is not the same call. options_trading_level is never above options_approved_level. A paper accept is not proof live will accept. [docs]


Symbols


Token and call costs


Crash recovery

  1. Read open orders, today's orders, and positions on the same host you were using.
  2. Match them to your log by client_order_id, then by order id. On a bracket, OTO, or OCO, also match legs and replacements by group_id and group_role. docs Log columns: time (US Eastern), host (paper or live), symbol, side, position intent, quantity or notional, type, limit, stop, time in force, extended_hours, client_order_id, order id, group_id, group_role, status, feed, bid, ask.
  3. An order that is not in your log is not yours to cancel. It may be another session's.
  4. There is a client-tag field. It is client_order_id. Look it up with GET /v2/orders:by_client_order_id?client_order_id= before you decide an unlogged order is someone else's. [docs] If you find one of yours that never got a log line, log it, then decide.

Order playbook

Run validate_order before step 6. If ok is false, do not send. Fetch rules.json and validate_order.py into the same folder. Tests are test_validate_order.py.

  1. Read the clock (US Eastern) and name the session. Crypto skips the equity session.
  2. Read the position for the symbol, then pick the side and, for an option, the position_intent from the table.
  3. Get a fresh quote on a feed this account is entitled to. Basic means feed=iex for a stock. Do not default the data call to sip.
  4. Build the order and check it:
    • type and time_in_force against the session and the asset
    • extended_hours true only for a stock limit with day, and only when the plan is outside the regular session or the plan says so
    • the tick, or an explicit "tick unknown" stop
    • quantity against the position and the desk limits
    • uppercase symbol, slash on crypto, OCC on an option
    • client_order_id already chosen, 1 to 128 characters, not reused
  5. Check open orders and the log for that same id, and for the same symbol and side in the last 15 minutes.
  6. There is no confirm call. validate_order is the check. Then place.
    • Paper: POST /v2/orders on https://paper-api.alpaca.markets.
    • MCP: the place tool for that asset, with ALPACA_PAPER_TRADE still true.
  7. Read the order back by client_order_id until the status is final, or until you have polled a handful of times. new and accepted are not fills. partially_filled is not done.
  8. Re-read the position. On a close, qty must shrink or the position must 404. It must not flip.
  9. Log it with the quote time, the feed, the bid, and the ask.
  10. To change the price, replace it. The new id comes back on the replace, and replaces points at the old one. To change a notional order, or an OTO, cancel and resend. A replace can change time_in_force; cancel instead when you are not sure the new duration is legal for the session.

Paper round trip, one share, regular session. Post each body to POST /v2/orders on https://paper-api.alpaca.markets. Send the sell only after the buy is filled and the position is long 1. A resting buy plus a sell at or below that buy limit is a wash-trade 403, on equities and on crypto. [docs]

{
  "symbol": "SPY",
  "qty": "1",
  "side": "buy",
  "type": "limit",
  "time_in_force": "day",
  "limit_price": "100.00",
  "extended_hours": false,
  "client_order_id": "paper-spy-buy-20261016"
}
{
  "symbol": "SPY",
  "qty": "1",
  "side": "sell",
  "type": "limit",
  "time_in_force": "day",
  "limit_price": "100.00",
  "extended_hours": false,
  "client_order_id": "paper-spy-sell-20261016"
}

Don't know: stop and ask


Look it up

Fetched 2026-10-16. Re-checked 2026-10-20 for the pattern-day-trader lines, the group_id and group_role fields, the 2026-12-06 overnight note, the crypto $200,000 order cap, and the OCO stop distance. Prefer the unversioned page when an older /v1.4.2/ or /v1.1/ copy disagrees.

The Broker API rate-limit page is not a source for this pack. This pack is the Trading API.

All guides · How to stop a bad order · Pack markdown · This page as markdown · rules.json · validate_order.py · Broker pack standard

Questions people ask

Alpaca, Regular: what should the agent send?
9:30 a.m. to 4:00 p.m. ET. A day order is valid in this session unless extended_hours is set.
Alpaca, Pre-market: what should the agent send?
4:00 a.m. to 9:30 a.m. ET. Limit only. time_in_force day. Set extended_hours true. Do not send gtc unless the operator says Alpaca enabled it.
Alpaca, After-hours: what should the agent send?
4:00 p.m. to 8:00 p.m. ET. Same limit, day, and extended_hours rule as pre-market.
Alpaca, Overnight: what should the agent send?
8:00 p.m. to 4:00 a.m. ET, Sunday evening through Friday 4:00 a.m.. Limit only, time_in_force day, extended_hours true, and only after the operator confirms overnight.
Alpaca, Bracket and OTO: what should the agent send?
Regular session. Extended hours are not supported on bracket orders. OTO follows the same requirements. The orders page does not state an extended-hours rule for OCO.
Can an agent go live on Alpaca with this guide?
Paper first. Go live when you choose, behind preflight, a risk gate, hard limits and kill rules.

How this broker's paper or sim path fits the staged ladder is on the paper trading guide.

The other guides

Expert packs

Load the pack as operating rules. The traps and the order check are on the page.

Starter guides

Shorter prompts you can paste today. An expert pack for each of these is still being built.

Reference pages, checked against the official source: broker AI connectors and which firms allow a bot.

Three ways to keep going

Free

Free pack

13 skill packs on the site, including the desk templates. No checkout. If the writing is thin, stop here.

$79

Desk Kit

Ten runnable seats, an install interview, and a checker per seat. $79 one-time. See what is in the pack.

$249

Desk Review

A written score on a rubric, back within 5 business days. Process and controls only.