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 of Empires

Manage AI coding agent sessions via Agent of Empires (aoe)

Registry SourceRecently Updated
Automation

lotto-agent

Private lottery assistant for number generation, drawing fetching, prize checking, report generation, and automation management without prediction or winning...

Registry SourceRecently Updated
Automation

Self-Improving Compound

Capture durable lessons from debugging, user corrections, missing capabilities, and repeated workflow friction so future sessions avoid the same mistakes. Hy...

Registry SourceRecently Updated
Automation

Cold outreach Starter

Free cold outreach templates — 5 proven email formulas for B2B outreach. Generate personalized openers, follow-ups, and value props. Upgrade to Pro for autom...

Registry SourceRecently Updated