97 examples covering the full Futu OpenAPI surface — every API call documented, every response demonstrated, zero mocks.
All scripts import examples/connect.py for HA gateway selection and RSA configuration.
#
Name
What you'll see
00
HA Gateway
TCP probe all your hosts, pick the fastest, handle RSA. Start here to confirm your setup is solid.
#
Name
What you'll see
02
Quote Push
All four quote handlers running together — stock quotes, order book updates, tick-by-tick prints, broker queue changes
05
Quote + Trade Push
Every push type in one script: K-lines, trades, orderbook, and live trade order/deal events
14
Live K-Line Stream
Subscribe to real-time candlestick updates as they print
39
System Notifications
Login events, order fills, market state changes — push directly from OpenD
40
Trade Push
Watch orders go from submitted → filled → partially filled in real time
45
Broker Queue Push
BrokerHandlerBase — real-time push when broker queue changes. LV1 data permission required.
45b
Ticker Push
TickerHandlerBase — every trade print with price, volume, direction, and millisecond timestamp
46
CurKline Push
CurKlineHandlerBase — live candle build-up as it forms, before the bar closes
47
Price Reminder Push
PriceReminderHandlerBase — server-pushed alerts when your price targets are hit
48
KeepAlive Push
KeepAliveHandlerBase — heartbeat monitoring between client and OpenD
54
Pair Trading Signal
Rolling z-score spread between HK.00700 and HK.09988 via CurKlineHandler — statistical arbitrage signal in real time
56
Order Flow Imbalance
ORDER_BOOK push accumulation — measures directional pressure as net bid vs ask volume delta over time
57
VWAP Benchmark
TICKER push stream → running VWAP, deviation in bps, simulated entry P&L — execution quality in real time
Static & Historical Market Data
#
Name
What you'll see
01
Market Snapshot
Every single stock in a market — price, volume, turnover, bid/ask — in one shot
44
Multi-Market Snapshot
All four markets (HK/US/SH/SZ) fetched concurrently via threading
55
Momentum Screener
RSI + MACD across Daily/60M/15M for 8 HK stocks — multi-timeframe signal confluence
07
K-Line History
Historical K-lines with pagination + today's live bar via get_cur_kline
08
Tick Data
Every trade print — exact time, price, volume, direction — for a stock
09
Broker Queue
Who sits on the bid and ask, how many lots each broker is showing
10
Order Book
Full 10-level bid/ask ladder — price, volume, order count at each level
16
Stock Quote
Last price, open, high, low, volume, turnover for a list of stocks
22
Market State
Is the market pre-open, open, closed, or after-hours right now?
#
Name
What you'll see
03
Stock Screener
20+ filter criteria — price, PE, market cap, turnover, industry, flag day, and more
52
Option Chain Filter
Slice option chains by delta, IV, moneyness, OI using OptionDataFilter
Sectors, Plates & References
#
Name
What you'll see
13
Sector Plates
All plates (sectors/industries) in a market, and every stock belonging to a plate
17
Owner Plates
Which plate owns a given stock — useful for sector rotation
18
Reference Stocks
Warrant and bull-bear chain reference data — the underlying and its related instruments
28
Warrant Data
All warrants for an underlying — issuer, implied volatility, premium, maturity
#
Name
What you'll see
19
Capital Flow
Intraday and daily capital flow heatmap — where money is flowing in/out
42
Capital Distribution
Super/Big/Mid/Small fund flow breakdown per stock — institutional tier breakdown
29
Unusual Activity
Unusual volume, price, technical and derivative signals — pick up early mover prints
27
Code Changes
Stock rename, split, and code change history
41
Rehabilitation Data
Ex-dividend, ex-rights, share consolidation dates — for adjusting historical prices
Advanced Analytics & Algo Execution
#
Name
What you'll see
58
Options Greeks
Live delta/gamma/theta/vega/rho from option chain data — pure Python Black-Scholes
59
Dark Pool Detector
Cross-reference TICKER + BROKER push to flag off-book trades
60
Cross-Market Arb
HK.00700 vs US.TCEHY spread tracking — live dual-market quote monitoring
61
TWAP Slicer
Slice large orders over time using ORDER_BOOK pricing (SIMULATE)
62
Portfolio Risk
6 live risk metrics — concentration, leverage, margin, P&L alerts
63
Earnings Screener
Pre-earnings IV/HV ratio + post-earnings unusual activity
64
Backtesting
SMA/RSI/MACD strategies with Sharpe, drawdown, win rate
65
Vol Surface
Moneyness × expiry IV matrix from option chains
66
Multi-Leg Options
Vertical call spread on SIMULATE — 2-leg fill monitoring
67
Health Monitor
Watchdog — latency, subscription quota, market state polling
Advanced Execution Strategies
#
Name
What you'll see
68
Trailing Stop Execution
Dynamic stop-loss that follows price favorably with order replacement
69
Bollinger Band Bounce
Mean-reversion via pure-Python Bollinger Bands (statistics.pstdev)
70
Warrant Valuation Dashboard
Intrinsic/time value, simplified implied vol, mispricing ranking
71
Market Regime Detector
ADX + rolling vol — classifies TRENDING / RANGING / BREAKOUT
72
Candlestick Pattern Scanner
9 classic patterns with confidence scoring + trend confirmation
73
Multi-Asset Correlation Tracker
Rolling Pearson matrix + spike detection across 10+ tickers
74
Order Flow Imbalance Visualizer
Real-time ASCII imbalance bar chart using ORDER_BOOK push
75
Futures Term Structure & Roll Yield
Dynamic futures discovery, contango/backwardation, ASCII chart
76
Kelly Criterion Position Sizer
Optimal sizing with half/quarter-Kelly, ATR-based stop
77
Iceberg Order Detector
Heuristic hidden order detection via order book dynamics
78
Grid Trading Bot
Automated buy-low/sell-high within a defined price range
79
Pairs Trading (Cointegration)
Engle-Granger stat-arb — HK.00700 vs US.TCEHY
80
Multi-Leg Options Strategy
Straddle, strangle, iron condor execution on SIMULATE
81
Portfolio Rebalancing Bot
Periodic target-allocation rebalancing with live positions
82
Unusual Options Activity Scanner
Volume anomaly flagging across full option chain
#
Name
What you'll see
83
Dividend & Corporate Action Tracker
Upcoming dividends, ex-dates, splits, rights issues for watchlist
84
VWAP Execution Analysis
Trade quality vs VWAP benchmark, slippage analysis, time-bucketed breakdown
85
Options Volatility Skew
Implied vol surface across strikes/expiries with Newton-Raphson solver
#
Name
What you'll see
86
Market Breadth Dashboard
Adv/Dec, McClellan Oscillator, sector participation across HK/US/SH/SZ
87
Smart Watchlist Alerts
Price targets, RSI, Bollinger Band break alerts with cooldown logic
Risk Management (SIMULATE)
#
Name
What you'll see
88
Stop-Loss / Take-Profit Engine
Dual SL/TP with partial exits and trailing activation
92
Monte Carlo Portfolio Simulator
10K path simulation with VaR, percentiles, ASCII histogram
96
Margin Utilization Monitor
Real-time margin tracking, utilization bars, liquidation price
#
Name
What you'll see
89
Gap Scanner
Overnight gap detection across all markets with volume confirmation
90
AH Premium/Discount Tracker
A-share vs H-share price comparison with FX adjustment
91
Sector Rotation Scanner
RSI-based sector ranking for rotation signals
95
52-Week High/Low Scanner
Proximity to yearly extremes with volume confirmation
97
VWAP Anchored Trading Levels
Dynamic support/resistance with volume confirmation signals
Options Strategies (SIMULATE)
#
Name
What you'll see
93
Options Calendar Spread Builder
Neutral theta plays via vol differential across expiries
94
Earnings Surprise Analyzer
EPS surprise detection + post-earnings price action
Real-Time Feeds (Push Handlers)
Push handlers receive streaming data from OpenD as events occur. Subscribe once, and the handler fires every time the data changes — no polling required.
#
Name
What you'll see
02
All quote push handlers
Quote, orderbook, ticker, broker queue — all running simultaneously
05
Quote + trade combined
Every push type in one script, with trade order/deal streams
14
Live K-Line Stream
Subscribe to real-time candlestick updates as they print
39
System Notifications
Login events, order fills, market alerts
40
Trade Push
Live order status and deal confirmations as they happen
45
Broker Queue Push
BrokerHandlerBase for real-time broker depth changes (LV1 req.)
45b
Ticker Push
TickerHandlerBase — every trade print with price, volume, direction
46
CurKline Push
CurKlineHandlerBase for live candle build-up before bar closes
47
Price Reminder Push
PriceReminderHandlerBase for server-pushed price alerts
48
KeepAlive Push
KeepAliveHandlerBase for connection heartbeat monitoring
Trading (SIMULATE Account)
All trade examples use the SIMULATE account only. No real orders are placed.
#
Name
What you'll see
04
MACD strategy
Calculate MACD cross signals, place simulated orders
06
Place and modify orders
Sell with smart order types
11
Account info + positions
Cash, margin, positions, Unrealized P&L, dry-run your buying power
32
Order lifecycle
Query, modify, cancel orders and their fills
33
Trading limits
Max buy/sell quantity, margin ratios
34
Cancel all open orders
Emergency cleanup
35
Cash flow history
Deposits, withdrawals, fees
37
Margin ratios
Margin utilization for leveraged positions
38
Order fees
Commission, platform fee, clear fees per order
49
Account cash flow
get_acc_cash_flow on trade context
50
Historical orders & deals
Closed-order pipeline and historical fill records
51
Account list
All sub-accounts (REAL + SIMULATE) with types and statuses
Calendars & Reference Data
#
Name
What you'll see
12
Trading days calendar
Which days each market is open
20
IPO calendar
Upcoming and recent IPOs per market
21
Futures specs
Contract size, tick size, trading hours
53
Option expiration cycles
Full roll calendar grouped by WEEK/MONTH/QUARTER
User Data & Administration
#
Name
What you'll see
23
Price alerts
Create, query, update, delete price reminders
24
Watchlist groups
Create, rename, delete watchlist groups; add and remove stocks
30
User info
Account list, user profile, broker firm and account type
31
Misc
Flag days, rehabilitation data, watchlist operations
#
Name
What you'll see
15
Subscription list
Which stocks and what types you're subscribed to
25
Option chains
All option contracts for an underlying grouped by expiration date
26
K-line quota
How many historical K-line API calls you've burned through today
36
Stock basic info
Name, lot size, board lot, security type for a market or code list
43
Subscribe lifecycle
Batch subscribe → query subscription → unsubscribe_all