Set Up OpenClaw with Alpaca (Stocks, Options, and Crypto)
Blog

Set Up OpenClaw with Alpaca (Stocks, Options, and Crypto)

Alpaca is an API-first US brokerage with commission-free stocks and ETFs, options, and crypto, plus a free paper trading sandbox that mirrors the live API exactly. That sandbox makes it the safest broker to hand an AI agent, because your agent can place a hundred orders and lose zero real dollars while you learn how it behaves. This guide walks the full setup on OpenClaw Direct: provision an isolated Instance, generate paper keys, wire the official Alpaca MCP, and attach a persistent safety skill with per-trade caps and a symbol whitelist. You run entirely on paper first, then add Telegram trade approvals, then promote to a small live account only once the agent has earned it. It also covers day-trading and intraday-margin limits for agents (as FINRA phases out the PDT rule) and the layered kill switches that stop a misbehaving agent fast.

TL;DR
  • Alpaca is an API-first US brokerage: commission-free stocks and ETFs, options, and crypto, with a first-class REST/WebSocket API.
  • Its free paper trading environment mirrors the live API exactly, so you can exercise the whole agent stack on fake money before risking a cent.
  • Setup: sign up for OpenClaw Direct, generate paper (not live) keys, store them scoped in the vault, and wire the official alpacahq/alpaca-mcp-server.
  • Attach a persistent safety skill with per-trade caps, a symbol whitelist, an intraday-margin-aware day-trade throttle, and a paper-keys-only rule.
  • Graduate deliberately: run on paper for days, add Telegram trade approvals, then go live with a tiny position in a liquid name.
  • Kill switches layer up: suspend the Instance from any browser, revoke the API keys at Alpaca, and stay on paper keys through the whole learning phase.
OpenClaw Direct Team ·

Alpaca is the broker developers reach for when they want to point code at the US market, and that makes it the natural first home for a trading agent. It's an API-first brokerage with commission-free stocks and ETFs, options, and crypto — but the feature that matters most for an AI agent is the one that costs nothing: a free paper trading environment with the exact same API as live, running on fake money. That's a real on-ramp. You can wire up the whole stack, watch your OpenClaw agent place a hundred orders, and lose precisely zero dollars while you learn how it behaves. This guide walks the full setup: sign up for OpenClaw Direct, generate paper keys, wire an Alpaca MCP, bolt on a safety skill, and only then graduate, deliberately, toward real money.

Why an Always-On Market Needs a Hosted Agent

Here's the thing an agent changes about Alpaca: it removes the human from the loop, and a market doesn't wait for you to open your laptop. US equities trade during market hours, but Alpaca crypto trades 24/7 — around the clock, every day, including the 3am when your machine went to sleep. An agent built to watch that market only helps if it's actually watching. A bot that runs when your laptop is awake is a bot that misses the move that mattered.

So where should that agent live? Not on your laptop. Your personal machine sleeps, reboots for updates, drops off Wi-Fi at cafes, and keeps your API keys in a config file sitting next to your browser. None of that is acceptable for software that can place orders against a brokerage account. The failure modes aren't hypothetical — they're Tuesday.

OpenClaw Direct runs every agent on its own dedicated machine, isolated from every other user, with your Alpaca keys encrypted at rest inside the platform's credential vault instead of a plaintext file on your disk. The infrastructure holds 99.9% uptime with 24/7 monitoring, so the agent keeps watching a market that never fully rests, and you can suspend or terminate it from any browser on any device. For a program that talks to real money, that's the right amount of surface area — and the right size of blast radius when something goes wrong.

What Is Alpaca, and How Do Agents Plug Into It?

Alpaca is a US brokerage built API-first: instead of a mobile app with an API bolted on, the API is the product. It offers commission-free trading in stocks and ETFs, options, and crypto, all reachable through a clean REST and WebSocket interface. Developers picked it long before AI agents existed, which means the surface an agent needs — order placement, positions, account data, market data — is mature and well-documented rather than reverse-engineered.

