/ Verzeichnis / Playground / Alpaca
● Offiziell alpacahq 🔑 Eigener Schlüssel nötig

Alpaca

von alpacahq · alpacahq/alpaca-mcp-server

Let Claude research, backtest, and place trades on stocks, ETFs, options, and crypto via Alpaca — paper-first so you won't blow up your account.

Alpaca's official MCP wraps the Alpaca Trading and Market Data APIs. Pull quotes, bars, fundamentals, and positions; place/modify/cancel orders. Defaults to paper trading, which is exactly how you should learn this. Flip to live only once a strategy is proven.

Warum nutzen

Hauptfunktionen

Live-Demo

In der Praxis

alpaca.replay ▶ bereit
0/0

Installieren

Wählen Sie Ihren Client

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": [
        "alpaca-mcp-server"
      ]
    }
  }
}

Öffne Claude Desktop → Settings → Developer → Edit Config. Nach dem Speichern neu starten.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": [
        "alpaca-mcp-server"
      ]
    }
  }
}

Cursor nutzt das gleiche mcpServers-Schema wie Claude Desktop. Projektkonfiguration schlägt die globale.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": [
        "alpaca-mcp-server"
      ]
    }
  }
}

Klicken Sie auf das MCP-Servers-Symbol in der Cline-Seitenleiste, dann "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": [
        "alpaca-mcp-server"
      ]
    }
  }
}

Gleiche Struktur wie Claude Desktop. Windsurf neu starten zum Übernehmen.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "alpaca",
      "command": "uvx",
      "args": [
        "alpaca-mcp-server"
      ]
    }
  ]
}

Continue nutzt ein Array von Serverobjekten statt einer Map.

~/.config/zed/settings.json
{
  "context_servers": {
    "alpaca": {
      "command": {
        "path": "uvx",
        "args": [
          "alpaca-mcp-server"
        ]
      }
    }
  }
}

In context_servers hinzufügen. Zed lädt beim Speichern neu.

claude mcp add alpaca -- uvx alpaca-mcp-server

Einzeiler. Prüfen mit claude mcp list. Entfernen mit claude mcp remove.

Anwendungsfälle

Praxisnahe Nutzung: Alpaca

Generate a daily pre-market brief for your watchlist

👤 Active retail traders ⏱ ~10 min beginner

Wann einsetzen: You want a 30-second morning check on your 20 tickers before the open — overnight moves, earnings, obvious news.

Voraussetzungen
  • Alpaca account (free paper) — alpaca.markets → sign up → API keys on the dashboard
  • Watchlist of symbols — Plain list like [AAPL, MSFT, NVDA, ...]
Ablauf
  1. Pull overnight bar data
    For my watchlist [symbols], get yesterday's close and the latest pre-market quote. Compute % gap.✓ Kopiert
    → Table: symbol, prev_close, pre_open, gap_pct
  2. Flag outliers
    Which tickers are gapping more than 2% in either direction? Rank by gap magnitude.✓ Kopiert
    → Short 'needs attention' list
  3. Add context
    For each outlier, pull the latest news headlines from Alpaca news endpoint.✓ Kopiert
    → Per-ticker bullet with likely cause

Ergebnis: A 1-screen daily pre-market brief, same shape every day, no manual clicking.

Fallstricke
  • Free market data is IEX-only and lags; quotes may not match your broker — Fine for overnight/EOD analysis; if you need SIP feed, upgrade to Alpaca's paid data plan
Kombinieren mit: notion

Paper-trade a simple rules-based strategy

👤 Algo-trading beginners ⏱ ~30 min intermediate

Wann einsetzen: You have a rule like 'buy SPY when 5-day return < -3%, sell after +2% or 5 trading days' and want to run it live on paper money.

Voraussetzungen
  • Paper account keys configured — Use APCA_API_BASE_URL=https://paper-api.alpaca.markets
  • A written rule — Entry, exit, position size, max loss — all explicit before coding anything
Ablauf
  1. Check account and positions
    Show my paper account equity, buying power, and current open positions.✓ Kopiert
    → Clean account snapshot
  2. Evaluate entry condition today
    Get SPY's last 5 daily bars. Compute 5-day return. If it's < -3% and I don't already hold SPY, place a market buy for $5000 notional. Otherwise do nothing.✓ Kopiert
    → Either an order id or an explicit 'no action'
  3. Log today's decision
    Append a row to /trades/journal.csv: date, condition_met, action, order_id, fill_price.✓ Kopiert
    → Journal row written

Ergebnis: An auditable daily run of a simple strategy against paper money, with a journal you can review.

Fallstricke
  • Accidentally running against live keys during testing — Keep a very obvious check at the start: confirm the account number matches your paper account before placing any order
  • Claude forgets yesterday's position and double-buys — Always fetch current positions before evaluating entry; never rely on memory
Kombinieren mit: filesystem

Rebalance a portfolio to target allocations

👤 DIY investors with a target allocation ⏱ ~20 min intermediate

Wann einsetzen: Quarterly: bring 60/30/10 (US/INTL/bonds) back to target without manually computing share counts.

Voraussetzungen
  • Target allocation defined — e.g. VTI 60%, VXUS 30%, BND 10%
