alpaca-trading-mcp

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Alpaca Trading MCP

Alpaca Trading MCP

Skill by ara.so — MCP Skills collection.
Alpaca MCP Server is an official Model Context Protocol server that enables natural language trading operations through AI assistants. It provides comprehensive access to Alpaca's Trading API for stocks, options, crypto, portfolio management, and real-time market data. Built with FastMCP and OpenAPI, this is a complete v2 rewrite with spec-aligned tooling.
ara.so开发的Skill——属于MCP Skills集合。
Alpaca MCP Server是官方的Model Context Protocol服务器,支持通过AI助手以自然语言执行交易操作。它提供对Alpaca交易API的全面访问,涵盖股票、期权、加密货币、投资组合管理及实时市场数据。基于FastMCP和OpenAPI构建,这是完全重写的v2版本,工具与规范保持一致。

What It Does

功能介绍

  • Market Data Access: Real-time and historical quotes, trades, bars for stocks, crypto, and options
  • Trading Operations: Place market, limit, stop, trailing-stop orders for any supported asset
  • Options Trading: Search contracts, place single/multi-leg strategies, get Greeks and IV
  • Portfolio Management: View account info, positions, buying power, portfolio history
  • Watchlist Management: Create, update, and manage custom watchlists
  • News & Corporate Actions: Access market news and corporate action announcements
  • 市场数据访问:获取股票、加密货币和期权的实时及历史报价、交易记录、K线数据
  • 交易操作:为所有支持的资产下达市价单、限价单、止损单、追踪止损单
  • 期权交易:搜索合约、下达单腿/多腿策略订单、获取希腊值及隐含波动率
  • 投资组合管理:查看账户信息、持仓情况、购买力、投资组合历史
  • 自选股管理:创建、更新和管理自定义自选股列表
  • 资讯与公司行动:获取市场资讯及公司行动公告

Installation

安装步骤

Prerequisites

前置要求

  • Python 3.10+
  • uv package manager:
    curl -LsSf https://astral.sh/uv/install.sh | sh
  • Alpaca API keys (free paper trading account at https://app.alpaca.markets)
  • An MCP-compatible client (Claude Desktop, Cursor, VS Code, etc.)

Configuration

配置

Add to your MCP client configuration file:
Claude Desktop (
~/Library/Application Support/Claude/claude_desktop_config.json
on Mac):
json
{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": ["alpaca-mcp-server"],
      "env": {
        "ALPACA_API_KEY": "your_alpaca_api_key",
        "ALPACA_SECRET_KEY": "your_alpaca_secret_key",
        "ALPACA_PAPER_TRADE": "true"
      }
    }
  }
}
Cursor (
~/.cursor/mcp.json
):
json
{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": ["alpaca-mcp-server"],
      "env": {
        "ALPACA_API_KEY": "your_alpaca_api_key",
        "ALPACA_SECRET_KEY": "your_alpaca_secret_key",
        "ALPACA_PAPER_TRADE": "true"
      }
    }
  }
}
VS Code (
.vscode/mcp.json
in project root):
json
{
  "mcp": {
    "servers": {
      "alpaca": {
        "type": "stdio",
        "command": "uvx",
        "args": ["alpaca-mcp-server"],
        "env": {
          "ALPACA_API_KEY": "your_alpaca_api_key",
          "ALPACA_SECRET_KEY": "your_alpaca_secret_key",
          "ALPACA_PAPER_TRADE": "true"
        }
      }
    }
  }
}
Claude Code CLI:
bash
claude mcp add alpaca --scope user --transport stdio uvx alpaca-mcp-server \
  --env ALPACA_API_KEY=your_alpaca_api_key \
  --env ALPACA_SECRET_KEY=your_alpaca_secret_key \
  --env ALPACA_PAPER_TRADE=true
