mcp-server-shioaji

Official

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.

Integrations

  • Provides configuration management for Shioaji API credentials through a .env file, allowing secure storage of API and secret keys.

  • Serves as the runtime environment for the MCP server that interfaces with the Shioaji trading API, enabling financial market data access for Taiwan stocks.

Shioaji 的 MCP 服务器

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

概述

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

  • 检索当前股票价格
  • 获取历史数据
  • 列出可用股票
  • 还有更多...

安装

先决条件

  • 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,结果默认按降序排列( ascendingtrue可实现升序排列)。

发展

项目结构

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——模型上下文协议
-
security - not tested
F
license - not found
-
quality - not tested

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

  1. Overview
    1. Installation
      1. Prerequisites
      2. Using uv
    2. Configuration
      1. Environment Variables
      2. Using .env File
    3. Running the Server
      1. Available Tools
        1. get_stock_price
        2. get_kbars
        3. scan_stocks
      2. Development
        1. Project Structure
        2. Adding New Tools
      3. License
        1. Acknowledgements
          ID: qi6cyzu7hz