Skip to main content
Glama
mcp-server-shioaji

mcp-server-shioaji

Official
by Sinotrade

Shioaji 的 MCP 服务器

模型上下文协议 (MCP) 服务器,为 AI 助手提供访问台湾金融市场的 Shioaji 交易 API 的权限。

概述

该服务器实现了 MCP 协议,将 Shioaji API 功能公开为可供 AI 助手使用的工具。它允许 AI 模型执行以下操作:

  • 检索当前股票价格

  • 获取历史数据

  • 列出可用股票

  • 还有更多...

Related MCP server: Financial Datasets MCP Server

安装

先决条件

  • Python 3.10 或更高版本

  • uv(快速 Python 包管理器)

使用 uv

uv sync

配置

在运行服务器之前,您需要配置Shioaji API凭据。有两种方法可以做到这一点:

环境变量

设置以下环境变量:

export SHIOAJI_API_KEY="your_api_key"
export SHIOAJI_SECRET_KEY="your_secret_key"

使用 .env 文件

在根目录中创建一个.env文件,其内容如下:

SHIOAJI_API_KEY=your_api_key
SHIOAJI_SECRET_KEY=your_secret_key

运行服务器

使用以下命令启动服务器:

uv run mcp-server-shioaji

服务器默认从http://0.0.0.0:8000启动。

可用工具

服务器通过 MCP 公开以下工具:

获取股票价格

通过股票代码获取股票的当前价格。

{
  "tool": "get_stock_price",
  "params": {
    "symbols": "TW.2330,TW.2317"
  }
}

响应将包括所请求股票的价格信息,包括开盘价、最高价、最低价、收盘价、交易量和其他交易数据。

获取kbars

获取某个日期范围内股票的 K-Bar(烛台)数据。

{
  "tool": "get_kbars",
  "params": {
    "symbol": "TW.2330",
    "start_date": "2023-12-01",
    "end_date": "2023-12-15"
  }
}

如果未提供start_date ,则默认为今天。如果未提供end_date ,则默认与start_date相同。

扫描股票

根据各种排名标准扫描股票。

{
  "tool": "scan_stocks",
  "params": {
    "scanner_type": "VolumeRank",
    "ascending": false,
    "limit": 10
  }
}

支持的扫描仪类型:

  • VolumeRank - 按交易量排名

  • AmountRank - 按交易金额排名

  • TickCountRank - 按交易数量排名

  • ChangePercentRank - 按百分比变化排名

  • ChangePriceRank - 按价格变化排名

  • DayRangeRank - 按每日范围排名

默认限制为 20,结果默认按降序排列( ascending为true可实现升序排列)。

发展

项目结构

mcp-server-shioaji/
├── src/
│   └── mcp_server_shioaji/
│       ├── __init__.py      # Package entry point
│       └── server.py        # MCP server implementation
├── pyproject.toml           # Project metadata and dependencies
└── README.md                # This file

添加新工具

要添加新的 Shioaji 功能,请修改server.py并使用@mcp.tool装饰器添加新的工具定义。

执照

麻省理工学院

致谢

  • Shioaji - 永丰金控交易 API 的 Python 包装器

  • MCP——模型上下文协议

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    An MCP server that integrates the XTQuant quantitative trading platform with AI assistants, allowing AI to directly access and operate on trading data and functionality.
    8
    170
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    MCP server that provides AI assistants access to stock market data including financial statements, stock prices, and market news through a Model Context Protocol interface.
    11
    2,317
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    An MCP server that provides standardized access to the SinoPac Securities Shioaji trading API for market data retrieval and order management. It enables users to search contracts, access real-time market snapshots, and manage trading accounts through a secure, model-compatible interface.
    11
    3
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that integrates Futu OpenAPI, enabling AI models to query real-time market data and execute trades across Hong Kong, US, and A-share markets.
    30 PyPI
    81
    MIT