返回顶部
f

futu-trading-bot富途交易机器人

Use Futu Trade Bot Skills to run account, quote, and trade workflows with real HK market data.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.7
安全检测
已通过
572
下载量
免费
免费
1
收藏
概述
安装方式
版本历史

futu-trading-bot

Futu Trade Bot Skills 📈

🎯 Overview / 概述

English Version:
A trading bot skill based on Futu OpenAPI that enables natural language trading. This skill encapsulates Futus market quote and order execution APIs, allowing agents to perform real-time trading operations through simple commands or scripts. Perfect for implementing natural language trading strategies and automated workflows.

Important: Always use the encapsulated functions provided in this skill (e.g., submitorder, getmarketsnapshot). Never call Futu SDK functions directly (ctx.placeorder, ctx.getmarketsnapshot), as this will bypass connection management, parameter validation, and error handling, leading to unpredictable failures and resource leaks.

中文版本:
基于富途牛牛API接口的交易机器人技能,帮助用户用自然语言进行交易。本技能已将富途牛牛的行情报价、下单交易等功能做了完整封装,可供智能助手随时调用。建议通过命令行或脚本来实现自然语言的策略生成和交易执行。

重要提示:请始终使用本技能提供的封装函数(如 submitorder、getmarketsnapshot)。切勿直接调用富途SDK的原始函数(例如 ctx.placeorder),否则会绕过连接管理、参数校验和错误处理,导致不可预料的失败和资源泄漏。



When to Use This Skill / 使用场景

Use this skill when the user asks in natural language, for example:

  • - 账户相关:“查一下我的账户余额”、“解锁交易”、“锁定账户”、“看看我有哪些账户”
  • 行情查询:“腾讯现在多少钱?”、“查一下港交所的实时报价”、“帮我看看美团今天的K线图”
  • 数据拉取:“获取腾讯的历史K线数据”、“拉取最近10笔成交”
  • 订阅与回调:“实时监控腾讯的报价”、“给我推送腾讯的逐笔成交”
  • 下单交易:“帮我买100股腾讯,限价350”、“卖出200股阿里”、“撤单”、“把订单价格改到355”
  • 策略运行
- “帮我写一个区间策略,监控腾讯,低于540买入,高于550卖出” - “启动这个策略” - “我的策略跑得怎么样了?” - “停止我的策略”

Note to agent: When the user expresses any of these intents, you should use the encapsulated functions provided in this skill (e.g., getaccountinfo, getmarketsnapshot, submit_order, etc.). Never call Futu SDK functions directly – always go through the skills API.

Quick Start / 快速开始

Prerequisites / 前提条件:

  • - Ensure Futu OpenD is running and HK quote entitlement is available.
  • 确保富途OpenD正在运行且拥有港股行情权限。
  • When running inside a restricted agent sandbox (for example OpenClaw/Codex exec), prefer host / elevated mode.
  • The Futu Python SDK may access local OpenD resources during import, including the user log directory under ~/.com.futunn.FutuOpenD/Log, so restricted sandboxes may fail before business functions are called.
  • 如果在受限的 agent 沙箱中运行(例如 OpenClaw/Codex exec),优先使用 host / elevated 模式。
  • 富途 Python SDK 在导入阶段就可能访问本机 OpenD 相关资源,包括 ~/.com.futunn.FutuOpenD/Log 下的日志目录;因此受限沙箱可能会在业务函数执行前就失败。

Setup Steps / 安装步骤:

  1. 1. Install this skill via ClawHub (if not installed yet):

bash
clawhub install futu-trading-bot

  1. 2. Enter the skill folder (default OpenClaw workspace path):
bash cd ~/.openclaw/workspace/skills/futu-trading-bot

If you installed to a different location, cd into that folder instead.

  1. 3. Create virtual environment (recommended):
bash python3 -m venv .venv source .venv/bin/activate
  1. 4. Install package:
bash pip install -e .
  1. 5. Configure credentials:
bash cp json/config_example.json json/config.json # Edit json/config.json with your Futu credentials # 编辑json/config.json填写你的富途账户信息

