Agent skill

Stock Connect Flow Analysis

by HKUDS in HKUDS/Vibe-Trading

Analyzes Northbound and Southbound Stock Connect flows between the mainland and Hong Kong, including quota use, sector allocation shifts and cross-border arbitrage signals.

MITAuto-check passedBusiness, Finance & HR

Install Stock Connect Flow Analysis

skills CLI
$ npx skills add HKUDS/Vibe-Trading --skill hk-connect-flow -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install HKUDS/Vibe-Trading hk-connect-flow --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/HKUDS/Vibe-Trading.git skills-src && mkdir -p .claude/skills && cp -r skills-src/agent/src/skills/hk-connect-flow .claude/skills/hk-connect-flow && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
hk-connect-flow
GitHub stars
35k
Token cost
~2.8k tokens
SKILL.md length
627 words
Files
1
Skills in repo
89
Repo updated
First seen
Licence
MIT

At a glance

Analyzes Northbound and Southbound Stock Connect flows between the mainland and Hong Kong, including quota use, sector allocation shifts and cross-border arbitrage signals.

  • Works in 5 steps: Stock Connect Architecture → Northbound Flow Analysis (Foreign into… → Southbound Flow Analysis (Mainland into… → …
  • Reading Northbound flows as a sentiment indicator for A-shares
  • SKILL.md covers Overview, Core Concepts, Data Access and Output Format, plus 1 more section
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

The skill uses Shanghai and Shenzhen Connect flows as a real-time gauge of cross-border positioning. Northbound flow, foreign money buying A-shares, is treated as an institutional sentiment indicator, while Southbound flow shows mainland appetite for Hong Kong assets. A table lays out the four channels and what each measures, and notes a daily net buy quota where heavy utilization is read as a strong directional signal.

For Northbound flows it explains why they matter despite a small share of free-float market cap, gives a signal function keyed to daily net buy size, and tabulates typical sector allocation from consumer staples and financials to technology, healthcare and new energy. Shifts in sector weights are read as defensive or risk-on positioning. Cross-border arbitrage signals are part of the stated scope.

When your agent uses it

  • Reading Northbound flows as a sentiment indicator for A-shares
  • Tracking Southbound flows into Hong Kong stocks
  • Watching sector allocation shifts by foreign investors
  • Looking for cross-border arbitrage signals between A and H listings

Example prompts

  • “Is today's Northbound net buy large enough to count as a strong signal?”
  • “Show how Northbound sector weights shifted toward consumer staples and what that suggests.”
  • “Compare Southbound flow into Hong Kong with Northbound flow this month.”
  • “Build a daily Northbound signal function for my backtest.”

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Stock Connect Architecture
  2. Northbound Flow Analysis (Foreign into A-shares)
  3. Southbound Flow Analysis (Mainland into HK)
  4. AH Premium Index
  5. Cross-Border Flow Composite Signal

What it can do on your machine

Read from SKILL.md and the folder at commit b1f6ce7. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Stock Connect Flow Analysis loads about 2.8k tokens when it runs. Until then it costs about 53 tokens; SKILL.md has 627 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~53
When it runs · the whole SKILL.md, loaded when a task matches
~2.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from HKUDS/Vibe-Trading at commit b1f6ce7, republished under its MIT licence (© HKUDS). 627 words, ~2,754 tokens.

Download SKILL.mdSave it as .claude/skills/hk-connect-flow/SKILL.md (or your agent's skills folder).
name
hk-connect-flow
description
Stock Connect (Shanghai/Shenzhen-Hong Kong) fund flow analysis — Northbound (foreign into A-shares), Southbound (mainland into HK), sector allocation tracking, and cross-border arbitrage signals.
category
flow

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
ChannelDirectionWhat It Measures
Shanghai Connect NorthboundForeign → A-shares (SSE)Foreign institutional A-share appetite
Shenzhen Connect NorthboundForeign → A-shares (SZSE)Foreign institutional A-share appetite (growth bias)
Shanghai Connect SouthboundMainland → HK (HKEX)Mainland capital HK allocation
Shenzhen Connect SouthboundMainland → 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 PreferenceTypical HoldingsSignal
Consumer staples (Moutai, dairy)30-35% of holdingsCore 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
Show full SKILL.md (239 more words)Show less
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 added to
    "southbound_flow": 0,       # -2 to +2: 20-day cumulative SB flow direction
    "ah_premium": 0,            # -2 to +2: AH premium level (high = favor HK)
    "fx_direction": 0,          # -2 to +2: CNY strength (strong CNY = NB inflow support)
}

# Total range: -10 to +10
# > +5: strong cross-border risk-on, favor A-shares
# +2 to +5: mild bullish
# -2 to +2: neutral / mixed
# < -2: cross-border risk-off, foreign selling A-shares
# < -5: strong risk-off, likely FX-driven

Data Access

Via agent tools (no code, throttled, envelope-standard)
python
# Daily Southbound net buy — 港股通(沪)/(深) channels, unit 100M HKD (亿).
# Eastmoney datacenter primary (cross-verified against HKEX official daily
# statistics); HKEX official report as keyless fallback (latest day snapshot):
get_southbound_flow(lookback_days=20)

⚠️ Do NOT read daily southbound flow from tushare moneyflow_hsgt: its ggt_ss/ggt_sz/south_money fields now carry the cumulative net-bought stock (万亿-scale, near-constant day to day), not daily flow.

Via Tushare (A-share perspective)
python
import tushare as ts
pro = ts.pro_api()

# Daily Northbound/Southbound aggregate flows
df = pro.moneyflow_hsgt(start_date="20260101", end_date="20260330")
# Columns: trade_date, ggt_ss (Shanghai SB), ggt_sz (Shenzhen SB),
#           hgt (Shanghai NB), sgt (Shenzhen NB), north_money, south_money

# Top 10 Northbound active stocks
df = pro.hsgt_top10(trade_date="20260328", market_type="1")  # 1=Shanghai, 3=Shenzhen
# Columns: trade_date, ts_code, name, close, change, rank, market_type,
#           amount (trade amount), net_amount (net buy), buy, sell
Via yfinance (HK perspective)
python
import yfinance as yf

# HK-listed stocks price data
tencent = yf.download("0700.HK", start="2025-01-01", end="2026-03-30", progress=False)
alibaba = yf.download("9988.HK", start="2025-01-01", end="2026-03-30", progress=False)

# AH Premium Index (proxy via Hang Seng indices)
hsi = yf.download("^HSI", start="2025-01-01", end="2026-03-30", progress=False)
Key Data Points to Track
MetricSourceFrequencyThreshold
Northbound daily net buyTushare / HKEXDaily>RMB 5B = significant
Northbound 20-day cumulativeCalculatedDaily>RMB 30B = trend
Southbound daily net buyget_southbound_flow (Eastmoney ↔ HKEX)Daily>HKD 3B = significant
AH Premium IndexHang SengDaily>130 = H-share value
Quota utilizationHKEXIntraday>50% = strong conviction
NB Top 10 concentrationTushareDailyTop 3 names >50% = concentrated bet

Output Format

## Stock Connect Flow Analysis — [Date Range]

### Northbound (Foreign → A-shares)
- **20-day cumulative**: [+/- RMB X.XB]
- **5-day trend**: [accelerating / decelerating / reversing]
- **Daily average**: [RMB X.XB]
- **Quota utilization**: [X%]
- **Signal**: [sustained accumulation / distribution / neutral]

### Northbound Sector Allocation
- **Adding to**: [sector1 (top names), sector2]
- **Reducing**: [sector1, sector2]
- **Rotation direction**: [defensive / cyclical / growth]

### Southbound (Mainland → HK)
- **20-day cumulative**: [+/- HKD X.XB]
- **Focus names**: [Tencent, Alibaba, bank names]
- **Driver**: [dividend yield / tech allocation / AH arbitrage]

### AH Premium
- **Current index**: [XXX]
- **Historical percentile**: [X%]
- **Implication**: [favor H-shares / neutral / favor A-shares]

### Composite Signal
| Dimension | Score (-2~+2) | Basis |
|-----------|---------------|-------|
| NB flow | +1 | Cumulative +RMB 15B over 20 days |
| NB breadth | +2 | Adding across 8 of top 10 |
| SB flow | 0 | Flat |
| AH premium | -1 | AH premium at 135 (H relatively cheap) |
| FX | +1 | CNY stable/strengthening |

### Cross-Market Implication
- **A-share outlook**: [bullish / neutral / bearish] (NB perspective)
- **HK outlook**: [bullish / neutral / bearish] (SB + AH perspective)
- **Arbitrage**: [AH premium trade: buy H / sell A for dual-listed names]

Notes

  • Northbound flow is the single most-watched institutional indicator for A-shares; it often leads index turns by 1-3 days
  • Quarter-end and MSCI rebalancing dates (Feb/May/Aug/Nov) cause mechanical flow distortions — filter these out for signal purity
  • CNY/USD exchange rate is a key driver of Northbound flow; USD strength typically triggers NB outflows regardless of A-share fundamentals
  • Southbound flow can be distorted by dividend arbitrage (mainland funds buy before ex-div, creating artificial inflow spikes)
  • Stock Connect data is freely available from HKEX website and Tushare API
  • This framework is for research purposes only and does not constitute investment advice

© HKUDS, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in agent/src/skills/hk-connect-flow of HKUDS/Vibe-Trading.

Open the folder on GitHubat commit b1f6ce7

Compare with similar skills

Stock Connect Flow Analysis next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Stock Connect Flow Analysis compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Stock Connect Flow Analysis this skillHKUDS/Vibe-Trading35k—~2.8kAutomated safety check: PassMIT
AI-Trader Market IntelHKUDS/AI-Trader23k—~1.1kAutomated safety check: PassNone
Stock Deep Analysis Workflowwbh604/UZI-Skill7.1k—~9.1kAutomated safety check: NotesMIT
Zhengxi Fund Manager Views Librarylyra81604/zhengxi-views1.8k—~1.6kAutomated safety check: PassMIT
Supply Chain Bottleneck Hunterxbtlin/ai-berkshire17k—~2.6kAutomated safety check: PassMIT
Deep Company Article Seriesxbtlin/ai-berkshire17k—~2kAutomated safety check: PassMIT

Similar skills

  • AI-Trader Market Intel

    HKUDS/AI-Trader

    Reads AI-Trader's read-only market snapshots, grouped financial news and events board through its market-intel endpoints, for context before trading or posting.

    23k GitHub stars~1.1k tokensUpdated 4 mo ago
    Business, Finance & HRAuto-check passed
  • Runs a staged deep analysis of a single stock on China A-share, Hong Kong and US markets, ending in an HTML report with valuation models and investor-panel scores.

    7.1k GitHub stars~9.1k tokensUpdated 1 mo ago
    Business, Finance & HRAuto-check: notes
  • Zhengxi Fund Manager Views Library

    lyra81604/zhengxi-views

    Answers questions with sourced quotes from one Chinese fund manager's public writings, applies his stated investment method and compares his words with real fund holdings.

    1.8k GitHub stars~1.6k tokensUpdated 1 mo ago
    Business, Finance & HRAuto-check passed
  • Scans a long-running industry trend for supply chain chokepoints, aiming to find second- and third-layer suppliers that the market has not yet priced in.

    17k GitHub stars~2.6k tokensUpdated 2 days ago
    Business, Finance & HRAuto-check passed
  • Deep Company Article Series

    xbtlin/ai-berkshire

    Plans and writes a three-to-eight-part long-form article series that breaks down one company, built on fact-checked financials, valuation and management analysis.

    17k GitHub stars~2k tokensUpdated 2 days ago
    Business, Finance & HRAuto-check passed
  • Longbridge Earnings

    helsome/folio

    Earnings analysis — pre- and post-earnings. An agent skill from helsome/folio.

    271 GitHub starsUsed in 1 repo~2.5k tokens
    Business, Finance & HRAuto-check passed

More from HKUDS/Vibe-Trading

All 89 skills in this repo
  • Eastmoney Market Data

    HKUDS/Vibe-Trading

    Index of Eastmoney's free, no-token market data interfaces for China A-shares and Hong Kong stocks: fund flows, dragon-tiger lists, margin trading, reports and news.

    35k GitHub stars~1k tokensUpdated yesterday
    Auto-check passed
  • OKX Market Data

    HKUDS/Vibe-Trading

    Retrieves public OKX cryptocurrency market data such as spot prices, candlesticks, funding rates and open interest through the OKX V5 REST API, with no authentication.

    35k GitHub stars~1.3k tokensUpdated yesterday
    Auto-check passed
  • SEC EDGAR Filings Fetcher

    HKUDS/Vibe-Trading

    Fetches U.S. SEC EDGAR data: resolves tickers to CIK numbers, lists recent 10-K, 10-Q and 8-K filings with document URLs, and pulls XBRL financial series.

    35k GitHub stars~1.4k tokensUpdated yesterday
    Auto-check passed
  • A-Share ST Risk Screener

    HKUDS/Vibe-Trading

    Predicts whether a mainland China A-share company risks an ST or *ST warning after its next annual report, using financial thresholds and Sina penalty records.

    35k GitHub stars~4.9k tokensUpdated yesterday
    Auto-check passed
  • Breaks a structural trend such as AI infrastructure into its physical supply chain and ranks lesser-known listed companies sitting on each bottleneck.

    35k GitHub stars~2.7k tokensUpdated yesterday
    Auto-check passed
  • Plans and drafts an eight-part, roughly 120k-word investigative series on one company, built around a strict fact-check pass rather than fast drafting.

    35k GitHub stars~2.4k tokensUpdated yesterday
    Auto-check passed

Questions about Stock Connect Flow Analysis

What does Stock Connect Flow Analysis do?

Analyzes Northbound and Southbound Stock Connect flows between the mainland and Hong Kong, including quota use, sector allocation shifts and cross-border arbitrage signals. The skill uses Shanghai and Shenzhen Connect flows as a real-time gauge of cross-border positioning. Northbound flow, foreign money buying A-shares, is treated as an institutional sentiment indicator, while Southbound flow shows mainland appetite for Hong Kong assets.

When should I use Stock Connect Flow Analysis?

Stock Connect Flow Analysis fits situations like: reading Northbound flows as a sentiment indicator for A-shares; tracking Southbound flows into Hong Kong stocks; watching sector allocation shifts by foreign investors; looking for cross-border arbitrage signals between A and H listings.

How do I install Stock Connect Flow Analysis in Claude Code?

Run `npx skills add HKUDS/Vibe-Trading --skill hk-connect-flow -a claude-code`. Or copy the skill folder (agent/src/skills/hk-connect-flow in HKUDS/Vibe-Trading) into .claude/skills/hk-connect-flow in your project. Claude Code loads it when a task matches its description.

How do I install Stock Connect Flow Analysis in Codex?

Run `npx skills add HKUDS/Vibe-Trading --skill hk-connect-flow -a codex`. Or copy the skill folder (agent/src/skills/hk-connect-flow in HKUDS/Vibe-Trading) into .agents/skills/hk-connect-flow in your project. Codex loads it when a task matches its description.

Can I use Stock Connect Flow Analysis in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add HKUDS/Vibe-Trading --skill hk-connect-flow -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/hk-connect-flow, .gemini/skills/hk-connect-flow, .github/skills/hk-connect-flow and .opencode/skills/hk-connect-flow in your project.

What does Stock Connect Flow Analysis need to run?

SKILL.md names no scripts, command-line tools or credentials: Stock Connect Flow Analysis is instructions for the agent only.

Does Stock Connect Flow Analysis access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Stock Connect Flow Analysis safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Stock Connect Flow Analysis use?

Stock Connect Flow Analysis is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Stock Connect Flow Analysis use?

About 2.8k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Stock Connect Flow Analysis?

Skills that share tags, products or a category with Stock Connect Flow Analysis: AI-Trader Market Intel (HKUDS/AI-Trader, 23k stars), Stock Deep Analysis Workflow (wbh604/UZI-Skill, 7.1k stars), Zhengxi Fund Manager Views Library (lyra81604/zhengxi-views, 1.8k stars) and Supply Chain Bottleneck Hunter (xbtlin/ai-berkshire, 17k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Stock Connect Flow Analysis?

HKUDS (a GitHub organization) maintains it in HKUDS/Vibe-Trading, which has 35,097 GitHub stars. The repository holds 89 skills in this directory. The repository was last updated on October 9, 2026.

Source: HKUDS/Vibe-Trading on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.