mirror of
https://ghfast.top/https://github.com/aeroxw/easy-tdx.git
synced 2026-09-12 18:04:16 +08:00
feat: merge datetime fields in DataFrame output, hide MinuteBar internal fields
- K-line: daily+ periods output 'date' only, minute periods output 'datetime' - Transactions (tick-by-tick): combine date param + hour/minute into 'datetime' - XdxrRecord, HistoricalFundFlow: year/month/day merged to 'date' - MinuteBar: rename unknown_1 to _unknown_1 (hidden from DataFrame) - MinuteBar: add datetime column computed from bar index (A-share 240-bar pattern) - get_minute_time_data: use history endpoint only (current-day endpoint broken in pytdx too) - Update all examples to reflect new DataFrame column names
This commit is contained in:
@@ -4,16 +4,20 @@
|
||||
"""
|
||||
|
||||
import pandas as pd
|
||||
from easy_tdx import TdxClient, Market
|
||||
from easy_tdx import Market, TdxClient
|
||||
|
||||
with TdxClient.from_best_host() as c:
|
||||
flow = c.get_fund_flow(Market.SH, "600519")
|
||||
df = pd.DataFrame([
|
||||
{"级别": "超大单", "流入(亿)": flow.super_in / 1e8, "流出(亿)": flow.super_out / 1e8},
|
||||
{"级别": "大单", "流入(亿)": flow.large_in / 1e8, "流出(亿)": flow.large_out / 1e8},
|
||||
{"级别": "中单", "流入(亿)": flow.medium_in / 1e8, "流出(亿)": flow.medium_out / 1e8},
|
||||
{"级别": "小单", "流入(亿)": flow.small_in / 1e8, "流出(亿)": flow.small_out / 1e8},
|
||||
])
|
||||
# flow 是单行 DataFrame,转换为万元便于阅读
|
||||
in_cols = ["super_in", "large_in", "medium_in", "small_in"]
|
||||
out_cols = ["super_out", "large_out", "medium_out", "small_out"]
|
||||
df = pd.DataFrame(
|
||||
{
|
||||
"级别": ["超大单", "大单", "中单", "小单"],
|
||||
"流入(亿)": [flow[c].iloc[0] / 1e8 for c in in_cols],
|
||||
"流出(亿)": [flow[c].iloc[0] / 1e8 for c in out_cols],
|
||||
}
|
||||
)
|
||||
df["净流入(亿)"] = df["流入(亿)"] - df["流出(亿)"]
|
||||
print("贵州茅台 当日资金流向:")
|
||||
print(df.to_string(index=False))
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
"""演示:获取个股历史日线资金流向序列。"""
|
||||
|
||||
import pandas as pd
|
||||
from easy_tdx import TdxClient, Market
|
||||
from easy_tdx import Market, TdxClient
|
||||
|
||||
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])
|
||||
df = c.get_history_fund_flow(Market.SH, "600519", 0, 10)
|
||||
print(f"贵州茅台 历史资金流向,共 {len(df)} 天:")
|
||||
print(df.to_string(index=False))
|
||||
|
||||
Reference in New Issue
Block a user