依赖项

本技能通过 pip install -e . 自动安装以下核心 Python 包:

  • - futu-api(富途 SDK)
  • pydantic(数据校验)

更多依赖请以 pyproject.toml / requirements.txt 为准。

Module Map

  • - Account: account_manager
- getaccountinfo() - unlocktrade(password=None, passwordmd5=None) - lock_trade()
  • - Quote: quote_service
- Stage 1: getstockbasicinfo, getmarketstate - Stage 2: subscribe, unsubscribe, unsubscribeall, querysubscription, callbacks - Stage 3: getmarketsnapshot, getcurkline, requesthistorykline, getrtticker - Stage 4: startquotestream, startorderbookstream
  • - Trade: trade_service
- submitorder, modifyorder, cancelorder, cancelall_orders
  • - Strategy Runtime: strategy_runtime
- run_strategy
  • - Strategy Helpers: strategy
- in-memory state - trade guard / lock - trading window and cooldown helpers

Standard Workflow

  1. 1. Run preflightcheck first to verify config, OpenD connectivity, and sandbox/runtime readiness.
  2. Call getaccountinfo() and select target account (get accid).
  3. Pull quote/snapshot for the target symbol (default HK use case: HK.00700).
  4. For real trading, call unlocktrade(...) (password from config or input).
  5. Submit or manage orders with explicit accid and trdenv.
  6. After real operation, call locktrade() if needed.

Connection Lifecycle

  • - Pull-style quote functions such as getmarketsnapshot, getstockbasicinfo, getmarketstate, getcurkline, requesthistorykline, and getrtticker now close their quote context automatically after returning.
  • Trade functions such as submitorder, modifyorder, and cancelallorders now close their trade/quote contexts automatically after returning.
  • Account functions such as getaccountinfo, unlocktrade, and locktrade now close their contexts automatically after returning.
  • Subscription/callback flows keep the quote context open on purpose. For subscribe, unsubscribe, unsubscribeall, querysubscription, setquotecallback, and setorderbookcallback, call closequoteservice() explicitly when you are done with the session.

Canonical Imports

python

Always use these import paths – do not import from futu directly


from preflightcheck import runpreflight
from strategy import (
StrategyState, TradeGuard, intradingwindow,
tradingwindowstatus, cooldownelapsed, holdingtimeout_exceeded
)
from strategyruntime import runstrategy
from accountmanager import getaccountinfo, unlocktrade, lock_trade
from quote_service import (
getstockbasicinfo, getmarketstate, getmarketsnapshot,
getcurkline, requesthistorykline, getrtticker,
subscribe, unsubscribe, unsubscribeall, querysubscription,
setquotecallback, setorderbookcallback,
startquotestream, startorderbookstream
)
from tradeservice import submitorder, modifyorder, cancelorder, cancelallorders

Account Usage

Preflight

python preflight = run_preflight() if not preflight[success]: print(preflight) raise SystemExit(Preflight failed)

python

Get list of accounts


info = getaccountinfo()
if info[success]:
accounts = info[accounts]
print(accounts)

Unlock trade (uses password from config or provided)

unlock_trade() # will prompt for password if not configured

Or with explicit password:

unlocktrade(password=yourpassword)

Lock trade

lock_trade()

Quote Usage

Basic Info / Market State

python getstockbasicinfo(market=HK, sectype=STOCK, codelist=[HK.00700]) getmarketstate([HK.00700])

Snapshot (no subscription needed)

python snap = getmarketsnapshot([HK.00700]) if snap[success]: price = snap[data][0][last_price]

K-Line

python

Current K-line (requires subscription

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 futu-trading-bot-1776189984 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 futu-trading-bot-1776189984 技能

通过命令行安装

skillhub install futu-trading-bot-1776189984

下载

⬇ 下载 futu-trading-bot v1.0.7(免费)

文件大小: 41.63 KB | 发布时间: 2026-4-15 11:46

v1.0.7 最新 2026-4-15 11:46
Docs: sync latest README/docs; add strategy helpers and runtime; add unified quote/orderbook stream startup

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部