将以下内容添加到你的MCP客户端配置文件:
Claude Desktop(Mac系统路径:
~/Library/Application Support/Claude/claude_desktop_config.json
):
json
{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": ["alpaca-mcp-server"],
      "env": {
        "ALPACA_API_KEY": "your_alpaca_api_key",
        "ALPACA_SECRET_KEY": "your_alpaca_secret_key",
        "ALPACA_PAPER_TRADE": "true"
      }
    }
  }
}
Cursor(路径:
~/.cursor/mcp.json
):
json
{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": ["alpaca-mcp-server"],
      "env": {
        "ALPACA_API_KEY": "your_alpaca_api_key",
        "ALPACA_SECRET_KEY": "your_alpaca_secret_key",
        "ALPACA_PAPER_TRADE": "true"
      }
    }
  }
}
VS Code(项目根目录下的
.vscode/mcp.json
):
json
{
  "mcp": {
    "servers": {
      "alpaca": {
        "type": "stdio",
        "command": "uvx",
        "args": ["alpaca-mcp-server"],
        "env": {
          "ALPACA_API_KEY": "your_alpaca_api_key",
          "ALPACA_SECRET_KEY": "your_alpaca_secret_key",
          "ALPACA_PAPER_TRADE": "true"
        }
      }
    }
  }
}
Claude Code CLI
bash
claude mcp add alpaca --scope user --transport stdio uvx alpaca-mcp-server \
  --env ALPACA_API_KEY=your_alpaca_api_key \
  --env ALPACA_SECRET_KEY=your_alpaca_secret_key \
  --env ALPACA_PAPER_TRADE=true

Environment Variables

环境变量

VariableRequiredDefaultDescription
ALPACA_API_KEY
YesYour Alpaca API key
ALPACA_SECRET_KEY
YesYour Alpaca secret key
ALPACA_PAPER_TRADE
No
true
Set to
false
for live trading
ALPACA_TOOLSETS
NoallComma-separated toolsets to enable
变量名是否必填默认值描述
ALPACA_API_KEY
你的Alpaca API密钥
ALPACA_SECRET_KEY
你的Alpaca密钥
ALPACA_PAPER_TRADE
true
设置为
false
启用实盘交易
ALPACA_TOOLSETS
all启用的工具集,以逗号分隔

Toolset Filtering

工具集过滤

Restrict available tools by setting
ALPACA_TOOLSETS
:
json
{
  "env": {
    "ALPACA_TOOLSETS": "account,trading,stock-data"
  }
}
Available toolsets:
  • account
    : Account info, portfolio history, activities
  • trading
    : Orders, positions, options exercise
  • watchlists
    : Watchlist CRUD operations
  • assets
    : Asset lookup, option contracts, market calendar
  • stock-data
    : Stock bars, quotes, trades, snapshots
  • crypto-data
    : Crypto bars, quotes, trades, orderbooks
  • options-data
    : Option bars, quotes, Greeks, chain
  • corporate-actions
    : Corporate action announcements
  • news
    : News articles
通过设置
ALPACA_TOOLSETS
限制可用工具:
json
{
  "env": {
    "ALPACA_TOOLSETS": "account,trading,stock-data"
  }
}
可用工具集:
  • account
    :账户信息、投资组合历史、交易活动
  • trading
    :订单、持仓、期权行权
  • watchlists
    :自选股增删改查操作
  • assets
    :资产查询、期权合约、市场日历
  • stock-data
    :股票K线、报价、交易记录、快照
  • crypto-data
    :加密货币K线、报价、交易记录、订单簿
  • options-data
    :期权K线、报价、希腊值、合约链
  • corporate-actions
    :公司行动公告
  • news
    :资讯文章

Core Trading Operations

核心交易操作

Check Account Status

查看账户状态

python
undefined
python
undefined

Natural language prompts:

自然语言指令示例:

"What's my current account balance?"

"我当前的账户余额是多少?"

"Show my buying power"

