> Every Taji docs page as Markdown: https://docs.taji.is/llms.txt

# Alpaca

A US broker with a free paper account: you trade stocks, options and crypto through it and read its market data.

## Before you link

Paper needs a free Alpaca account (email only, no funding) and its paper key pair. Live needs a funded Alpaca account and its own live key pair, not the paper one.

### Fees

`files.alpaca.markets/disclosures/library/BrokFeeSched.pdf`, 2026-09-17:

- Equity: $0 per order and share; sells pay SEC $0.0000206 × value and TAF $0.000195/share (cap $9.79); CAT $0.000003/share.
- Equity option (retail order flow): $0 per order and contract; sells pay SEC and TAF $0.00329/contract; ORF $0.015, OCC $0.025 per contract.
- Index option: $0.50 per contract plus exchange fees (SPX $0.57–$0.66, SPXW $0.50–$0.59).
- Crypto (`docs.alpaca.markets/docs/crypto-fees`, 2026-10-06): maker 0.15–0.00%, taker 0.25–0.10% by 30-day volume, on the credited asset; `CFEE` batched end-of-day, paper included, its `created_at` the execution time; executions at `/v2/account/activities/FILL?order_id=`, each net truncated to 9 places.

`FEE` and `CFEE` activities carry no `order_id`. A paper `CFEE` is "Coin Pair Transaction Fee (Non USD)" (`symbol` `BTCUSD`, `net_amount` `0`) or "(USD)" (`symbol` null, `net_amount` negative); paper `FEE` posting is unmeasured.

### Data subscriptions

Basic $0 (IEX real-time or delayed SIP), Algo Trader Plus $99 (real-time SIP) (`alpaca.markets/data`, 2026-09-21).

## Link

Start `alpaca-paper` (simulated money; the recommended first link) or `alpaca-live` (real money: every order the key sends is real) from Connections in the window, or run `taji-link alpaca-paper` or `taji-link alpaca-live`. Each takes the API key and secret, which Taji seals in the vault.

### Linking

Fetched 2026-11-18. Dashboard `https://app.alpaca.markets/dashboard/overview`; "yours" is a password, a code or money.

| Step | Page and controls | Yours |
|---|---|---|
| `account`, paper | `https://app.alpaca.markets/signup`, "Sign Up for Free" (alpaca.markets/learn/api-key-security-best-practices-for-alpaca-builders); a Paper Only Account needs an email address, no funding (docs.alpaca.markets/us/docs/paper-trading). Form fields: unsourced | yours: opening an account |
| `keys`, paper | Top navigation: environment toggled to "Paper Trading"; right-side "API Keys" module: "Generate New Key"; a modal shows "API Key" and "Secret Key", the secret once only. Replace: "Regenerate", then "Generate New Keys"; the old pair stops (the learn article). | none: the agent may |
| `keys`, live | Separate pair, separate host (docs.alpaca.markets/us/docs/authentication). The live toggle's label and key controls: unsourced | none: the agent may, once approved |

## What you get

Stocks, options and crypto orders, your balances, positions and orders, and Alpaca's market data. What it serves, cell by cell: [Alpaca coverage](https://docs.taji.is/reference/coverage/alpaca.md).

## Behaviour and limits

Measured 2026-09-01 to 2026-11-07; each entry carries its own date.

### Order handling

Server-side **bracket/OCO (OTOCO)**, depth **1**, equities only; several coexist on one symbol (2026-09-10).

**OTO** = entry + stop-loss, no `take_profit`: `stop` leg `held`, `nested=true`; cancel closed both (2026-09-13).

After a bracket's entry fills, its take-profit reads `new`, its stop `held`; an OTO's stop `new` (2026-09-29).

A stop rests around the clock, fires only in regular hours (2026-09-01).

Paper 2026-11-04 RTH, 1 AAPL held: a GTC stop SELL rests (`qty_available` 0); after its cancel a GTC limit, then an OCO, accepted.

**`client_order_id` is unique, and stays spent** (M, 2026-11-02, paper-api.alpaca.markets): a repeat answers `422` `40010001` "client_order_id must be unique", same body or different, neither returning the original nor creating a second. A cancelled order's id is refused alike, 109 days on too. `GET /v2/orders:by_client_order_id` saw the order on the first read after the POST reply.

**`PATCH` refused while `accepted`** (Day order queued outside regular hours): `422` `42210000` "cannot replace order in accepted status" (2026-09-07).

**A bracket's held child accepts `PATCH` while its parent rests `accepted`** (2026-09-09), parent unchanged; cancelling one cancels the group. After entry fills, a take-profit repriced through the market filled and cancelled the stop; a market sell of the group's held shares is `403` `40310000` "insufficient qty available" (2026-09-11).

