Files
easy-tdx/examples/08_fund_flow/history_fund_flow.py
T
GitHubandClaude Opus 4.7 7fd6e610cf feat: add examples (01-08), fix index bars parsing, add ruff hook
- Add example scripts for all API categories (connection, market info,
  kline, minute, transaction, finance, block, fund flow)
- Fix GetIndexBarsCmd: index bar records have 4 extra bytes (advance/
  decline counts) that were not consumed, causing pos drift and
  corrupted dates/volumes for all records after the first
- Fix price_limits.py example (SecurityQuote has no name attr)
- Fix finance_info.py display (scientific notation -> formatted numbers)
- Add PostToolUse ruff hook (scripts/ruff_hook.py)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 18:36:50 +08:00

16 lines
622 B
Python

"""演示:获取个股历史日线资金流向序列。"""
import pandas as pd
from xmtdx import TdxClient, Market
with TdxClient.from_best_host() as c:
flows = c.get_history_fund_flow(Market.SH, "600519", 0, 10)
df = pd.DataFrame([{
"日期": f"{f.year}-{f.month:02d}-{f.day:02d}",
"超大单净流入(亿)": (f.super_in - f.super_out) / 1e8,
"大单净流入(亿)": (f.large_in - f.large_out) / 1e8,
"主力净流入(亿)": f.main_net_inflow / 1e8,
} for f in flows])
print(f"贵州茅台 历史资金流向,共 {len(df)} 天:")
print(df.to_string(index=False))