"显示我的可用购买力"

"Am I approved for options trading?"

"我是否已开通期权交易权限?"

The MCP server exposes get_account_info tool

MCP服务器暴露get_account_info工具

Returns: account_number, status, buying_power, cash, portfolio_value, etc.

返回内容:account_number、status、buying_power、cash、portfolio_value等

undefined
undefined

Place Stock Orders

下达股票订单

python
undefined
python
undefined

Natural language prompts:

自然语言指令示例:

"Buy 100 shares of AAPL at market price"

"以市价买入100股AAPL"

"Place a limit order to buy TSLA at $250"

"下达限价单,以250美元买入TSLA"

"Sell 50 shares of NVDA with a trailing stop at 2%"

"以2%的追踪止损卖出50股NVDA"

Market order

市价单

Tool: post_orders

工具:post_orders

Parameters: {

参数:{

"symbol": "AAPL",

"symbol": "AAPL",

"qty": 100,

"qty": 100,

"side": "buy",

"side": "buy",

"type": "market",

"type": "market",

"time_in_force": "day"

"time_in_force": "day"

}

}

Limit order

限价单

Parameters: {

参数:{

"symbol": "TSLA",

"symbol": "TSLA",

"qty": 10,

"qty": 10,

"side": "buy",

"side": "buy",

"type": "limit",

"type": "limit",

"limit_price": 250.00,

"limit_price": 250.00,

"time_in_force": "gtc"

"time_in_force": "gtc"

}

}

Trailing stop

追踪止损单

Parameters: {

参数:{

"symbol": "NVDA",

"symbol": "NVDA",

"qty": 50,

"qty": 50,

"side": "sell",

"side": "sell",

"type": "trailing_stop",

"type": "trailing_stop",

"trail_percent": 2.0,

"trail_percent": 2.0,

"time_in_force": "gtc"

"time_in_force": "gtc"

}

}

undefined
undefined

Get Real-Time Market Data

获取实时市场数据

python
undefined
python
undefined

Natural language prompts:

自然语言指令示例:

"What's the current price of AAPL?"

"AAPL当前价格是多少?"

"Show me the latest BTC quote"

"显示BTC最新报价"

"Get today's price bars for MSFT in 5-minute intervals"

"获取MSFT今日5分钟间隔的K线数据"

Latest quote

最新报价

Tool: get_stocks_quotes_latest

工具:get_stocks_quotes_latest

Parameters: {"symbols": "AAPL,MSFT,GOOGL"}

参数:{"symbols": "AAPL,MSFT,GOOGL"}

Crypto quote

加密货币报价

Tool: get_crypto_quotes_latest

工具:get_crypto_quotes_latest

Parameters: {"symbols": "BTC/USD,ETH/USD"}

参数:{"symbols": "BTC/USD,ETH/USD"}

Historical bars

历史K线

Tool: get_stocks_bars

工具:get_stocks_bars

Parameters: {

参数:{

"symbols": "MSFT",

"symbols": "MSFT",

"timeframe": "5Min",

"timeframe": "5Min",

"start": "2025-05-01T09:30:00Z",

"start": "2025-05-01T09:30:00Z",

"end": "2025-05-01T16:00:00Z"

"end": "2025-05-01T16:00:00Z"

}

}

undefined
undefined

Options Trading

期权交易

python
undefined
python
undefined

Natural language prompts:

自然语言指令示例:

"Find call options for AAPL expiring next month"

"查找AAPL下月到期的看涨期权"

"Place a covered call on my 100 shares of NVDA"

"为我的100股NVDA备兑看涨期权"

"Get the Greeks for SPY 500 calls expiring this Friday"

"获取SPY 500本周到期看涨期权的希腊值"

Search option contracts

搜索期权合约

Tool: get_options_contracts

工具:get_options_contracts

