hk-connect-flow
**hk-connect-flow** This Claude Code skill analyzes capital flows through China's Shanghai-Hong Kong and Shenzhen-Hong Kong Stock Connect programs, tracking Northbound flows (foreign institutional purchases of A-shares) and Southbound flows (mainland investor activity in Hong Kong-listed stocks). Use it to gauge cross-border capital sentiment, identify quota utilization signals above 50%, and detect institutional accumulation or distribution patterns that may precede price movements in Chinese equities.
git clone --depth 1 https://github.com/HKUDS/Vibe-Trading /tmp/hk-connect-flow && cp -r /tmp/hk-connect-flow/agent/src/skills/hk-connect-flow ~/.claude/skills/hk-connect-flowSKILL.md
# Stock Connect Fund Flow Analysis
## Overview
Analyze capital flows through the Shanghai-Hong Kong and Shenzhen-Hong Kong Stock Connect programs. Northbound flows (foreign capital into A-shares) are a key institutional sentiment indicator for the China market; Southbound flows (mainland capital into Hong Kong) reveal mainland investor preference for HK-listed assets. Together they provide a real-time cross-border capital positioning signal.
## Core Concepts
### 1. Stock Connect Architecture
| Channel | Direction | What It Measures |
|---------|-----------|------------------|
| Shanghai Connect Northbound | Foreign → A-shares (SSE) | Foreign institutional A-share appetite |
| Shenzhen Connect Northbound | Foreign → A-shares (SZSE) | Foreign institutional A-share appetite (growth bias) |
| Shanghai Connect Southbound | Mainland → HK (HKEX) | Mainland capital HK allocation |
| Shenzhen Connect Southbound | Mainland → HK (HKEX) | Mainland capital HK allocation |
**Daily quota**: Each channel has a daily net buy quota (~RMB 52B / HKD 42B). Quota utilization >50% = strong directional signal.
### 2. Northbound Flow Analysis (Foreign into A-shares)
**Why Northbound matters:**
- Foreign institutions (global funds, sovereign wealth funds, hedge funds) are considered "smart money" in A-shares
- Northbound holdings represent ~4-5% of A-share free-float market cap — small but marginal price-setters
- Northbound flow correlates with MSCI China index rebalancing and global EM allocation decisions
**Northbound signal framework:**
```python
# Daily Northbound net buy signals
def northbound_signal(daily_net_buy_rmb_billion):
if daily_net_buy_rmb_billion > 10:
return "strong_foreign_buying" # Very large single-day inflow
elif daily_net_buy_rmb_billion > 5:
return "moderate_foreign_buying"
elif daily_net_buy_rmb_billion > 0:
return "mild_foreign_buying"
elif daily_net_buy_rmb_billion > -5:
return "mild_foreign_selling"
elif daily_net_buy_rmb_billion > -10:
return "moderate_foreign_selling"
else:
return "strong_foreign_selling" # Panic outflow
# Cumulative flow trend (more important than single-day)
def northbound_trend(flows_20d, flows_5d):
cum_20d = sum(flows_20d)
cum_5d = sum(flows_5d)
if cum_20d > 30 and cum_5d > 10:
return "sustained_accumulation" # Strong bullish for A-shares
elif cum_20d < -30 and cum_5d < -10:
return "sustained_distribution" # Bearish for A-shares
elif cum_20d > 0 and cum_5d < 0:
return "accumulation_pausing" # Watch for reversal
elif cum_20d < 0 and cum_5d > 0:
return "distribution_pausing" # Possible bottom formation
```
**Northbound sector allocation patterns:**
| Sector Preference | Typical Holdings | Signal |
|-------------------|-----------------|--------|
| Consumer staples (Moutai, dairy) | 30-35% of holdings | Core allocation, low turnover |
| Financials (banks, insurance) | 15-20% | Cyclical allocation, rate-sensitive |
| Technology (semiconductors, software) | 10-15% | Growth allocation, high turnover |
| Healthcare (CXO, innovative pharma) | 8-12% | Structural growth bet |
| New energy (EV, solar) | 5-10% | Thematic, high volatility |
**Sector rotation signal:**
- When Northbound increases consumer staples weight → defensive positioning
- When Northbound increases tech/new energy weight → risk-on, growth chasing
- When Northbound reduces across all sectors → broad risk-off, usually FX-driven (CNY weakening)
### 3. Southbound Flow Analysis (Mainland into HK)
**Why Southbound matters:**
- Mainland investors are the marginal buyer for many HK mid/small caps
- Southbound flows are driven by: AH premium (A vs H discount arbitrage), dividend yield hunting, and tech platform allocation (Tencent, Alibaba, Meituan)
- Insurance and pension funds increasingly use Southbound for international diversification
**Southbound signal framework:**
```python
# Southbound focus areas
southbound_targets = {
"tech_platforms": ["0700.HK", "9988.HK", "3690.HK", "9618.HK"],
"high_dividend": ["0939.HK", "1398.HK", "0883.HK", "2628.HK"],
"ah_discount": [], # Dynamically calculated based on AH premium index
}
def southbound_signal(daily_net_buy_hkd_billion):
if daily_net_buy_hkd_billion > 5:
return "strong_mainland_buying"
elif daily_net_buy_hkd_billion > 2:
return "moderate_mainland_buying"
elif daily_net_buy_hkd_billion < -2:
return "mainland_selling"
else:
return "neutral"
```
**Southbound investment patterns:**
1. **Dividend yield arbitrage**: mainland funds buy HK-listed banks/telecoms for higher dividend yield (H-share dividends are often 2-3% higher than A-share equivalents due to lower prices)
2. **Tech platform allocation**: Tencent, Alibaba, Meituan are HK-only or HK-primary listings; mainland tech allocation must go Southbound
3. **AH premium arbitrage**: when AH premium index >130, arbitrage capital flows Southbound to buy cheaper H-shares
### 4. AH Premium Index
The Hang Seng AH Premium Index (HSAHP) tracks the average premium of A-shares over their H-share counterparts for dual-listed companies.
```python
# AH Premium interpretation
ah_premium_index = 130 # A-shares trade 30% above H-shares on average
if ah_premium_index > 140:
signal = "extreme_ah_premium"
action = "favor H-shares over A-shares for dual-listed names"
elif ah_premium_index > 125:
signal = "elevated_ah_premium"
action = "mild H-share preference"
elif ah_premium_index < 110:
signal = "compressed_ah_premium"
action = "A-shares relatively cheap vs H; unusual, investigate"
else:
signal = "normal_range"
```
### 5. Cross-Border Flow Composite Signal
**Multi-dimensional scoring:**
```python
connect_score = {
"northbound_flow": 0, # -2 to +2: 20-day cumulative NB flow direction
"northbound_breadth": 0, # -2 to +2: number of NB top-10 holdings being addeProfessional finance research toolkit — backtesting (7 engines + benchmark comparison panel), factor analysis, Alpha Zoo (452 pre-built alphas across qlib158/alpha101/gtja191/academic), options pricing, 77 finance skills, 29 multi-agent swarm teams, Trade Journal analyzer, and Shadow Account (extract → backtest → render) across 7 data sources (tushare, yfinance, okx, akshare, mootdx, ccxt, futu).
ADR/H-share/A-share cross-listing premium analysis — track pricing gaps between US-listed ADRs, HK-listed H-shares, and A-shares for arbitrage signals, dual-listing valuation, and delisting risk assessment.
AKShare financial data aggregator (18k+ stars). Free, no API key. Covers A-shares, US, HK, futures, macro, forex. Primary fallback for tushare and yfinance.
Browse and bench the bundled alpha zoos — prebuilt cross-sectional factor libraries (Kakushadze 101, GTJA 191, Qlib 158, Fama-French / Carhart). Use when the user asks "which alphas exist", wants metadata on a named alpha, or wants to run IC/IR on a whole zoo over a universe.
A 股 ST/*ST 风险预测框架 — 基于最新中报/三季报或业绩预告/快报,预测下一财年是否会因营收、利润、净资产、分红不达标而被风险警示,并将新浪监管处罚记录作为独立证据面纳入风险等级。仅适用于 A 股,不预测财务造假。
Asset allocation theory and optimizer usage — MPT / Black-Litterman / risk budgeting / all-weather strategy, including guides for 4 optimizers and rebalancing rules.
Diagnose failed or underperforming backtests, locate the root cause, and fix the issue
Behavioral finance applications: theories of overreaction and underreaction, behavioral explanations for momentum and reversal, investor sentiment cycles, cognitive-bias checklists, and debiasing quantitative strategies.