Hk Connect Flow logo

Hk Connect Flow

OrganizationPopular
HKUDS
hk-connect-flow

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.

Overview

PublisherHKUDS
RepositoryVibe-Trading
Skill namehk-connect-flow
Stars
33.6K
Forks
5.5K
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by HKUDS on GitHub. Read the source before you install it.

Installation

Install the Hk Connect Flow AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HKUDS/Vibe-Trading.git /tmp/Vibe-Trading
mkdir -p .claude/skills
cp -r /tmp/Vibe-Trading/agent/src/skills/hk-connect-flow .claude/skills/hk-connect-flow
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Hk Connect Flow in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Hk Connect Flow on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Hk Connect Flow is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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

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 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 buyTushare / HKEXDaily>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

Frequently asked questions

What does the Hk Connect Flow AI skill do?

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.

Why use Hk Connect Flow on TypingMind?

Because you install it once and use it with any model. Hk Connect Flow is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Hk Connect Flow in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/HKUDS/Vibe-Trading/tree/main/agent/src/skills/hk-connect-flow. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Hk Connect Flow?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Hk Connect Flow?

As many as you like. As long as a model supports skills, you can use Hk Connect Flow with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Hk Connect Flow AI skill free?

Yes. It is published on GitHub by HKUDS under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