[Bug] get_northbound_flow silently returns an empty envelope: Eastmoney northbound net feed dead since 2024-08-30, payload shape drifted, and the tushare fallback's ×100 mislabels turnover as net flow

Author: shadowinlifeCreated Sep 18, 2026Updated Sep 24, 2026

What happened:

get_northbound_flow silently returns a useless envelope — ok: true, source: "eastmoney" with realtime all null and history: [] — on every call, and never falls through to the tushare fallback. Live run against current main (d3c29488):

json
{"ok": true, "market": "China A", "source": "eastmoney",
 "data": {"unit": "10k CNY", "lookback_days": 5,
          "realtime": {"shanghai_connect": null, "shenzhen_connect": null, "total": null},
          "history": []}}

There are three stacked root causes, each verified against live endpoints on 2026-09-18:

1. The Eastmoney kamt northbound net-flow feed is dead (since 2024-08-30). HKEX stopped publishing northbound daily net buy in late Aug 2024. The push2his kamt.kline series confirms it: the last non-zero net-inflow point is 2024-08-29, and every trading day from 2024-08-30 onward is 0.00 with a frozen cumulative (273757367.45, identical for 2 years). The realtime kamt/get payload carries dayNetAmtIn: 0.0 for both hk2sh/hk2sz.

2. The Eastmoney payload shape drifted, so the parser reads keys that no longer exist. _parse_realtime reads data.hk2sh.netBuyAmt, but the live payload nests dayNetAmtIn; _parse_history reads data.klines, but the live payload returns per-channel arrays under data.hk2sh / data.hk2sz. Result: even the (dead) zeros never reach the envelope — history parses to []. Because the HTTP calls succeed, the except-based tushare fallback never triggers: the tool reports ok: true on a structurally empty payload.

3. The tushare fallback's ×100 rescale is wrong for current data — the field semantics changed at the same disclosure reform. tushare_fallbacks.fetch_northbound_flow multiplies hgt/sgt/north_money by 100 ("million CNY → 10k CNY", pinned by test_northbound_converts_tushare_million_yuan_to_10k_cny). But since 2024-08-30 tushare repurposed these fields to carry turnover, in million CNY — verified to the cent against HKEX's official Stock Connect Daily Statistics on three anchor days:

trade_date tushare hgt HKEX SSE Northbound Total Turnover tushare sgt HKEX SZSE Northbound
2026-09-15 107092.06 107,092.06 122612.63 122,612.63
2026-09-16 122957.80 122,957.80 141280.72 141,280.72
2026-09-17 120233.94 120,233.94 139631.89 139,631.89

(north_money = hgt + sgt exactly.) The magnitude jump across the boundary is also visible in the raw series: 2024-06-28 north_money=4948.47 (net buy, million CNY) → 2024-08-30 167789.97 (turnover, million CNY). So for post-reform rows the ×100 inflates turnover 100× and the envelope mislabels turnover as "net inflow, 10k CNY"; for pre-reform rows the ×100 was correct. One constant factor cannot serve both eras.

What I expected:

  • A dead/empty Eastmoney payload should be detected and treated as provider failure, falling through to the tushare path (or returning an honest error when no fallback is configured) — never ok: true with an empty envelope.
  • The tushare path should pass values through in their real unit (million CNY) with the 2024-08-30 semantics boundary documented in the envelope (net buy before / turnover after), instead of a blanket ×100 under a "10k CNY net inflow" label.

Steps to Reproduce:

  1. NorthboundFlowTool().execute(lookback_days=5) (or the MCP tool get_northbound_flow) with network access — observe ok: true, realtime nulls, history: [], source: "eastmoney".
  2. curl 'https://push2his.eastmoney.com/api/qt/kamt.kline/get?fields1=f1,f3&fields2=f51,f52,f54&klt=101&lmt=10' — observe 0.00 net inflow with a frozen cumulative on every recent day.
  3. With TUSHARE_TOKEN set, call tushare_fallbacks.fetch_northbound_flow(lookback_days=5) directly — values come back ×100 against the HKEX official turnover figures linked above.

Error Logs

bash
# no exception is raised — that is the bug: the failure is silent
{"ok": true, "market": "China A", "source": "eastmoney", "data": {"unit": "10k CNY", "realtime": {"shanghai_connect": null, "shenzhen_connect": null, "total": null}, "history": []}}

Interface: MCP Plugin (also reproducible via Python API)

LLM Provider: n/a (data-layer bug, provider-independent)

Version: main @ d3c29488 (0.1.15)

Environment: macOS 15 / Python 3.12


Proposed fix (PR to follow, scoped minimal):

  1. northbound_tool.py: detect the dead Eastmoney state (realtime all null/zero and history empty/all-zero) and route it into the existing tushare fallback branch with an explanatory warning; when the fallback is unavailable, return an honest ok: false error naming the 2024-08-30 disclosure change instead of an empty success envelope.
  2. tushare_fallbacks.fetch_northbound_flow: drop the ×100, emit unit: "CNY million", and carry a note documenting the semantics boundary (net buy before 2024-08-30 / turnover after, HKEX-verified).
  3. Tests: dead-payload → fallback; healthy legacy-shape payload → eastmoney path preserved; passthrough unit pinned (replacing the ×100 pin).

Southbound is not affected by the disclosure change (HKEX still publishes southbound Buy/Sell Turnover; Eastmoney's southbound daily series cross-checks exactly against it) — a separate feature request will propose a get_southbound_flow tool.