Ablauf
  1. Measure drift
    Get my positions and current prices. Compute current weight per symbol vs target [paste targets]. Show drift in $ and %.✓ Kopiert
    → Per-symbol drift table
  2. Propose trades
    Propose the minimum set of buys/sells to bring weights within 1% of target. Show expected commissions (likely $0) and estimated slippage.✓ Kopiert
    → Order plan
  3. Execute with confirmation
    Before placing: summarize the plan in 3 lines and wait for my 'yes'. On yes, submit as market-on-open orders.✓ Kopiert
    → Orders placed with ids; equity matches target within 1%

Ergebnis: A clean quarterly rebalance with a written record of why each trade happened.

Fallstricke
  • Taxable account: every rebalance triggers gains/losses — Prefer new-contribution rebalancing or tax-lot-aware exits; run only in IRA if unsure
Kombinieren mit: filesystem

Scan an options chain for short-dated put premium

👤 Option income traders (cash-secured puts / covered calls) ⏱ ~25 min advanced

Wann einsetzen: You want to find the best cash-secured put to sell on tickers you'd be happy to own, weekly.

Voraussetzungen
  • Options-enabled Alpaca account — Enable in account settings; paper works for learning
Ablauf
  1. Fetch chain + greeks
    Get the options chain for [ticker] expiring next Friday, puts only, strikes within 5% of spot. Include bid, ask, mid, delta, IV.✓ Kopiert
    → Chain table
  2. Rank by annualized yield
    Compute annualized return-on-cash for each strike assuming assignment. Filter delta between -0.15 and -0.30. Rank top 5.✓ Kopiert
    → Ranked short list
  3. Place sell-to-open with a limit at mid
    Place a sell-to-open limit order for 1 contract of the #1 strike at the mid. GTC, day-only.✓ Kopiert
    → Order id returned

Ergebnis: A repeatable weekly income routine with a conservative risk screen.

Fallstricke
  • Selling puts on companies you wouldn't want to own — Hard rule: only trade this strategy on 10 tickers you've pre-approved as long-term holds
  • Illiquid strikes with huge bid-ask — fills never happen at mid — Filter for open_interest > 500 and spread < 5% of mid before ranking
Kombinieren mit: notion

Kombinationen

Mit anderen MCPs für 10-fache Wirkung

alpaca + notion

Daily pre-market brief delivered to a Notion page

Run my pre-market scan for watchlist and create a Notion page in 'Trading / Daily' with the results.✓ Kopiert
alpaca + filesystem

Trade journal: append every order and reason to a local CSV

After any place_order, append {ts, symbol, side, qty, reason} to /trading/journal.csv.✓ Kopiert
alpaca + postgres

Store daily equity curve for backtesting strategies

Every evening, INSERT today's account equity into the equity_curve table.✓ Kopiert

Werkzeuge

Was dieses MCP bereitstellt

WerkzeugEingabenWann aufrufenKosten
get_account First call in any session — confirm you're on paper vs live free
get_positions Check current holdings before any entry logic free
get_bars symbol, timeframe, start, end, limit? Historical OHLCV for analysis and signals free (IEX) or paid (SIP)
get_latest_quote symbol Real-time price before placing an order free
place_order symbol, qty|notional, side, type, time_in_force, limit_price? Submit a new order (always paper-first) free (commission-free)
cancel_order order_id Cancel an open order before it fills free
get_options_chain underlying, expiration, side? Scan strikes for an options strategy free on Alpaca

Kosten & Limits

Was der Betrieb kostet

API-Kontingent
200 req/min on data API (free tier); trading API is effectively unthrottled at retail scale
Tokens pro Aufruf
Account/positions: 200–500 tokens. Bars: scales with limit.
Kosten in €
Alpaca is commission-free. Paid market data plan ~$9/mo for SIP feed; free IEX feed is fine for most retail use.
Tipp
Paper-trade every new strategy for at least 4 weeks before touching live money. It's free.

Sicherheit

Rechte, Secrets, Reichweite

Minimale Scopes: Account API key + secret — Alpaca doesn't have sub-scopes
Credential-Speicherung: APCA_API_KEY_ID, APCA_API_SECRET_KEY, and APCA_API_BASE_URL in env vars
Datenabfluss: All calls to api.alpaca.markets or paper-api.alpaca.markets
Niemals gewähren: Sharing live keys with any third-party service, including code hosts

Fehlerbehebung

Häufige Fehler und Lösungen

403 forbidden.insufficient-permissions

Your keys are for the wrong environment (live vs paper). Match APCA_API_BASE_URL to the key pair.

Prüfen: curl -H 'APCA-API-KEY-ID: ...' -H 'APCA-API-SECRET-KEY: ...' $APCA_API_BASE_URL/v2/account
422 buying_power insufficient

Your paper account reset, or you sized the trade beyond cash. Call get_account and recompute position size.

Bars return empty for recent timestamp

IEX feed has ~15-min delay on free tier, and doesn't serve every symbol. Use SIP or wait.

Order rejected: market closed

Default TIF is day; market-closed orders need time_in_force='opg' or 'cls' or switch to extended hours with extended_hours=true on limit orders.

Alternativen

Alpaca vs. andere

AlternativeWann stattdessenKompromiss
Interactive Brokers MCPYou need international markets or futuresMore complex auth (gateway app required); learning curve
Polygon.io MCPYou only need market data, no tradingNo order execution; paid for full coverage

Mehr

Ressourcen

📖 Offizielle README auf GitHub lesen

🐙 Offene Issues ansehen

🔍 Alle 400+ MCP-Server und Skills durchsuchen