Skip to main content
Glama
laukikk

Alpaca Trading MCP Server

by laukikk

羊驼交易 MCP 服务器

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

特征

  • 账户管理:查看账户详情、余额和投资组合状态

  • 交易:下达市价单、限价单、止损单和止损限价单

  • 投资组合管理:查看仓位、计算业绩、平仓

  • 市场数据:获取实时报价和历史价格数据

  • 资产信息:获取可交易资产的详细信息

Related MCP server: Alpaca MCP Server

安装

  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 - 获取投资组合的综合摘要

Install Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

Resources

Looking for Admin?

Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.

Latest Blog Posts

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