DEV Community

pengwang
pengwang

Posted on Edited on Originally published at apify.com

Getting China A-Share Main-Force Money Flow (主力资金流向) as Clean JSON

Main-force money flow (主力资金流向) is one of the most-watched indicators in Chinese A-share trading. It's the net money flowing in from large and super-large orders — roughly, what institutional-size money is doing.

Getting the data is annoying for three specific reasons.

The three problems with free A-share fund-flow data

1. The fields are internal codes. Eastmoney's public endpoints return f62, f66, f72, f84… There's no documentation, and the ordering changes between endpoints.

2. Some fields return plausible garbage. The f69 field (super-large order net ratio) comes back as roughly -17.9 for every single stock on the market-wide endpoint. It looks like a real ratio. It isn't. If you don't know this and ship it, your screener is silently garbage.

3. No single endpoint gives you all five tiers. Super-large, large, medium, small, plus the ratios — you end up stitching multiple APIs together.

What you get back

from apify_client import ApifyClient

client = ApifyClient("<YOUR_API_TOKEN>")
run = client.actor("jfishpw/china-a-share-fund-flow").call(
    run_input={"mode": "single", "codes": ["002112", "600519"]},
)

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["code"], item["name"], item["main_net"], item["main_ratio"])
Enter fullscreen mode Exit fullscreen mode
{
  "code": "002112",
  "name": "三变科技",
  "price": 12.0,
  "change_pct": -2.44,
  "main_net": -1834716.0,
  "super_large_net": -1779763.0,
  "large_net": -54953.0,
  "medium_net": 5227471.0,
  "small_net": -3392755.0,
  "main_ratio": -1.27,
  "super_large_ratio": -1.23,
  "large_ratio": -0.04,
  "medium_ratio": 3.62,
  "small_ratio": -2.35,
  "timestamp": 1794898488,
  "has_data": true,
  "main_net_check": true
}
Enter fullscreen mode Exit fullscreen mode

Three design choices worth knowing about:

  • main_net_check is a per-row integrity flag. true means super_large_net + large_net == main_net — the identity that defines "main force" in Eastmoney's own terms. You can verify every row without re-deriving anything.
  • main_ratio is super_large_ratio + large_ratio — the identity that defines "main force". Verified per-stock against Eastmoney's own day-end value (difference 0.00).
  • All five order-tier ratios are real in every mode, including market. The market-wide endpoint does return the genuine per-stock super-large ratio. Where a value isn't reliable, it's null — never a fake number.
  • has_data is false for delisted and suspended stocks. Out of ~5,900 stocks, roughly 350 have no money-flow data at all. They stay in the output with null amounts so you can filter explicitly rather than discovering gaps later.

Three modes

Mode Input Output Price
single codes one row per stock $0.005 each
market — all ~5,900 stocks $3.9 per snapshot
history codes + historyDays one row per stock per day $0.02 per stock-day

Finding main-force accumulation

The classic use: sort the whole market by main net inflow.

run = client.actor("jfishpw/china-a-share-fund-flow").call(run_input={"mode": "market"})
rows = list(client.dataset(run["defaultDatasetId"]).iterate_items())

live = [r for r in rows if r["has_data"]]
print(f"{len(live)} live out of {len(rows)}")

for r in sorted(live, key=lambda x: x["main_net"] or 0, reverse=True)[:20]:
    print(f"{r['code']} {r['name']:<8} {r['main_net']/1e8:>8.2f}亿  {r['main_ratio']}%")
Enter fullscreen mode Exit fullscreen mode

With pandas it's about the same:

import pandas as pd

df = pd.DataFrame(client.dataset(run["defaultDatasetId"]).list_items())
df = df[df["has_data"]].copy()
df["main_net_yi"] = df["main_net"] / 1e8
df["change_pct"] = pd.to_numeric(df["change_pct"], errors="coerce")

print(df.nlargest(20, "main_net_yi")[
    ["code", "name", "main_net_yi", "main_ratio", "change_pct", "price"]
].to_string(index=False))
Enter fullscreen mode Exit fullscreen mode

Note main_net / 1e8 — the amounts are in raw CNY, so 1e8 is 100 million (亿).

Distinguishing sustained inflow from a one-day blip

A single day of main-force inflow is noise. Five days of it is a signal.

run = client.actor("jfishpw/china-a-share-fund-flow").call(
    run_input={"mode": "history", "codes": ["600519"], "historyDays": 30},
)

history = list(client.dataset(run["defaultDatasetId"]).iterate_items())
recent = history[-5:]

cumulative = sum(r["main_net"] or 0 for r in recent)
print(f"5-day cumulative main net: {cumulative/1e8:.2f}亿")
print("sustained inflow" if cumulative > 0 else "sustained outflow")
Enter fullscreen mode Exit fullscreen mode

Data conventions

  • Amounts are in CNY. 1e8 = 1 亿, 1e4 = 1 万.
  • main_net == super_large_net + large_net always holds. main_net_check verifies it per row.
  • Delisted and suspended stocks (PTxx, 退, ST) have no money-flow data → has_data: false, amount fields null. Set includeQuote: false to slim the payload.
  • Source: Eastmoney's public market-data endpoints.

Calling it from an AI agent

claude mcp add --transport http apify "https://mcp.apify.com?tools=jfishpw/china-a-share-fund-flow"
Enter fullscreen mode Exit fullscreen mode
{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com?tools=jfishpw/china-a-share-fund-flow"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Links

Pay-per-event: a full-market snapshot is $3.9, a single stock is $0.005.

Top comments (0)