返回顶部
v

vbrokers-traderVBrokers交易自动化

VBrokers (华盛通 VCL HK) trading automation via OpenAPI Gateway running on localhost port 11111. Use when: setting up VBrokers or 华盛通 account access, authenticating trading sessions, checking portfolio or positions or funds, placing or cancelling orders for US, HK or A stocks, fetching real-time quotes or K-lines, building automated trading bots, or implementing stop-loss and take-profit logic. Handles AES-ECB password encryption, sessionType for pre/post-market trading, mktTmType for time-segment

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

vbrokers-trader

VBrokers Trader

通过本地运行的OpenAPI网关,在华盛通(VCL HK)上实现自动化交易。

前置条件

  • - OpenAPI网关 必须在本地运行(GUI应用:华盛通OpenAPIGateway.app)
  • 网关地址:http://127.0.0.1:11111
  • 用于密码加密的 AES密钥:在账户设置时提供(参见 references/api-reference.md)
  • Python包:pycryptodome(pip install pycryptodome)

快速开始

将 scripts/vbrokers_client.py 复制到您的项目中并导入:

python
import sys
sys.path.insert(0, /path/to/skill/scripts)
import vbrokers_client as vb

1. 登录(网关重启后必需)

vb.trade_login(您的交易密码)

2. 查询账户

funds = vb.getaccountfunds(P) # P=美股, K=港股

3. 获取实时行情(使用正确的mktTmType对应时段)

quote = vb.getquotesbatch([AAPL], session=-1) # -1=盘前

4. 下单

result = vb.place_order(AAPL, P, 1, 1, 180.00) # 买入1股限价$180

5. 查询持仓

positions = vb.get_positions(P)

核心概念

请求格式(关键)

所有HTTP请求必须使用嵌套的 params: json {timeout_sec: 10, params: {exchangeType: P, ...}}

交易所类型
代码市场
P美股
K
港股 |

| v | 深股通 | | t | 沪股通 |

交易时段类型(用于订单)
含义
0仅常规时段
1
延长时段(盘前+盘后)— 适用于美股 |

mktTmType(用于实时行情)
时段北京时间
1盘中22:30–05:00
-1
盘前 | 17:00–22:30 |

| -2 | 盘后 | 05:00–09:00 | | -3 | 夜盘 | 09:00–17:00 | | 省略 | 默认(上次收盘价) | — |

⚠️ 获取实时价格时务必指定 mktTmType — 省略将返回上次收盘价。

密码加密

交易密码在登录前必须进行AES-ECB加密: python

已在 vbrokersclient.py 中通过 encryptpassword() 处理

密钥:base64编码的24字节AES密钥(账户设置时提供)

常见工作流程

止损/止盈监控

python result = vb.checkstoploss(AAPL, P, cost_price=150.0, stoplosspct=0.08, takeprofitpct=0.10)

返回:{action: hold/stoploss/takeprofit, currentprice: ..., pnlpct: ...}

if result[action] == stop_loss: vb.placeorder(AAPL, P, 2, qty, 0, entrusttype=5) # 市价卖出

带时段参数的批量行情

python from datetime import datetime, timezone, timedelta bj_hour = (datetime.now(tz=timezone.utc) + timedelta(hours=8)).hour

根据北京时间确定正确的mktTmType

session = 1 if (bjhour >= 22 or bjhour <= 4) else -1 if bjhour >= 17 else -2 if bjhour <= 8 else -3 quotes = vb.getquotesbatch([AAPL, TSLA, NVDA], session=session)

取消所有订单

python vb.cancelallorders(P) # 取消所有待处理的美股订单

API参考

完整的端点文档、参数和响应模式:
→ 参见 references/api-reference.md

完整的已验证客户端实现:
→ 参见 scripts/vbrokers_client.py

标签

skill ai

通过对话安装

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

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 vbrokers-trading-1776200718 技能

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

设置 SkillHub 为我的优先技能安装源,然后帮我安装 vbrokers-trading-1776200718 技能

通过命令行安装

skillhub install vbrokers-trading-1776200718

下载

⬇ 下载 vbrokers-trader v1.0.0(免费)

文件大小: 9.37 KB | 发布时间: 2026-4-15 10:34

v1.0.0 最新 2026-4-15 10:34
VBrokers (华盛通 VCL HK) OpenAPI trading automation. Real-time quotes, order management, stop-loss/take-profit, session-aware price polling for US/HK/A stocks.

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

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

p2p_official_large
返回顶部