**An accepted `PATCH` mints a new order** (2026-10-06): the old reads `status: "replaced"` on REST and `trade_updates`, `replaced_by` the new; the new carries `replaces`.

**`DELETE /v2/positions` is a market order, `extended_hours: false`** (2026-09-01); overnight it tripped the wash-trade guard.

**A bracket is regular-session only**: with `extended_hours: true`, `403` `40310000` "bracket orders do not support extended hours trading" (2026-09-09). After 16:00 ET as `gtc` it queues `accepted` for the next open.

**GTC** works on brackets and limits; a non-marketable one is adjusted for corporate actions, cancelled after 90 days.

**Trailing stop, limit-on-open/close** (2026-09-22): `opg` and `cls` limits `200 accepted` after 19:00 ET (opg refused 09:28–19:00 ET, cls 15:50–19:00 ET); the rest of the matrix is `LEGALITY` in `exec/orders.rs`.

**Notional, fractional, short, overnight** (AAPL, 2026-09-23), each `200 accepted`: `notional: "5"` with no `qty`; `qty: "0.5"`; `sell_to_open` with nothing held; `extended_hours: true` reads `pending_new` overnight.

**Crypto** (`BTC/USD`, 2026-09-23): market and `notional: "10"` fill; under $10 `403` `"cost basis must be >= minimal amount of order 10"`.

**Options**: single-leg buys (2026-09-23, closed): limit, stop and stop_limit, `gtc` and `day`, `200 accepted`; a cash-secured `sell_to_open` limit accepted. A market order out of hours is 422 42210000.

An option exit rests as a single-leg `stop` or `stop_limit`, regular hours only: "`stop` and `stop_limit` are only available for single-leg orders", "`extended_hours` must be `false` or not populated" (`docs.alpaca.markets/docs/options-trading`, 2026-12-02). Its docs name no option bracket, OCO or OTO, so none is declared.

### Request budget

2026-10-02 (paper): per-key counters, replies carrying `X-RateLimit-Limit`/`-Remaining`/`-Reset` (budgets in `ratelimit.rs`; account, positions and orders share one, stock and option bars one). The trading limit refills as a token bucket, ~3.3 calls a second (M, 2026-11-02): 220 POSTs in 6.6 s all answered 200, `X-Ratelimit-Remaining` reaching 0.

Idle close, 2026-10-31: `data.alpaca.markets`, `paper-api` and `api` drop a connection by 75 s. All three are HTTP/1.1.

429s, 2026-10-02 (paper): the trading host's after 274 calls in 22.4 s: `42910000` "rate limit exceeded" with the rate headers; the data host "too many requests." with none; neither sends `Retry-After`.

Basic-key streams 2026-10-02: a second `delayed_sip` socket is refused `406 connection limit exceeded`; a socket's symbol cap is 30 (`405 symbol limit exceeded`), crypto's too; two `trade_updates` sockets stay open.

Basic REST history is SIP to `now − 960 s`: it **403s any bars `end` inside the last ~16 min** (FAQ: 15); `end` must land on an extended-hours close.

#### `data/<product>` reads (2026-09-23, paper key, Basic data, RTH)

- `StockSnapshotSingle`/`StockLatestTradeSingle` `feed=sip` → 403 `subscription does not permit querying recent SIP data`; `delayed_sip` answers 15 min behind (2026-09-29). No `feed` answers IEX (`x: "V"`).
- `OptionSnapshots`/`OptionChain` `feed=opra` → 403 `subscription does not permit querying OPRA data` (paper, 2026-10-18: `OPRA agreement is not signed`); `indicative` answers all five `greeks` and `implied_volatility` (2026-10-10), never theo, std_dev or probability.
- `OptionTrades` inside 15 min → 403. `OptionBars` daily `t` 04:00Z; 1m: no bar without a print, `adjustment: null`.
- Crypto data reads `us-1` (Kraken US), same key and host, serving all `us` does; orders fill on `us` (2026-10-27; why in `lib.rs` `CRYPTO_PATH`).
- `CryptoBars`/`CryptoTrades`/`CryptoSnapshots` answer on `us`, volume/size fractional; `BTCUSD`, `BTC-USD` → 400 (2026-09-24). `CryptoBars` 1m: one bar per minute printed or not (`n: 0`, `v: 0`).
- Live 1m bars (2026-09-23): `v2/delayed_sip` SPY's land 16 min late; crypto BTC/USD's at the next turn. The option stream has none.
- Live ticks (2026-09-24): `v2/sip` 409 at auth; `v2/delayed_sip` acks trades, quotes and statuses; crypto `orderbooks` first book `r: true` with every level, deltas after. `v1beta1/opra` 409 `insufficient subscription`; a paper Basic key streams `v1beta1/indicative` (2026-09-25; option quotes acked 2026-11-02), `c` a string, msgpack only.
- `/v3/calendar/NYSE` answers `{date, pre_*, core_*, post_*, settlement_date}` in `-04:00`.
- `/v2/options/contracts/AAPL261104C00275000` (paper, 2026-11-01): 200 with the list row plus `deliverables`; an unlisted symbol 404 `40410000`.
- `CryptoLatestOrderbooks` BTC/USD (2026-11-01): `{orderbooks: {pair: {t, b, a}}}`, sides best first, no zero sizes. `us` 79 bids, 86 asks, uncrossed; `us-1` 100 each but crossed (its best bid above its best ask).