For an AI agent, the connection point is an MCP server that wraps Alpaca's API and exposes its actions as tools your agent can call in plain language. You reach Alpaca either directly through its API or through an MCP that fronts it — Alpaca publishes an official open-source MCP server (alpacahq/alpaca-mcp-server) that covers account info, positions, stock and options orders, and market data. Whichever route you take, the pattern is the one from our MCP explainer: one server, a menu of tools, a standard handshake. The agent connects, sees the tools it's allowed to call, and, for now, shouldn't call the trading ones at all.

This is a very different feel from a retail app like Robinhood, where the agentic account is a consumer-facing product with guardrails baked into the account itself (we cover that flow in setting up OpenClaw with Robinhood). Alpaca hands you the raw API and trusts you to build the guardrails. That's more power and more responsibility — which is exactly why the paper environment matters so much.

Paper Trading: Alpaca's Best Safety Feature

This is the step that makes Alpaca the safest broker to hand an agent, so internalize it before you touch a live key. Alpaca gives every account a free paper trading environment: identical API, identical order types, identical market data — fake money. Your agent can't tell it isn't live, which is precisely the point. Every mistake it's going to make, it makes here first, for free.

The practical difference is a separate set of keys and a separate base URL. Paper keys point at Alpaca's paper endpoint; live keys point at the real one. The API calls are otherwise the same, so code — and an agent — written against paper runs unchanged against live. That means you get to exercise the entire stack end to end, MCP and safety skill and Telegram approvals included, with the worst-case outcome being a fake loss and a lesson.

Treat paper as a gate, not a formality. The temptation is to skim a day of paper trading and flip to live because the returns looked good. Resist it. Paper trading is where you find out that your agent over-trades on choppy days, or misreads a limit order, or wants to buy something absurd it saw trending. Those discoveries are cheap now and expensive later. Run it long enough that its behavior stops surprising you.

What Can Your Agent Actually Do — and What Should It Not?

Through an Alpaca MCP, an agent can read your full account (buying power, positions, open orders, PnL) and act on it: place market and limit orders in stocks, ETFs, options, and crypto, and manage or close positions. The read side is nearly free and nearly risk-free. The trade side is where a careless agent turns a bad idea into a filled order. Respect that gradient, and walk it from left to right.

  • Read and analyze (paper or live). Pull positions, scan market data, check buying power, and write a brief on what it would do. Start — and stay a while — here.
  • Trade on paper. Let it place real order flow against fake money. This is where it earns your trust, or shows you it hasn't yet.
  • Small live stock and ETF orders. A modest position in a liquid, blue-chip name is the right first live action once paper looks sane.
  • Options. Defined-risk, income-style strategies — see our covered-call income skill for a concrete starting point — before anything with open-ended risk. Options add assignment, expiry, and leverage-like payoffs the agent must reason about.

One equities-specific consideration before you scale up frequency: the pattern day trader (PDT) rule historically capped margin day-trading. FINRA has since retired it — Alpaca replaced the old $25,000-and-round-trip regime with a real-time intraday margin framework on June 4, 2026, and other brokers are phasing the change in through 2027 — but an over-eager agent can still trip live intraday margin and buying-power limits, and orders that would create a margin deficit are now rejected pre-trade. Cap its activity deliberately. The safety skill in the next section is where all of these limits live.

The Setup, Step by Step

Step One: Sign Up for OpenClaw Direct and Provision Your Instance

Go to openclaw.direct/users/sign_up and create an account. The Advanced plan ($29/month, "Most Popular") is the right starting point for trading workloads — 4 GB of dedicated RAM and unlimited AI models, so you're not rationing calls while your agent watches the market. Every subscription includes free trial credits, enough to wire the whole thing up and watch a stack of paper orders fill before you commit a cent. Create a new Instance, name it something like "Alpaca Agent," and click "Start Provisioning." While it builds, move to Step Two.

Step Two: Generate Alpaca Paper Trading Keys (Not Live)

Log in to Alpaca and open the dashboard. Switch to the paper trading environment first — this is the whole safety strategy, so do it deliberately — and generate an API key and secret there. These paper keys point at Alpaca's paper endpoint and control nothing but fake money, which makes them the perfect credential to hand a brand-new agent. Copy the key and secret; you'll paste them into OpenClaw Direct in Step Three. Leave your live keys ungenerated for now. There is no reason for a live key to exist until your agent has earned one on paper.