Parameters: {

参数:{

"underlying_symbols": "AAPL",

"underlying_symbols": "AAPL",

"expiration_date_gte": "2025-06-01",

"expiration_date_gte": "2025-06-01",

"expiration_date_lte": "2025-06-30",

"expiration_date_lte": "2025-06-30",

"type": "call"

"type": "call"

}

}

Place option order

下达期权订单

Tool: post_orders

工具:post_orders

Parameters: {

参数:{

"symbol": "AAPL250620C00150000",

"symbol": "AAPL250620C00150000",

"qty": 1,

"qty": 1,

"side": "sell_to_open",

"side": "sell_to_open",

"type": "limit",

"type": "limit",

"limit_price": 5.50,

"limit_price": 5.50,

"time_in_force": "day",

"time_in_force": "day",

"class": "option"

"class": "option"

}

}

Get option snapshot with Greeks

获取带希腊值的期权快照

Tool: get_options_snapshots

工具:get_options_snapshots

Parameters: {"symbols": "SPY250516C00500000"}

参数:{"symbols": "SPY250516C00500000"}

Returns: greeks (delta, gamma, theta, vega), implied_volatility, latest_quote

返回内容:greeks(delta、gamma、theta、vega)、implied_volatility、latest_quote

undefined
undefined

Manage Positions

持仓管理

python
undefined
python
undefined

Natural language prompts:

自然语言指令示例:

"Show all my open positions"

"显示我所有的未平仓头寸"

"What's my position in AAPL?"

"我持有多少AAPL?"

"Close half of my TSLA position"

"平掉一半的TSLA持仓"

Get all positions

获取所有持仓

Tool: get_positions

工具:get_positions

Get specific position

获取特定持仓

Tool: get_positions_by_symbol_or_asset_id

工具:get_positions_by_symbol_or_asset_id

Parameters: {"symbol_or_asset_id": "AAPL"}

参数:{"symbol_or_asset_id": "AAPL"}

Close position

平仓

Tool: delete_positions_by_symbol_or_asset_id

工具:delete_positions_by_symbol_or_asset_id

Parameters: {

参数:{

"symbol_or_asset_id": "TSLA",

"symbol_or_asset_id": "TSLA",

"percentage": 50 # Optional: close percentage

"percentage": 50 # 可选:平仓比例

}

}

undefined
undefined

Watchlist Management

自选股管理

python
undefined
python
undefined

Natural language prompts:

自然语言指令示例:

"Create a tech stocks watchlist with AAPL, MSFT, GOOGL"

"创建包含AAPL、MSFT、GOOGL的科技股自选股列表"

"Add TSLA to my tech watchlist"

"把TSLA添加到我的科技股自选股"

"Show me all my watchlists"

"显示我所有的自选股列表"

Create watchlist

创建自选股

Tool: post_watchlists

工具:post_watchlists

Parameters: {

参数:{

"name": "Tech Stocks",

"name": "Tech Stocks",

"symbols": ["AAPL", "MSFT", "GOOGL"]

"symbols": ["AAPL", "MSFT", "GOOGL"]

}

}

Get all watchlists

获取所有自选股

Tool: get_watchlists

工具:get_watchlists

Add symbol to watchlist

向自选股添加标的

Tool: post_watchlists_by_watchlist_id

工具:post_watchlists_by_watchlist_id

Parameters: {

参数:{

"watchlist_id": "uuid-here",

"watchlist_id": "uuid-here",

"symbol": "TSLA"

"symbol": "TSLA"

}

}

undefined
undefined

Advanced Market Data Queries

高级市场数据查询

Screen Stocks

股票筛选

python
undefined
python
undefined

Natural language prompts:

自然语言指令示例:

"Find the most active stocks today"

"找出今日成交量最高的股票"

"Show me top gainers with volume over 1M"

"显示成交量超过100万的涨幅榜"

Tool: get_screener_stocks_most_actives

工具:get_screener_stocks_most_actives