### Corporate actions

`/v1/corporate-actions`, batched.

- **Dividends** — `rate` is **as-declared**.
- **Renames** — `name_changes` rows answer on either symbol: FB and META both return FB→META, 2022-06-09 (2026-10-26). Other actions keep their day's symbol. Some splits are missing.

### Bar basis and feeds

Equity bars are **hybrid**: `daily/` OHLC covers regular hours, its volume and all `1min/` the extended session.

`stockbars`' `feed` has no `delayed_sip`.

Overnight, Basic key (2026-11-05): `v1beta1/boats` 409 at auth; `v1beta1/overnight` acks `trades`, `quotes`, `bars` beside `delayed_sip`; quotes on time, trades 900 s late, bars ~960 s after their minute.

`5Min` and `30Min` sit on the clock grid and equal the `1Min` fold (SPY's 2026-10-29 extended day; BTC/USD but its end-inclusive 00:00 bar; probed 2026-10-31); options likewise (2026-11-07), native.

A bars page ends near its 10,000th minute whatever the tier and `limit=10000` (2026-11-01, SIP raw SPY: `1Min` 10,000 bars, `5Min` 2,121, `30Min` 354, each 17 days).

A bars read's latency follows the minutes it spans (SIP SPY, warm, p50, 2026-11-02): `1Min` ~220 ms to ~1,000 minutes, then +0.09 ms a minute; `1Hour`: `source.rs` `first`.

Hour tiers, starts ET (SPY 2025-07–2026-10, 2026-11-02; AAPL week of 11-02, EST, 2026-11-07): extended `1Hour` 04:00-19:00, native (SIP adds 23:00, 00:00); regular `1Hour` from 09:00, off the grid; `24h` `1Hour` (SIP plus Blue Ocean) 120 gapless rows, native. `4Hour` is UTC-anchored (03:00 … 23:00 in EST), Taji's only in EDT; the rest fold (`lib.rs` `get_bars_session`). Options `1Hour` from 09:00, `4Hour` 07:00, 11:00, 15:00: fold. BTC/USD: UTC grid, native.

### Price adjustment

ADJ: `split,dividend,spin-off` (stockbars, 2026-10-16).

### Trades

`trading-api.json` `AssetClass` has no future (2026-09-23); 2026-10-31 adds `us_index`, `crypto_perp`: unread. Option history starts February 2024 per the vendor; earliest bar probed 2024-01-18.

## Open

- Option volume: how far back Alpaca lists expired contracts and serves their bars (30 days measured 2026-12-04: expired contracts listed, most sampled ones with bars); whether `expiration_date_lte=9999-12-31` is accepted; how a Basic key's 200 calls a minute fares against a full listing's 100-contract bars calls (`spy_option_volume_sums_from_batched_contract_bars` samples).
- `boats` (Algo Trader Plus): lag, channels, `406` beside SIP.
- Whether a 429 on a POST ever follows a created order.
- Whether a call inside a 429 extends it, `sip` and `delayed_sip` share a socket cap, a symbol on two channels counts twice, or a 405 brings a `subscription` echo; the `trade_updates` socket cap above 2.
- The statuses `canceled`, `rejected`, `expired`, `done_for_day` and `partially_filled` on the order stream: documented, unmeasured.
- Live account onboarding: the control that starts it, identity fields, funding page and approval wait are unsourced.

## References

- OpenAPI, index of all specs: https://docs.alpaca.markets/us/openapi
- Account plans, live onboarding with Alpaca Securities LLC from a paper-only account: docs.alpaca.markets/us/docs/account-plans
- Dashboard bank funding requires MFA: alpaca.markets/learn/api-key-security-best-practices-for-alpaca-builders
- How the integration works, and why: [ARCHITECTURE.md](https://docs.taji.is/catalog/alpaca/architecture.md)