Step Three: Wire the Alpaca MCP Into Your Instance

With your Instance provisioned, add the Alpaca MCP to its server list — Alpaca's official alpaca-mcp-server is the straightforward choice. Supply the paper key and secret from Step Two, which get stored in the OpenClaw Direct credential vault, scoped to your Instance and never written to a personal disk. Point the agent at the MCP. The MCP is model-agnostic, so you're not locked to one provider — use whichever model you already trust. Once connected, your agent can see the Alpaca tools it's allowed to call. It just shouldn't call the trading ones until Step Four is in place.

Step Four: Attach a Safety Skill (Don't Skip This)

Wiring the MCP gives your agent the capability to trade. It does not give it the judgment to trade well. Before it places a single order, attach a small persistent safety skill to your Instance from the Skills card. A sensible Alpaca starting set:

  • A per-trade notional cap and a rolling daily volume cap.
  • A symbol whitelist — only the tickers you actually want traded (say SPY, QQQ, AAPL), nothing the agent found trending.
  • A day-trade throttle that respects your account's day-trading and intraday margin limits. (FINRA's PDT rule is being retired in favor of real-time intraday margin — Alpaca switched on June 4, 2026 — but buying-power limits can still reject orders, so the agent shouldn't trade its way into one.)
  • A hard rule that the agent uses paper keys only until you explicitly promote it, and never touches a live key on its own.
  • A rule to read buying power and open positions before every action, to avoid over-committing or stacking positions.

This lives in a skill, not a chat instruction, because chat instructions vanish when the agent's memory is compacted — persistent rules belong in persistent files. A skill survives every conversation, restart, and model swap. Our safety rails hub collects the full set of guardrails worth layering in; treat the list above as the floor, not the ceiling.

Step Five: Run on Paper, Then Add Approvals, Then Go Small and Live

Give your agent a bounded first task on paper. From the OpenClaw Direct dashboard, ask it to read your paper account, pull current market context, and place a few small paper orders — then report what it did and why. This costs nothing, exercises the MCP end to end, and shows you how the agent reasons and acts before a real dollar is ever at stake. Run that loop for days, not minutes. Sensible behavior on paper is your evidence; anything weird catches a problem while it's still free.

When paper looks boringly consistent, add a human checkpoint before you touch live money. Wire a Telegram approval on every trade so you get a preview — symbol, side, quantity, order type, estimated cost — with confirm and reject buttons before anything routes. Only then generate a live key, store it in the vault, promote the agent in your safety skill, and keep the first real order tiny: a small position in a liquid name. Expand into scheduled strategies with cron only once the plumbing has earned that trust. Never before.

What Happens When Something Goes Wrong

Every serious agentic setup has to answer one question: when your agent does something you don't want, how fast can you stop it? With Alpaca on OpenClaw Direct you have layered kill switches, and the first one is instant.

Your fastest is the OpenClaw Direct dashboard: suspend or terminate the Instance from any browser, on any device. Because the Alpaca keys live in the platform vault rather than on your laptop, killing the Instance means no process can route a new order. Your second is at the broker: regenerate or revoke your API keys in the Alpaca dashboard, and the old credentials stop working no matter what any process tries. And your structural safety net for the entire learning phase is simply that the keys are paper keys — a runaway agent on paper can do nothing but lose imaginary money and teach you something real.

The harder truth is what a kill switch can't undo. An order that already filled is filled; there's no reversing a live trade because you hit the button a second too late. That's why the per-trade caps, the symbol whitelist, and the paper-first discipline in your safety skill do the heavy lifting, and why the size of the live account — not the kill switch — is your real limit on the downside. The rule that matters most stays simple: fund the live account only with money you can lose without rearranging your life, and don't promote off paper until you've earned the right to.

Ready to run an Alpaca agent the safe way?

Start on paper with OpenClaw Direct. Free trial credits included with every subscription.

Run OpenClaw Now

Sources: Alpaca Docs — Paper Trading, Alpaca Docs — Trading API, GitHub — alpacahq/alpaca-mcp-server, Alpaca Docs — Crypto Trading, and FINRA — Day Trading and the Pattern Day Trader Rule.