Parameters: {

参数:{

"by": "volume",

"by": "volume",

"top": 10

"top": 10

}

}

Tool: get_screener_stocks_movers

工具:get_screener_stocks_movers

Parameters: {

参数:{

"market_type": "stocks",

"market_type": "stocks",

"top": 20

"top": 20

}

}

undefined
undefined

Get News

获取资讯

python
undefined
python
undefined

Natural language prompts:

自然语言指令示例:

"Show me latest news about AAPL"

"显示AAPL的最新资讯"

"Get crypto news for Bitcoin"

"获取比特币的加密货币资讯"

Stock news

股票资讯

Tool: get_news

工具:get_news

Parameters: {

参数:{

"symbols": "AAPL",

"symbols": "AAPL",

"limit": 10,

"limit": 10,

"sort": "desc"

"sort": "desc"

}

}

Crypto news

加密货币资讯

Tool: get_crypto_news

工具:get_crypto_news

Parameters: {

参数:{

"symbols": "BTC",

"symbols": "BTC",

"limit": 10

"limit": 10

}

}

undefined
undefined

Corporate Actions

公司行动

python
undefined
python
undefined

Natural language prompts:

自然语言指令示例:

"Are there any upcoming stock splits?"

"近期有哪些股票拆分计划?"

"Show dividend announcements for next week"

"显示下周的股息公告"

Tool: get_corporate_actions_announcements

工具:get_corporate_actions_announcements

Parameters: {

参数:{

"ca_types": "dividend,split",

"ca_types": "dividend,split",

"since": "2025-05-01",

"since": "2025-05-01",

"until": "2025-05-31"

"until": "2025-05-31"

}

}

undefined
undefined

Portfolio Analysis

投资组合分析

Get Portfolio History

获取投资组合历史

python
undefined
python
undefined

Natural language prompts:

自然语言指令示例:

"Show my portfolio performance over the last month"

"显示我过去一个月的投资组合表现"

"Graph my portfolio value for the past year"

"绘制我过去一年的投资组合价值走势"

Tool: get_account_portfolio_history

工具:get_account_portfolio_history

Parameters: {

参数:{

"period": "1M",

"period": "1M",

"timeframe": "1D"

"timeframe": "1D"

}

}

Returns: timestamp, equity, profit_loss, profit_loss_pct arrays

返回内容:timestamp、equity、profit_loss、profit_loss_pct数组

undefined
undefined

Account Activities

账户活动

python
undefined
python
undefined

Natural language prompts:

自然语言指令示例:

"Show my recent trades"

"显示我最近的交易记录"

"List all dividend payments this month"

"列出本月所有的股息支付"

Tool: get_account_activities

工具:get_account_activities

Parameters: {

参数:{

"activity_types": "FILL,DIV",

"activity_types": "FILL,DIV",

"after": "2025-05-01T00:00:00Z",

"after": "2025-05-01T00:00:00Z",

"direction": "desc"

"direction": "desc"

}

}

undefined
undefined

Common Patterns

常见使用模式

Multi-Symbol Quotes

多标的报价

python
undefined
python
undefined

Get quotes for multiple symbols at once

同时获取多个标的的报价

"Get current prices for AAPL, MSFT, GOOGL, AMZN"

"获取AAPL、MSFT、GOOGL、AMZN的当前价格"

Tool: get_stocks_quotes_latest

工具:get_stocks_quotes_latest

Parameters: {"symbols": "AAPL,MSFT,GOOGL,AMZN"}

参数:{"symbols": "AAPL,MSFT,GOOGL,AMZN"}

Use feed parameter for realtime: "feed": "sip"

使用feed参数获取实时数据:"feed": "sip"

undefined
undefined

Batch Order Placement

批量下单

python
undefined
python
undefined

Place multiple orders together

同时下达多个订单

"Buy 10 shares each of AAPL, MSFT, GOOGL at market"

