Alpaca
<!-- BEGIN:skill-intro -->
Tools for trading on
Alpaca against the
Trading API: place and manage stock, crypto, and options orders; read account balances, positions, portfolio history, and activities; look up assets, market hours, and option contracts; and read watchlists. 25 scripts across account, orders, positions, assets, options, and watchlists.
Trades run against Alpaca's paper (simulated) environment by default; live real-money trading requires an explicit opt-in (see Auth). Money and quantity values are returned as
strings to preserve decimal precision — never coerce them to numbers. Order placement is
async-confirmed:
acknowledges receipt with a status that can change server-side, so re-query
before asserting a fill.
<!-- legal:disclaimer -->
Independent, unofficial connector for Alpaca. Not affiliated with, endorsed by, or sponsored by Alpaca. "Alpaca" is a trademark of its owner, used only to identify the service this connector works with.
<!-- /legal:disclaimer -->
<!-- END:skill-intro -->
When to use this
<!-- BEGIN:skill-use-cases -->
- Inspect the account — read balances and buying power, list open positions and unrealized P&L, review portfolio history and account activities (fills, dividends, fees), or check whether the market is open.
- Place and manage orders — buy or sell stocks, crypto, or options (market/limit/stop/bracket/OCO/OTO/multi-leg); replace or cancel open orders; close or liquidate positions; exercise an options position.
- Look things up — resolve a symbol's tradability/shortability/fractionability, list assets or option contracts, and read watchlists.
<!-- END:skill-use-cases -->
Setup
This is an
agentskills.io skill.
If the connector has not been installed as a skill yet, install it first with
npx skills add zapier/connectors --skill alpaca
(or your harness's own skill-install mechanism), then continue here. Installing the skill copies these files, not dependencies. Before running the CLI, a local MCP server, or
auth commands, run
here once. Importing the published package as a dependency in your own project instead? That
already resolves everything — see
.
The connector runs on Node.js 22.18+. Pick the reference that matches how you're running it, and load it before doing anything else:
| You have... | Load |
|---|
| An MCP-aware client — tools may already be loaded (e.g. ), or you can register a local server yourself (or guide the user to) | |
| Terminal / subprocess access (you can run ) | |
| Only your own code, importing this package as a dependency | |
| No tool access, no terminal, no ability to import this package — you write your own code that calls the Alpaca API directly (e.g. a code-execution sandbox) | references/use-as-recipe.md
|
Scripts
<!-- BEGIN:skill-connections-note? -->
All scripts use the single connection
. Trading tools hit the paper host by default (live requires an opt-in — see Auth).
<!-- END:skill-connections-note -->
<!-- BEGIN:skill-scripts-table -->
| Script | Script name | Connections | Description |
|---|
| | | Get account balances, buying power, equity, and trading-permission flags. |
scripts/getAccountConfigurations.ts
| | | Get the account's trading configuration flags. |
scripts/getPortfolioHistory.ts
| | | Get the account's equity and P&L time series over a period. |
scripts/listAccountActivities.ts
| | | List account activities — fills, dividends, fees, transfers — by type and date. |
| | | Place an order to buy or sell a stock, crypto pair, or option. |
| | | Replace (modify) an open order's quantity, price, or time-in-force. |
| | | Cancel one open order by id. |
scripts/cancelAllOrders.ts
| | | Attempt to cancel every open order (per-order status list). |
| | | List orders, filtered by status, symbols, or side. |
| | | Get one order by id, including status and fill details. |
scripts/getOrderByClientOrderId.ts
| | | Get one order by the client_order_id you assigned. |
| | | List all open positions with market value, cost basis, and P&L. |
| | | Get one open position by symbol or asset id. |
| | | Close (liquidate) one position, fully or partially. |
scripts/closeAllPositions.ts
| | | Liquidate every open position (optionally cancel open orders first). |
scripts/exerciseOptionsPosition.ts
| | | Exercise a held options position by option symbol or contract id. |
| | | List tradable assets, filtered by class, status, or exchange. |
| | | Get one asset by symbol, asset id, or CUSIP (tradability flags). |
| | | Get the market clock — is it open now, and the next open/close. |
scripts/getMarketCalendar.ts
| | | Get market trading days with open/close times over a date range. |
scripts/listOptionContracts.ts
| | | List option contracts for underlyings, filtered by expiration/type/strike. |
scripts/getOptionContract.ts
| | | Get one option contract by OCC symbol or contract id. |
scripts/listWatchlists.ts
| | | List the account's watchlists. |
| | | Get one watchlist by id, including its asset symbols. |
scripts/getWatchlistByName.ts
| | | Get one watchlist by name, including its asset symbols. |
<!-- END:skill-scripts-table -->
<!-- BEGIN:disambiguation-and-refusals? -->
Disambiguation & refusals
Disambiguation before a write. Trade and position tools key on an exact symbol or id, not a company name. Before acting on something the user named loosely:
- Symbols / assets — if the user gives a company name ("Apple") rather than a ticker, resolve it first with or . If exactly one asset matches, act on it; if several plausibly match, list them (symbol + name + exchange) and ask which. Never guess a ticker.
- Watchlists — resolve by name with or . Names are unique per account, so one exact (case-insensitive) match is the answer — act on it, don't over-ask. If nothing matches, say so. This connector reads watchlists but does not create or modify them (see Unsupported operations).
- Orders / positions — take an or the user already has (from / ). If they describe an order vaguely ("cancel my Tesla order"), list the candidates first and confirm before canceling.
Unsupported operations — say so and stop; don't fake it with another tool. This connector deliberately does not:
- Move money — no deposits, withdrawals, transfers, bank links, or funding. Those live on Alpaca's Broker API and are out of scope.
- Read market data — quotes, bars, snapshots, news, corporate actions, and option chains are out of scope. This connector wraps Alpaca's Trading API only, not the Market Data API (); there are no price/history or streaming tools.
- Create or modify watchlists, or change account configuration — this connector reads watchlists ( / / ) and account settings () but does not create, update, or delete them.
- Trade against a live account by default — trading is paper (simulated) unless the user has explicitly enabled live (see Auth). If asked to trade real money, confirm live is enabled rather than assuming.
- Manage the stock screener, OAuth apps, or account documents — not exposed.
If asked for any of these, tell the user it's unsupported and stop — don't substitute an unrelated tool and report success for an action you didn't perform.
<!-- END:disambiguation-and-refusals -->
Auth
Every shape passes auth as one connection
selector, not the secret — a
string. Every connector accepts
(Zapier-managed auth — routes through Zapier's auth, retries, and governance layer); some also accept one or more direct-token resolvers (naming and count vary per connector) — check this connector's own resolvers rather than assuming. The
prefix is optional; a bare value goes to the first resolver that claims it — a UUID-shaped bare value always claims
. Each script declares the connections it needs and the resolvers each accepts. The exact syntax for passing a connection (and how to see this connector's resolver list) differs by shape — see the reference you loaded above.
Checking what's already configured first? Don't dump environment values to do it —
or
prints the value along with the name, leaking a live credential into the transcript if one is set. Check names only (
env | cut -d= -f1 | grep -i <name>
) or test a known name directly (
).
<!-- BEGIN:skill-auth-notes -->
Zapier-managed auth (
) is experimental for Alpaca — the direct resolver (
) is the verified path.
<!-- END:skill-auth-notes -->
No connection yet? Pick one — and follow the reference's own flow to obtain it; never just ask the user for a connection id or token as if they already have one memorized:
| Load |
|---|
| Pass the credential directly | references/use-without-zapier.md
|
| Route it through a Zapier connection | references/use-with-zapier.md
|
Output format
Every script returns a
envelope:
- — the script's result (the shape its declares; see the reference you loaded above for how to inspect a script's exact schema in your shape).
meta.outputDataValidation
— what validating did:
{ skipped: false, droppedPaths: null }
— validated, nothing removed.
{ skipped: false, droppedPaths: [...], instruction }
— validated, but those paths were stripped from : fields the script returned from the API that the doesn't declare. If you need them, re-run with output validation skipped.
- — validation was bypassed; is the raw, unchecked script output.
Reading dropped fields / . To receive the raw, unvalidated result, opt out of output validation (the exact syntax differs by shape — see the reference you loaded above). Input validation is never skipped.
Trimming the result / . To shrink a large result down to the fields you need, pass a jq expression that post-processes
(again, exact syntax per shape). The jq runs against
only, NOT the
envelope, so write it rooted at
(run the script's
— or your shape's equivalent — to see its output schema). The transformed value replaces
,
is preserved, and the result is NOT re-validated against the output schema.
<!-- BEGIN:skill-references-table -->
References
Load the matching reference file before working in that area:
| Reference | Covers | Load it when |
|---|
references/alpaca-api-gotchas.md
| Alpaca API behavior the schemas don't capture: auth & paper/live hosts, the error envelope + status codes, rate limits, pagination, order types/TIF/classes (bracket/oco/oto/mleg), fractional/notional & extended-hours rules, order lifecycle & cancel/replace, position close/liquidate/exercise, and account/watchlist/calendar details | Load before placing, replacing, or canceling orders; closing or exercising positions; or whenever a call returns an unexpected HTTP status or error code |
<!-- END:skill-references-table -->