Skip to main content
Glama

Alpaca Trading MCP Server

by laukikk

羊驼交易 MCP 服务器

模型上下文协议 (MCP) 服务器提供 Alpaca 交易 API 的接口,允许您管理股票和加密货币投资组合、进行交易和访问市场数据。

特征

  • 账户管理:查看账户详情、余额和投资组合状态
  • 交易:下达市价单、限价单、止损单和止损限价单
  • 投资组合管理:查看仓位、计算业绩、平仓
  • 市场数据:获取实时报价和历史价格数据
  • 资产信息:获取可交易资产的详细信息

安装

  1. 克隆此存储库
  2. 安装依赖项:
pip install -e .

或者使用 uv:

uv pip install -e .

配置

  1. .env.example文件复制到.env
cp .env.example .env
  1. 将您的 Alpaca Paper Trading API 凭证添加到.env文件:
ALPACA_PAPER_API_KEY = "your-api-key" ALPACA_PAPER_API_SECRET = "your-api-secret"

您可以通过在Alpaca创建帐户来获取这些凭证。

用法

运行 MCP 服务器:

python src/server.py

服务器将启动并可供 MCP 客户端连接。

可用资源

服务器提供以下资源:

  • account://info - 获取当前帐户信息
  • positions://all - 获取所有当前职位
  • positions://{symbol} - 获取特定符号的位置详情
  • orders://recent/{limit} - 获取指定限制的最近订单
  • market://{symbol}/quote - 获取特定符号的当前市场报价
  • market://{symbol}/bars/{timeframe} - 获取指定时间范围内符号的历史价格条
  • assets://list - 列出 Alpaca 上可交易的资产
  • assets://{symbol} - 按符号获取详细资产信息

可用工具

该服务器提供以下工具:

  • get_account_info_tool - 获取当前帐户信息
  • place_market_order - 下达市价单来买入或卖出股票
  • place_limit_order - 下达限价单以指定价格买入或卖出股票
  • place_stop_order - 当股票达到指定价格时,下达买入或卖出的止损订单
  • place_stop_limit_order - 结合止损和限价订单功能,下达止损限价订单
  • cancel_order - 根据订单 ID 取消未结订单
  • close_position - 关闭特定符号的未平仓头寸
  • get_portfolio_summary - 获取投资组合的综合摘要
-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

与 Alpaca 交易 API 接口的模型上下文协议服务器,允许用户通过自然语言交互来管理投资组合、进行交易和访问市场数据。

  1. 特征
    1. 安装
      1. 配置
        1. 用法
          1. 可用资源
            1. 可用工具

              Related MCP Servers

              • A
                security
                A
                license
                A
                quality
                A Model Context Protocol server that provides read-only access to Bybit's cryptocurrency exchange API, allowing users to query real-time cryptocurrency data using natural language.
                Last updated -
                9
                14
                9
                TypeScript
                MIT License
              • -
                security
                A
                license
                -
                quality
                A Model Context Protocol server enabling LLMs like Claude to interact with the Alpaca trading API through natural language for stock trading, checking positions, fetching market data, and managing your account.
                Last updated -
                Python
                MIT License
              • A
                security
                F
                license
                A
                quality
                A Model Context Protocol server that enables AI assistants to interact with the Deriv trading API, providing access to active trading symbols and account balance information.
                Last updated -
                2
                Python
                • Apple
              • -
                security
                A
                license
                -
                quality
                A Model Context Protocol server that enables interaction with the Tradovate API for managing trading contracts, positions, orders, and accounts.
                Last updated -
                JavaScript
                MIT License

              View all related MCP servers

              MCP directory API

              We provide all the information about MCP servers via our MCP API.

              curl -X GET 'https://glama.ai/api/mcp/v1/servers/laukikk/alpaca-mcp'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server