"以市价各买入10股AAPL、MSFT、GOOGL"

Call post_orders tool 3 times or use a loop pattern

调用post_orders工具3次或使用循环模式

Each order is submitted individually through the API

每个订单通过API单独提交

undefined
undefined

Conditional Order Logic

条件订单逻辑

python
undefined
python
undefined

Complex strategies require multiple steps

复杂策略需要多步骤执行

"If AAPL drops below $150, buy 100 shares"

"如果AAPL跌破150美元,买入100股"

1. Monitor current price with get_stocks_quotes_latest

1. 使用get_stocks_quotes_latest监控当前价格

2. When condition met, call post_orders

2. 满足条件时调用post_orders

Note: Alpaca supports bracket/OCO orders natively:

注意:Alpaca原生支持括号单/OCO订单:

Use order_class: "bracket" with take_profit and stop_loss

使用order_class: "bracket"并设置take_profit和stop_loss

undefined
undefined

Options Strategies

期权策略

python
undefined
python
undefined

Multi-leg options spreads

多腿期权价差

"Create a bull call spread on SPY"

"创建SPY的牛市看涨价差"

Tool: post_orders with order_class: "multileg"

工具:post_orders,设置order_class: "multileg"

Parameters: {

参数:{

"symbol": "SPY",

"symbol": "SPY",

"type": "limit",

"type": "limit",

"time_in_force": "day",

"time_in_force": "day",

"order_class": "multileg",

"order_class": "multileg",

"legs": [

"legs": [

{"symbol": "SPY250620C00500000", "side": "buy_to_open", "qty": 1},

{"symbol": "SPY250620C00500000", "side": "buy_to_open", "qty": 1},

{"symbol": "SPY250620C00510000", "side": "sell_to_open", "qty": 1}

{"symbol": "SPY250620C00510000", "side": "sell_to_open", "qty": 1}

]

]

}

}

undefined
undefined

Troubleshooting

故障排查

Server Not Showing in MCP Client

MCP客户端中未显示服务器

  1. Restart your MCP client after editing config
  2. Check JSON syntax in your config file (trailing commas cause issues)
  3. Verify uv is installed:
    uv --version
  4. Check logs in client's developer console/logs
  1. 编辑配置后重启MCP客户端
  2. 检查配置文件的JSON语法(尾随逗号会导致问题)
  3. 验证uv已安装
    uv --version
  4. 查看客户端开发者控制台/日志

Authentication Errors

认证错误

Error: 401 Unauthorized
  • Verify
    ALPACA_API_KEY
    and
    ALPACA_SECRET_KEY
    are correct
  • Ensure you're using paper trading keys if
    ALPACA_PAPER_TRADE=true
  • Check if keys have necessary permissions in Alpaca dashboard
Error: 401 Unauthorized
  • 验证
    ALPACA_API_KEY
    ALPACA_SECRET_KEY
    是否正确
  • 如果
    ALPACA_PAPER_TRADE=true
    ,确保使用的是模拟交易密钥
  • 在Alpaca控制台检查密钥是否具备必要权限

Tool Not Found

工具未找到

Error: Tool 'old_tool_name' not found
  • You may be using v1 tool names. V2 is a complete rewrite.
  • Clear MCP client cache and restart
  • Start a fresh chat session
  • Check Available Tools for current tool names
Error: Tool 'old_tool_name' not found
  • 你可能在使用v1版本的工具名称。v2是完全重写版本。
  • 清除MCP客户端缓存并重启
  • 开启新的会话
  • 查看可用工具获取当前工具名称

Rate Limiting

速率限制

Error: 429 Too Many Requests
  • Alpaca API has rate limits (200 requests/minute for paper trading)
  • Batch symbol queries when possible (comma-separated symbols)
  • Add delays between rapid tool calls
  • Upgrade to live account for higher limits
