Skip to content
Back to search

futu-stock-mcp-server

mcp server for futuniuniu stock

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/shuizhengqi1--futu-stock-mcp-server/badge.svg)](/listings/shuizhengqi1--futu-stock-mcp-server)

HTML

<a href="/listings/shuizhengqi1--futu-stock-mcp-server"><img src="/api/listings/shuizhengqi1--futu-stock-mcp-server/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 855 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Futu Stock MCP Server
  2. [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org)
  3. [![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
  4. [![OpenAPI](https://img.shields.io/badge/Futu-OpenAPI-orange)](https://openapi.futunn.com/futu-api-doc/)
  5. 基于[模型上下文协议(MCP)](https://github.com/cursor-ai/model-context-protocol)的富途证券行情交易接口服务器。将富途OpenAPI功能以标准化的MCP协议提供给AI模型使用,支持行情订阅、数据查询等功能。
  6. ## 🌟 特性
  7. - 🔌 完全兼容 MCP 2.0 协议标准
  8. - 📊 支持港股、美股、A股等市场的实时行情
  9. - 🔄 支持实时数据订阅和推送
  10. - 📈 支持K线、逐笔、买卖盘等多维度数据
  11. - 🔒 安全的API调用和数据访问机制
  12. - 🛠 提供完整的开发工具和示例代码
  13. ## ⚠️ 前置要求
  14. 在使用本项目之前,您需要:
  15. 1. 拥有富途证券账户并开通OpenAPI权限
  16. 2. 安装并运行富途的OpenD网关程序([官方文档](https://openapi.futunn.com/futu-api-doc/intro/intro.html))
  17. 3. 根据您的需求订阅相应的行情权限
  18. ## 🔒 安全提示
  19. - 请勿在代码中硬编码任何账号密码信息
  20. - 确保`.env`文件已添加到`.gitignore`中
  21. - 妥善保管您的API访问凭证
  22. - 遵守富途OpenAPI的使用条款和限制
  23. ## 📝 免责声明
  24. 本项目是一个开源工具,旨在简化富途OpenAPI的接入流程。使用本项目时请注意:
  25. 1. 遵守相关法律法规和富途OpenAPI的使用条款
  26. 2. 自行承担使用本项目进行交易的风险
  27. 3. 本项目不提供任何投资建议
  28. 4. 使用本项目前请确保您已获得所需的行情权限
  29. ## Features
  30. - Standard MCP 2.0 protocol compliance
  31. - Comprehensive Futu API coverage
  32. - Real-time data subscription support
  33. - Market data access
  34. - Derivatives information
  35. - Account query capabilities
  36. - Resource-based data access
  37. - Interactive prompts for analysis
  38. ## Prerequisites
  39. - Python 3.10+
  40. - Futu OpenAPI SDK
  41. - Model Context Protocol SDK
  42. - uv (recommended)
  43. ## 🚀 快速开始
  44. ### 方式一:通过 pipx 安装(推荐)
  45. ```bash
  46. # 安装 pipx(如果还没有安装)
  47. brew install pipx # macOS
  48. # 或者 pip install --user pipx # 其他系统
  49. # 安装包
  50. pipx install futu-stock-mcp-server
  51. # 运行服务器
  52. futu-mcp-server
  53. ```
  54. > **为什么使用 pipx?**
  55. > - pipx 专门用于安装 Python 应用程序到全局环境
  56. > - 自动管理独立的虚拟环境,避免依赖冲突
  57. > - 命令直接可用,无需激活虚拟环境
  58. ### 方式二:通过 Docker 运行
  59. ```bash
  60. # 拉取镜像
  61. docker pull your-registry/futu-stock-mcp-server:latest
  62. # 运行容器
  63. docker run -d \
  64. --name futu-mcp-server \
  65. -p 8000:8000 \
  66. -e FUTU_HOST=127.0.0.1 \
  67. -e FUTU_PORT=11111 \
  68. your-registry/futu-stock-mcp-server:latest
  69. ```
  70. ### 方式三:从源码安装
  71. 1. Clone the repository:
  72. ```bash
  73. git clone https://github.com/yourusername/futu-stock-mcp-server.git
  74. cd futu-stock-mcp-server
  75. ```
  76. 2. Install uv:
  77. ```bash
  78. # macOS/Linux
  79. curl -LsSf https://astral.sh/uv/install.sh | sh
  80. # Windows (PowerShell)
  81. powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
  82. ```
  83. 3. Create and activate a virtual environment:
  84. ```bash
  85. # Create virtual environment
  86. uv venv
  87. # Activate virtual environment
  88. # On macOS/Linux:
  89. source .venv/bin/activate
  90. # On Windows:
  91. .venv\Scripts\activate
  92. ```
  93. 4. Install dependencies:
  94. ```bash
  95. # Install in editable mode
  96. uv pip install -e .
  97. ```
  98. 5. (可选) 如需从源码直接运行,通过环境变量配置服务:
  99. ```bash
  100. export FUTU_HOST=127.0.0.1
  101. export FUTU_PORT=11111
  102. ```
  103. > **推荐方式**:在 MCP 客户端配置文件中使用 `env` 字段注入,无需创建 `.env` 文件,见下方 [MCP Server 配置](#-mcp-server-配置) 章节。
  104. ## Development
  105. ### Managing Dependencies
  106. Add new dependencies to `pyproject.toml`:
  107. ```toml
  108. [project]
  109. dependencies = [
  110. # ... existing dependencies ...
  111. "new-package>=1.0.0",
  112. ]
  113. ```
  114. Then update your environment:
  115. ```bash
  116. uv pip install -e .
  117. ```
  118. ### Code Style
  119. This project uses Ruff for code linting and formatting. The configuration is in `pyproject.toml`:
  120. ```toml
  121. [tool.ruff]
  122. line-length = 100
  123. target-version = "py38"
  124. [tool.ruff.lint]
  125. select = ["E", "F", "I", "N", "W", "B", "UP"]
  126. ```
  127. Run linting:
  128. ```bash
  129. uv pip install ruff
  130. ruff check .
  131. ```
  132. Run formatting:
  133. ```bash
  134. ruff format .
  135. ```
  136. ## 🔧 MCP Server 配置
  137. ### 在 Claude Desktop 中配置
  138. 1. **找到配置文件位置**:
  139. - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
  140. - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
  141. 2. **添加服务器配置**(所有参数均通过 `env` 字段注入,无需 `.env` 文件):
  142. ```json
  143. {
  144. "mcpServers": {
  145. "futu-stock": {
  146. "command": "futu-mcp-server",
  147. "env": {
  148. "FUTU_HOST": "127.0.0.1",
  149. "FUTU_PORT": "11111",
  150. "FUTU_ENABLE_POSITIONS": "1",
  151. "FUTU_ENABLE_TRADING": "0",
  152. "FUTU_TRADE_ENV": "SIMULATE",
  153. "FUTU_SECURITY_FIRM": "FUTUSECURITIES",
  154. "FUTU_TRD_MARKET": "HK"
  155. }
  156. }
  157. }
  158. }
  159. ```
  160. 3. **使用 `python` 命令启动**(适用于源码开发场景):
  161. ```json
  162. {
  163. "mcpServers": {
  164. "futu-stock": {
  165. "command": "python",
  166. "args": ["-m", "futu_stock_mcp_server.server"],
  167. "env": {
  168. "FUTU_HOST": "127.0.0.1",
  169. "FUTU_PORT": "11111"
  170. }
  171. }
  172. }
  173. }
  174. ```
  175. 4. **故障排除配置**:
  176. 如果上述配置不工作,可以尝试使用完整路径:
  177. ```json
  178. {
  179. "mcpServers": {
  180. "futu-stock": {
  181. "command": "/Users/your-username/.local/bin/futu-mcp-server",
  182. "env": {
  183. "FUTU_HOST": "127.0.0.1",
  184. "FUTU_PORT": "11111"
  185. }
  186. }
  187. }
  188. }
  189. ```
  190. > **提示**:使用 `which futu-mcp-server` 命令查看完整路径
  191. ### 在其他 MCP 客户端中配置
  192. #### 使用 Python MCP 客户端
  193. ```python
  194. from mcp import ClientSession, StdioServerParameters
  195. from mcp.client.stdio import stdio_client
  196. async def main():
  197. server_params = StdioServerParameters(
  198. command="futu-mcp-server",
  199. env={
  200. "FUTU_HOST": "127.0.0.1",
  201. "FUTU_PORT": "11111"
  202. }
  203. )
  204. async with stdio_client(server_params) as (read, write):
  205. async with ClientSession(read, write) as session:
  206. # Initialize the connection
  207. await session.initialize()
  208. # List available tools
  209. tools = await session.list_tools()
  210. print("Available tools:", [tool.name for tool in tools.tools])
  211. ```
  212. #### 使用 Node.js MCP 客户端
  213. ```javascript
  214. import { Client } from "@modelcontextprotocol/sdk/client/index.js";
  215. import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
  216. const transport = new StdioClientTransport({
  217. command: "futu-mcp-server",
  218. env: {
  219. FUTU_HOST: "127.0.0.1",
  220. FUTU_PORT: "11111"
  221. }
  222. });
  223. const client = new Client({
  224. name: "futu-stock-client",
  225. version: "1.0.0"
  226. }, {
  227. capabilities: {}
  228. });
  229. await client.connect(transport);
  230. ```
  231. ## 📋 使用方法
  232. ### 1. 启动服务器(独立运行)
  233. ```bash
  234. # 通过 pip 安装后
  235. futu-mcp-server
  236. # 或从源码运行
  237. python -m futu_stock_mcp_server.server
  238. ```
  239. ### 2. 环境变量配置
  240. 推荐在 MCP 客户端的 `env` 字段中直接配置,无需 `.env` 文件:
  241. | 环境变量 | 说明 | 默认值 |
  242. |---|---|---|
  243. | `FUTU_HOST` | OpenD 地址 | `127.0.0.1` |
  244. | `FUTU_PORT` | OpenD 端口 | `11111` |
  245. | `FUTU_TRADE_ENV` | 交易环境 (`SIMULATE`/`REAL`) | `SIMULATE` |
  246. | `FUTU_SECURITY_FIRM` | 券商 (`FUTUSECURITIES`/`FUTUINC`) | `FUTUSECURITIES` |
  247. | `FUTU_TRD_MARKET` | 交易市场 (`HK`/`US`) | `HK` |
  248. | `FUTU_DEBUG_MODE` | 调试日志开关 (`0`/`1`) | `0` |
  249. ### 3. 验证连接
  250. 启动服务器后,你应该看到类似的日志:
  251. ```
  252. 2024-10-02 14:20:52 | INFO | Initializing Futu connection...
  253. 2024-10-02 14:20:52 | INFO | Successfully initialized Futu connection
  254. 2024-10-02 14:20:52 | INFO | Starting MCP server in stdio mode...
  255. 2024-10-02 14:20:52 | INFO | Press Ctrl+C to stop the server
  256. ```
  257. ### 4. 在 AI 工具中使用
  258. 配置完成后,重启 Claude Desktop 或其他 MCP 客户端,你就可以:
  259. - 查询股票实时行情
  260. - 获取历史K线数据
  261. - 订阅股票数据推送
  262. - 查询账户信息
  263. - 执行交易操作(需要交易权限)
  264. ## 🔧 故障排除
  265. ### 常见问题
  266. #### 1. 命令 `futu-mcp-server` 找不到
  267. ```bash
  268. # 确保已正确安装
  269. pipx install futu-stock-mcp-server
  270. # 检查命令是否可用
  271. which futu-mcp-server
  272. # 如果还是找不到,检查 PATH
  273. echo $PATH | grep -o '[^:]*\.local/bin[^:]*'
  274. ```
  275. #### 2. Ctrl+C 无法退出服务器
  276. - 新版本已修复此问题
  277. - 如果仍然遇到,可以使用 `kill -9 <pid>` 强制终止
  278. #### 3. 连接富途 OpenD 失败
  279. ```bash
  280. # 检查 OpenD 是否运行
  281. netstat -an | grep 11111
  282. # 检查环境变量
  283. echo $FUTU_HOST
  284. echo $FUTU_PORT
  285. ```
  286. #### 4. Claude Desktop 无法识别服务器
  287. - 确保配置文件路径正确
  288. - 检查 JSON 格式是否有效
  289. - 重启 Claude Desktop
  290. - 查看 Claude Desktop 的日志文件
  291. #### 5. 权限问题
  292. ```bash
  293. # 确保有执行权限
  294. chmod +x ~/.local/bin/futu-mcp-server
  295. # 或者使用完整路径
  296. python -m futu_stock_mcp_server.server
  297. ```
  298. ### 日志调试
  299. 本项目已根据 [MCP 官方文档](https://github.com/modelcontextprotocol/python-sdk) 的最佳实践配置了日志系统:
  300. #### MCP 兼容的日志配置
  301. - **文件日志**: 所有日志写入 `logs/futu_server.log`,自动轮转和清理
  302. - **MCP Context 日志**: 工具执行期间通过 MCP Context 发送日志给客户端
  303. - **stdout 保护**: 确保 stdout 仅用于 MCP JSON 通信,避免污染
  304. #### 调试模式(仅开发时使用)
  305. ```bash
  306. # 启用调试模式(会向 stderr 输出日志)
  307. export FUTU_DEBUG_MODE=1
  308. futu-mcp-server
  309. ```
  310. **注意**: 在 MCP 客户端中不要启用调试模式,因为它会向 stderr 输出日志。
  311. #### 日志文件位置
  312. - 主日志文件:`./logs/futu_server.log`
  313. - 自动轮转:500 MB 后轮转
  314. - 自动清理:保留 10 天
  315. 详细的日志配置说明请参考 [docs/LOGGING.md](docs/LOGGING.md)。
  316. tools = await session.list_tools()
  317. # Call a tool
  318. result = await session.call_tool(
  319. "get_stock_quote",
  320. arguments={"symbols": ["HK.00700"]}
  321. )
  322. # Access a resource
  323. content, mime_type = await session.read_resource(
  324. "market://HK.00700"
  325. )
  326. # Get a prompt
  327. prompt = await session.get_prompt(
  328. "market_analysis",
  329. arguments={"symbol": "HK.00700"}
  330. )
  331. if __name__ == "__main__":
  332. import asyncio
  333. asyncio.run(main())
  334. ```
  335. ## Changelog
  336. Latest updates (`2026-03-02`) - v0.1.5:
  337. - **环境变量优先配置**:`FUTU_HOST` / `FUTU_PORT` 现在直接通过 MCP 客户端 `env` 字段注入,无需 `.env` 文件。
  338. - 移除 `python-dotenv` 导入,简化依赖。
  339. - 新增 `python -m` 启动方式的配置示例。
  340. Previous updates (`2026-03-02`) - v0.1.4:
  341. - Added trading MCP tools: `unlock_trade`, `place_order`, `modify_order`, `cancel_order`, `cancel_all_orders`, order/deal query tools, fee/cashflow tools.
  342. - Added position and trade feature switches: `FUTU_ENABLE_POSITIONS`, `FUTU_ENABLE_TRADING`.
  343. - Added official Futu API to MCP mapping doc: [docs/FUTU_API_MCP_COVERAGE.md](docs/FUTU_API_MCP_COVERAGE.md).
  344. - Kept backward compatibility: existing MCP tool names and argument contracts were not changed.
  345. Full history: [CHANGELOG.md](CHANGELOG.md)
  346. ## Available API Methods
  347. Full mapping document (official Futu API -> MCP tools): [docs/FUTU_API_MCP_COVERAGE.md](docs/FUTU_API_MCP_COVERAGE.md)
  348. ### Market Data Tools
  349. - `get_stock_quote`: Get stock quote data
  350. - `get_market_snapshot`: Get market snapshot
  351. - `get_cur_kline`: Get current K-line data
  352. - `get_history_kline`: Get historical K-line data
  353. - `get_rt_data`: Get real-time data
  354. - `get_ticker`: Get ticker data
  355. - `get_order_book`: Get order book data
  356. - `get_broker_queue`: Get broker queue data
  357. ### Subscription Tools
  358. - `subscribe`: Subscribe to real-time data
  359. - `unsubscribe`: Unsubscribe from real-time data
  360. ### Derivatives Tools
  361. - `get_option_chain`: Get option chain data
  362. - `get_option_expiration_date`: Get option expiration dates
  363. - `get_option_condor`: Get option condor strategy data
  364. - `get_option_butterfly`: Get option butterfly strategy data
  365. ### Account Query Tools
  366. - `get_account_list`: Get account list
  367. - `get_funds`: Get account funds information
  368. - `get_positions`: Get account positions
  369. - `get_position_list`: Get account positions with filters
  370. - `get_max_power`: Get account buying power
  371. - `get_margin_ratio`: Get margin ratio for a security
  372. ### Trading Tools
  373. - `unlock_trade`: Unlock trade operations
  374. - `place_order`: Place order
  375. - `modify_order`: Modify order
  376. - `cancel_order`: Cancel one order
  377. - `cancel_all_orders`: Cancel all cancellable orders
  378. - `get_order_list`: Query current order list
  379. - `get_history_order_list`: Query historical orders
  380. - `get_deal_list`: Query current deals
  381. - `get_history_deal_list`: Query historical deals
  382. - `get_order_fee`: Query order fee details
  383. - `get_acc_cash_flow`: Query cash flow details
  384. - `get_acc_trading_info`: Query trade capability/pre-check
  385. ### Market Information Tools
  386. - `get_market_state`: Get market state
  387. - `get_security_info`: Get security information
  388. - `get_security_list`: Get security list
  389. ### Stock Filter Commands
  390. #### get_stock_filter
  391. Filter stocks based on various conditions.
  392. Parameters:
  393. - `base_filters` (optional): List of basic stock filters
  394. ```python
  395. {
  396. "field_name": int, # StockField enum value
  397. "filter_min": float, # Optional minimum value
  398. "filter_max": float, # Optional maximum value
  399. "is_no_filter": bool, # Optional, whether to skip filtering
  400. "sort_dir": int # Optional, sort direction
  401. }
  402. ```
  403. - `accumulate_filters` (optional): List of accumulate filters
  404. ```python
  405. {
  406. "field_name": int, # AccumulateField enum value
  407. "filter_min": float,
  408. "filter_max": float,
  409. "is_no_filter": bool,
  410. "sort_dir": int,
  411. "days": int # Required, number of days to accumulate
  412. }
  413. ```
  414. - `financial_filters` (optional): List of financial filters
  415. ```python
  416. {
  417. "field_name": int, # FinancialField enum value
  418. "filter_min": float,
  419. "filter_max": float,
  420. "is_no_filter": bool,
  421. "sort_dir": int,
  422. "quarter": int # Required, financial quarter
  423. }
  424. ```
  425. - `market` (optional): Market code (e.g. "HK.Motherboard", "US.NASDAQ")
  426. - `page` (optional): Page number, starting from 1 (default: 1)
  427. - `page_size` (optional): Number of results per page, max 200 (default: 200)
  428. Supported Market Codes:
  429. - `HK.Motherboard`: Hong Kong Main Board
  430. - `HK.GEM`: Hong Kong GEM
  431. - `HK.BK1911`: H-Share Main Board
  432. - `HK.BK1912`: H-Share GEM
  433. - `US.NYSE`: NYSE
  434. - `US.AMEX`: AMEX
  435. - `US.NASDAQ`: NASDAQ
  436. - `SH.3000000`: Shanghai Main Board
  437. - `SZ.3000001`: Shenzhen Main Board
  438. - `SZ.3000004`: Shenzhen ChiNext
  439. Example:
  440. ```python
  441. # Get stocks with price between 10 and 50 HKD in Hong Kong Main Board
  442. filters = {
  443. "base_filters": [{
  444. "field_name": 5, # Current price
  445. "filter_min": 10.0,
  446. "filter_max": 50.0
  447. }],
  448. "market": "HK.Motherboard"
  449. }
  450. result = await client.get_stock_filter(**filters)
  451. ```
  452. Notes:
  453. - Limited to 10 requests per 30 seconds
  454. - Each page returns maximum 200 results
  455. - Recommended to use no more than 250 filter conditions
  456. - Maximum 10 accumulate conditions of the same type
  457. - Dynamic data sorting (like current price) may change between pages
  458. - Cannot compare different types of indicators (e.g. MA5 vs EMA10)
  459. ## Resources
  460. ### Market Data
  461. - `market://{symbol}`: Get market data for a symbol
  462. - `kline://{symbol}/{ktype}`: Get K-line data for a symbol
  463. ## Prompts
  464. ### Analysis
  465. - `market_analysis`: Create a market analysis prompt
  466. - `option_strategy`: Create an option strategy analysis prompt
  467. ## Error Handling
  468. The server follows the MCP 2.0 error response format:
  469. ```json
  470. {
  471. "jsonrpc": "2.0",
  472. "id": "request_id",
  473. "error": {
  474. "code": -32000,
  475. "message": "Error message",
  476. "data": null
  477. }
  478. }
  479. ```
  480. ## Security
  481. - The server uses secure WebSocket connections
  482. - All API calls are authenticated through the Futu OpenAPI
  483. - Environment variables are used for sensitive configuration
  484. ## Development
  485. ### Adding New Tools
  486. To add a new tool, use the `@mcp.tool()` decorator:
  487. ```python
  488. @mcp.tool()
  489. async def new_tool(param1: str, param2: int) -> Dict[str, Any]:
  490. """Tool description"""
  491. # Implementation
  492. return result
  493. ```
  494. ### Adding New Resources
  495. To add a new resource, use the `@mcp.resource()` decorator:
  496. ```python
  497. @mcp.resource("resource://{param1}/{param2}")
  498. async def new_resource(param1: str, param2: str) -> Dict[str, Any]:
  499. """Resource description"""
  500. # Implementation
  501. return result
  502. ```
  503. ### Adding New Prompts
  504. To add a new prompt, use the `@mcp.prompt()` decorator:
  505. ```python
  506. @mcp.prompt()
  507. async def new_prompt(param1: str) -> str:
  508. """Prompt description"""
  509. return f"Prompt template with {param1}"
  510. ```
  511. ## License
  512. MIT License
  513. ## Available MCP Functions
  514. ### Market Data Functions
  515. #### get_stock_quote
  516. Get stock quote data for given symbols.
  517. ```python
  518. symbols = ["HK.00700", "US.AAPL", "SH.600519"]
  519. result = await session.call_tool("get_stock_quote", {"symbols": symbols})
  520. ```
  521. Returns quote data including price, volume, turnover, etc.
  522. #### get_market_snapshot
  523. Get market snapshot for given symbols.
  524. ```python
  525. symbols = ["HK.00700", "US.AAPL", "SH.600519"]
  526. result = await session.call_tool("get_market_snapshot", {"symbols": symbols})
  527. ```
  528. Returns comprehensive market data including price, volume, bid/ask prices, etc.
  529. #### get_cur_kline
  530. Get current K-line data.
  531. ```python
  532. result = await session.call_tool("get_cur_kline", {
  533. "symbol": "HK.00700",
  534. "ktype": "K_1M", # K_1M, K_5M, K_15M, K_30M, K_60M, K_DAY, K_WEEK, K_MON
  535. "count": 100
  536. })
  537. ```
  538. #### get_history_kline
  539. Get historical K-line data.
  540. ```python
  541. result = await session.call_tool("get_history_kline", {
  542. "symbol": "HK.00700",
  543. "ktype": "K_DAY",
  544. "start": "2024-01-01",
  545. "end": "2024-03-31"
  546. })
  547. ```
  548. #### get_rt_data
  549. Get real-time trading data.
  550. ```python
  551. result = await session.call_tool("get_rt_data", {"symbol": "HK.00700"})
  552. ```
  553. #### get_ticker
  554. Get ticker data (detailed trades).
  555. ```python
  556. result = await session.call_tool("get_ticker", {"symbol": "HK.00700"})
  557. ```
  558. #### get_order_book
  559. Get order book data.
  560. ```python
  561. result = await session.call_tool("get_order_book", {"symbol": "HK.00700"})
  562. ```
  563. #### get_broker_queue
  564. Get broker queue data.
  565. ```python
  566. result = await session.call_tool("get_broker_queue", {"symbol": "HK.00700"})
  567. ```
  568. ### Subscription Functions
  569. #### subscribe
  570. Subscribe to real-time data.
  571. ```python
  572. result = await session.call_tool("subscribe", {
  573. "symbols": ["HK.00700", "US.AAPL"],
  574. "sub_types": ["QUOTE", "TICKER", "K_1M"]
  575. })
  576. ```
  577. Subscription types:
  578. - "QUOTE": Basic quote
  579. - "ORDER_BOOK": Order book
  580. - "TICKER": Trades
  581. - "RT_DATA": Real-time data
  582. - "BROKER": Broker queue
  583. - "K_1M" to "K_MON": K-line data
  584. #### unsubscribe
  585. Unsubscribe from real-time data.
  586. ```python
  587. result = await session.call_tool("unsubscribe", {
  588. "symbols": ["HK.00700", "US.AAPL"],
  589. "sub_types": ["QUOTE", "TICKER"]
  590. })
  591. ```
  592. ### Options Functions
  593. #### get_option_chain
  594. Get option chain data.
  595. ```python
  596. result = await session.call_tool("get_option_chain", {
  597. "symbol": "HK.00700",
  598. "start": "2024-04-01",
  599. "end": "2024-06-30"
  600. })
  601. ```
  602. #### get_option_expiration_date
  603. Get option expiration dates.
  604. ```python
  605. result = await session.call_tool("get_option_expiration_date", {
  606. "symbol": "HK.00700"
  607. })
  608. ```
  609. #### get_option_condor
  610. Get option condor strategy data.
  611. ```python
  612. result = await session.call_tool("get_option_condor", {
  613. "symbol": "HK.00700",
  614. "expiry": "2024-06-30",
  615. "strike_price": 350.0
  616. })
  617. ```
  618. #### get_option_butterfly
  619. Get option butterfly strategy data.
  620. ```python
  621. result = await session.call_tool("get_option_butterfly", {
  622. "symbol": "HK.00700",
  623. "expiry": "2024-06-30",
  624. "strike_price": 350.0
  625. })
  626. ```
  627. ### Account Functions
  628. #### get_account_list
  629. Get account list.
  630. ```python
  631. result = await session.call_tool("get_account_list", {"random_string": "dummy"})
  632. ```
  633. #### get_funds
  634. Get account funds information.
  635. ```python
  636. result = await session.call_tool("get_funds", {"random_string": "dummy"})
  637. ```
  638. #### get_positions
  639. Get account positions.
  640. ```python
  641. result = await session.call_tool("get_positions", {"random_string": "dummy"})
  642. ```
  643. #### get_max_power
  644. Get maximum trading power.
  645. ```python
  646. result = await session.call_tool("get_max_power", {"random_string": "dummy"})
  647. ```
  648. #### get_margin_ratio
  649. Get margin ratio for a security.
  650. ```python
  651. result = await session.call_tool("get_margin_ratio", {"symbol": "HK.00700"})
  652. ```
  653. ### Market Information Functions
  654. #### get_market_state
  655. Get market state.
  656. ```python
  657. result = await session.call_tool("get_market_state", {"market": "HK"})
  658. ```
  659. Available markets: "HK", "US", "SH", "SZ"
  660. #### get_security_info
  661. Get security information.
  662. ```python
  663. result = await session.call_tool("get_security_info", {
  664. "market": "HK",
  665. "code": "00700"
  666. })
  667. ```
  668. #### get_security_list
  669. Get security list for a market.
  670. ```python
  671. result = await session.call_tool("get_security_list", {"market": "HK"})
  672. ```
  673. #### get_stock_filter
  674. Get filtered stock list based on conditions.
  675. ```python
  676. result = await session.call_tool("get_stock_filter", {
  677. "market": "HK.Motherboard",
  678. "base_filters": [{
  679. "field_name": 1, # Price
  680. "filter_min": 10.0,
  681. "filter_max": 50.0,
  682. "sort_dir": 1 # Ascending
  683. }],
  684. "page": 1,
  685. "page_size": 50
  686. })
  687. ```
  688. ### Time Function
  689. #### get_current_time
  690. Get current server time.
  691. ```python
  692. result = await session.call_tool("get_current_time", {"random_string": "dummy"})
  693. ```
  694. Returns timestamp, formatted datetime, date, time and timezone.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.