vbrokers-trader

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 quotes, and all major trade/quote endpoints.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "vbrokers-trader" with this command: npx skills add lcy360/vbrokers-trading

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

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

Agent Guardian

Agent体验守护系统。解决AI助手常见体验问题:长时间无响应、任务卡死、中英文混用、状态不透明。包含看门狗监控、智能状态汇报、即时状态查询、语言一致性过滤、消息队列追踪。适用于所有渠道(QQ/微信/Telegram/飞书/Discord等)。当用户抱怨"等太久没回复"、"回复中英文混着"、"不知道在干什么"时使...

Registry SourceRecently Updated
Automation

Proactive Agent V2

Transform AI agents from task-followers into proactive partners that anticipate needs and continuously improve. Now with WAL Protocol, Working Buffer, Autono...

Registry SourceRecently Updated
Automation

Palaia

Local, crash-safe persistent memory for OpenClaw agents. Replaces built-in memory-core with semantic search, projects, and scope-based access control. After...

Registry SourceRecently Updated
1381
iret77