Error: 429 Too Many Requests
  • Alpaca API有速率限制(模拟交易为每分钟200次请求)
  • 尽可能批量查询标的(以逗号分隔)
  • 在频繁调用工具之间添加延迟
  • 升级到实盘账户获取更高限制

Order Rejected

订单被拒绝

Error: insufficient buying power / position limit exceeded
  • Check account buying power:
    get_account_info
  • Verify position limits haven't been hit
  • For options, ensure account has appropriate trading level
  • Check if market is open:
    get_clock
Error: insufficient buying power / position limit exceeded
  • 查看账户购买力:
    get_account_info
  • 验证是否已达到持仓限制
  • 期权交易需确保账户具备相应交易等级
  • 检查市场是否开盘:
    get_clock

Market Data Gaps

市场数据缺失

Error: no data found for timeframe
  • Market may be closed (check
    get_clock
    )
  • Symbol may not have data for requested timeframe
  • Use
    feed: "sip"
    for consolidated US market data
  • Crypto trades 24/7, stocks only during market hours (9:30-16:00 ET)
Error: no data found for timeframe
  • 市场可能已休市(检查
    get_clock
  • 标的可能没有请求时间范围内的数据
  • 使用
    feed: "sip"
    获取美国市场合并数据
  • 加密货币24小时交易,股票仅在交易时段(美国东部时间9:30-16:00)交易

V1 to V2 Migration

V1到V2迁移

If upgrading from v1:
  1. Remove any .env files — v2 uses env vars in MCP config only
  2. Delete v1 tool references in custom instructions/rules
  3. Restart MCP client to clear tool cache
  4. Start fresh session so LLM discovers new tools
  5. Update toolset filtering using
    ALPACA_TOOLSETS
    env var
如果从v1版本升级:
  1. 删除所有.env文件——v2仅在MCP配置中使用环境变量
  2. 删除自定义指令/规则中的v1工具引用
  3. 重启MCP客户端清除工具缓存
  4. 开启新会话让LLM发现新工具
  5. 使用
    ALPACA_TOOLSETS
    环境变量更新工具集过滤

Docker Issues

Docker问题

bash
undefined
bash
undefined

If server fails to start in Docker

如果Docker中服务器启动失败

docker logs <container-id>
docker logs <container-id>

Check environment variables are passed

检查环境变量是否已传递

docker run --rm -e ALPACA_API_KEY=test mcp/alpaca:latest env | grep ALPACA
docker run --rm -e ALPACA_API_KEY=test mcp/alpaca:latest env | grep ALPACA

Test connection manually

手动测试连接

docker run --rm -i
-e ALPACA_API_KEY=your_key
-e ALPACA_SECRET_KEY=your_secret
-e ALPACA_PAPER_TRADE=true
mcp/alpaca:latest
undefined
docker run --rm -i
-e ALPACA_API_KEY=your_key
-e ALPACA_SECRET_KEY=your_secret
-e ALPACA_PAPER_TRADE=true
mcp/alpaca:latest
undefined

Live Trading

实盘交易

To switch from paper to live trading:
json
{
  "env": {
    "ALPACA_API_KEY": "your_live_api_key",
    "ALPACA_SECRET_KEY": "your_live_secret_key",
    "ALPACA_PAPER_TRADE": "false"
  }
}
⚠️ WARNING: Live trading uses real money. Test thoroughly in paper trading first. Markets are volatile and losses can exceed expectations.
从模拟交易切换到实盘交易:
json
{
  "env": {
    "ALPACA_API_KEY": "your_live_api_key",
    "ALPACA_SECRET_KEY": "your_live_secret_key",
    "ALPACA_PAPER_TRADE": "false"
  }
}
⚠️ 警告:实盘交易使用真实资金。请先在模拟交易中充分测试。市场波动剧烈,损失可能超出预期。

Additional Resources

额外资源

License

许可证

MIT License - Alpaca Markets
MIT License - Alpaca Markets