← 返回
安全合规

VBrokers Trading

VBrokers (华盛通 VCL HK) trading automation via OpenAPI Gateway running on localhost port 11111. Use when: setting up VBrokers or 华盛通 account access, authentica...
VBrokers (华盛通 VCL HK) trading automation via OpenAPI Gateway running on localhost port 11111. Use when: setting up VBrokers or 华盛通 account access, authentica...
lcy360
安全合规 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 682
下载
💾 7
安装
1
版本
#latest

概述

VBrokers Trader

Automate trading on VBrokers (华盛通 VCL HK) via the OpenAPI Gateway running locally.

Prerequisites

  • OpenAPI Gateway must be running locally (GUI app: 华盛通OpenAPIGateway.app)
  • Gateway URL: http://127.0.0.1:11111
  • AES key for password encryption: provided during account setup (see references/api-reference.md)
  • Python packages: pycryptodome (pip install pycryptodome)

Quick Start

Copy scripts/vbrokers_client.py to your project and import it:

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

# 1. Login (required after Gateway restart)
vb.trade_login("your_trading_password")

# 2. Check account
funds = vb.get_account_funds("P")   # P=US, K=HK

# 3. Get real-time quote (use correct mktTmType for time segment)
quote = vb.get_quotes_batch(["AAPL"], session=-1)  # -1=pre-market

# 4. Place order
result = vb.place_order("AAPL", "P", "1", 1, 180.00)  # BUY 1 share limit $180

# 5. Check positions
positions = vb.get_positions("P")

Key Concepts

Request Format (Critical)

All HTTP requests must use nested params:

{"timeout_sec": 10, "params": {"exchangeType": "P", ...}}

Exchange Types

CodeMarket
--------------
PUS Stocks
KHK Stocks
v深股通
t沪股通

Session Types (for orders)

ValueMeaning
----------------
"0"Regular hours only
"1"Extended (pre + post market) — use for US stocks

mktTmType (for real-time quotes)

ValueSegmentBeijing Time
------------------------------
1Regular (盘中)22:30–05:00
-1Pre-market (盘前)17:00–22:30
-2After-hours (盘后)05:00–09:00
-3Night session (夜盘)09:00–17:00
omitDefault (last close)

⚠️ Always specify mktTmType for real-time prices — omitting it returns the previous close.

Password Encryption

Trading password must be AES-ECB encrypted before login:

# Already handled in vbrokers_client.py via encrypt_password()
# Key: base64-encoded 24-byte AES key (provided at account setup)

Common Workflows

Stop-Loss / Take-Profit Monitor

result = vb.check_stop_loss("AAPL", "P", cost_price=150.0,
                             stop_loss_pct=0.08, take_profit_pct=0.10)
# Returns: {"action": "hold"/"stop_loss"/"take_profit", "current_price": ..., "pnl_pct": ...}
if result["action"] == "stop_loss":
    vb.place_order("AAPL", "P", "2", qty, 0, entrust_type="5")  # market sell

Batch Quotes with Time Segment

from datetime import datetime, timezone, timedelta
bj_hour = (datetime.now(tz=timezone.utc) + timedelta(hours=8)).hour
# Determine correct mktTmType based on Beijing time
session = 1 if (bj_hour >= 22 or bj_hour <= 4) else -1 if bj_hour >= 17 else -2 if bj_hour <= 8 else -3
quotes = vb.get_quotes_batch(["AAPL", "TSLA", "NVDA"], session=session)

Cancel All Orders

vb.cancel_all_orders("P")  # Cancel all pending US stock orders

API Reference

For complete endpoint documentation, parameters, and response schemas:

→ See references/api-reference.md

For the full verified client implementation:

→ See scripts/vbrokers_client.py

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 15:54 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,714
security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,215 📥 266,439
security-compliance

1password

steipete
设置和使用 1Password CLI (op)。适用于:安装 CLI、启用桌面应用集成、登录(单/多账户)、通过 op 读取/注入/运行密钥。
★ 53 📥 31,164