数据管理 API
基础信息
- Base URL:
http://localhost:6789/api/v1/datamgr - 前端页面:
src/pages/DataManager/index.tsx
统计与维护
GET /datamgr/stats
获取所有受监控数据表的记录数统计(_ALL_TABLES 白名单,当前 50 张表)。
响应(整个 payload 落在信封 results 内):
{
"ok": true,
"schema_version": 1,
"results": {
"_totalRows": 125680,
"fox_kline_daily": {"count": 98000, "latestUpdate": "2026-09-18 15:35:00"},
"fox_quote_snapshot": {"count": 5200, "latestUpdate": "2026-09-18 14:55:00"},
"sina_financial_indicator": {"count": 8500, "latestUpdate": "2026-06-30 00:00:00"},
"...": "共 50 张表"
},
"data_availability": {"kline": false, "valuation": false, "moneyflow": false, "quote": false, "finance": false},
"disclaimer": "数据仅供参考,不构成投资建议。"
}
统计口径:逐表 COUNT(*) + 时间列(updated_at,缺失则 imported_at)的 MAX;单表查询失败时该表记为 {"count": 0, "latestUpdate": null, "error": "..."},不影响其余表。
GET /datamgr/stats/{code} 与 GET /datamgr/stats/{code}/full
获取指定股票的数据完整性状态。两个端点当前返回同一份结果,覆盖 _STOCK_DATA_DIMENSIONS
的 26 类维度(另有 f10 一条,合计 24 个键)。
响应(信封 results 内):
{
"code": "600519",
"dataStatus": {
"kline": {"count": 250, "latestDate": "2026-09-18"},
"quote": {"count": 120, "latestDate": "2026-09-18"},
"fin_indicator": {"count": 8, "latestDate": "2026-03-31"},
"f10": {"count": 1, "latestDate": "2026-09-20 16:03:11"},
"...": "共 26 类维度 + f10"
}
}
/stats/freshness 必须注册在 /stats/{code} 之前:FastAPI 按注册顺序匹配,
否则路径参数 {code} 会吞掉静态段 freshness(历史 bug:该端点曾长期恒返回
code="freshness" 的单股统计)。
GET /datamgr/stats/freshness
数据新鲜度健康检查:按 _FRESHNESS_DIMENSIONS 的 52 类维度逐一比对「最新数据日期 vs 容忍 cutoff」。
容忍度按维度分级(不再是一刀切的 T/T-1):
| kind | 语义 | cutoff 计算 | 典型维度(max_lag 交易日/自然日) |
|---|---|---|---|
trading | 高频/中频行情类 | 最近交易日往前回推 max_lag 个交易日(节假日/周末自动跳过) | fox_kline_daily(1)、fox_stock_wide(1)、fox_valuation(1)、fox_margin(2)、fox_index_daily(2)、fox_dragon_tiger(3)、fox_block_trade(7) |
calendar | 公告/新闻/低频披露类 | 今日往前 max_lag 个自然日(周末也可能发布) | fox_announcement(3)、fox_news(3)、fox_dividend(30)、fox_stock_master(7)、cninfo_periodic_report(90) |
period | 财报类 | 解析最新报告期 + max_lag 天披露滞后 | fox_finance_indicator(90) |
响应(整个 payload 落在信封 results 内,该端点无 items/data 键):
{
"ok": true,
"results": {
"isFresh": true,
"staleDimensions": [],
"details": {
"fox_kline_daily": {"latestDate": "2026-09-18", "cutoff": "2026-09-17", "isStale": false},
"fox_quote_snapshot": {"latestDate": "2026-09-18", "cutoff": "2026-09-17", "isStale": false},
"fox_fund_flow_daily": {"latestDate": "2026-09-18", "cutoff": "2026-09-17", "isStale": false},
"fox_finance_indicator": {"latestDate": "2026-06-30", "cutoff": "2026-06-23", "isStale": false}
}
},
"disclaimer": "数据仅供参考,不构成投资建议。"
}
当 isFresh: false 时,staleDimensions 列出过期维度名,前端据此提示用户执行数据同步。
单维度检查异常时该维度记 {"latestDate": null, "cutoff": null, "isStale": false, "error": "..."}(不误报过期)。
freshness_snapshot 定时任务(19:30)把同一份结果幂等落库到 app_data_freshness_log,供历史轨迹查询。
POST /datamgr/cleanup
清理历史数据(需管理员)。
请求体:
{"days": 365}
或按表清理(table 名为表名,如 fox_kline_daily;不传则清理全部时序表):
{"table": "fox_kline_daily", "days": 180}
GET /datamgr/sync-logs?limit=30
获取最近的数据同步日志(limit 默认 50)。返回值为列表,信封包装后列表落在 results:
{
"ok": true,
"results": [
{"id": 1, "taskType": "kline", "code": "600519", "status": "success",
"total": 120, "success": 120, "failed": 0, "message": "无缺口",
"startedAt": "2026-09-18 15:35:02", "finishedAt": "2026-09-18 15:35:06"}
],
"stats": {"total": 1}
}
定时任务写入的日志 taskType 带 sched: 前缀(如 sched:eod_core)。
数据下载
POST /datamgr/download/{code}
下载指定股票的数据。通过 types 查询参数指定下载类型:
POST /datamgr/download/600519?types=kline
POST /datamgr/download/600519?types=all # 全量下载
支持的 types 枚举值(_DOWNLOAD_TYPE_MAP,共 38 种 + all):
| types | 下载内容 | 目标表 | 模式 |
|---|---|---|---|
kline | 日K线(腾讯前复权主源) | fox_kline_daily | 批量 UPSERT(code+date) |
quote | 行情快照 | fox_quote_snapshot | UPSERT |
valuation | 估值 | fox_valuation(融合器) | 融合 UPSERT |
fund_flow | 资金流向 | fox_fund_flow_daily | UPSERT |
minute_kline | 分钟K线 5/15/30/60min | tdx_kline_minute | 批量 UPSERT |
reports | 研究报告 | em_research_report | UPSERT |
dragon_tiger | 龙虎榜 | em_dragon_tiger | UPSERT |
margin | 融资融券 | em_margin_trading | UPSERT |
holder_num | 股东人数 | em_holder_num | UPSERT |
lockup | 限售解禁 | em_lockup_expiry | UPSERT |
block_trade | 大宗交易 | em_block_trade | UPSERT |
dividend | 分红历史 | em_dividend_history | UPSERT |
concept_blocks | 概念板块 | em_concept_block | UPSERT |
northbound | 北向资金 | em_northbound_daily | UPSERT |
announcements | 公司公告 | cninfo_announcement | 唯一键 (code,title,pub_date) UPSERT |
news | 个股新闻 | fox_news(融合器 API 驱动) | 融合 UPSERT |
finstmt | 财务报表三表 | sina_financial_statement | UPSERT |
fin_indicator | 财务指标 | sina_financial_indicator | UPSERT |
issue_info | 发行信息 | em_stock_issue_info | UPSERT |
holding_org | 机构持股 | em_stock_holding_org | UPSERT |
top_holders | 十大流通股东 | em_top_float_holder | UPSERT |
earnings_forecast | 盈利预测 | em_earnings_forecast | UPSERT |
earnings_express | 业绩快报 | em_earnings_express | UPSERT |
executive_holding | 高管持股 | em_executive_holding | UPSERT |
org_survey | 机构调研 | em_org_survey | UPSERT |
fund_holding | 基金持仓 | em_fund_holding | UPSERT |
ths_profile | 同花顺 F10 公司资料 | ths_f10_profile | 快照 UPSERT |
ths_finance_changes | 同花顺财务变动解读 | ths_f10_finance | 逐期 UPSERT |
ths_holders | 同花顺股东 | ths_f10_holders | 逐期 UPSERT |
ths_bonus | 同花顺分红送转 | ths_f10_bonus | 逐期 UPSERT |
ths_operate | 同花顺经营分析 | ths_f10_operate | 逐期 UPSERT |
ths_worth | 同花顺估值 | ths_f10_worth | 逐期 UPSERT |
ths_equity | 同花顺股本结构 | ths_f10_equity | 逐期 UPSERT |
ths_news | 同花顺新闻/研报 | ths_f10_news | 逐条 UPSERT |
ths_capital | 同花顺资金 | ths_f10_capital | 逐条 UPSERT |
ths_lhb | 同花顺龙虎榜 | ths_f10_lhb | 逐条 UPSERT |
ths_rzrq | 同花顺两融 | ths_f10_rzrq | 逐条 UPSERT |
ths_dzjy | 同花顺大宗交易 | ths_f10_dzjy | 逐条 UPSERT |
all | 全部类型(除市场级 northbound 外逐一执行) | 以上所有表 | 逐一执行 |
响应(数据在信封 results 内):
{"ok": true, "results": {"status": "success", "total": 120, "saved": 100, "gap_count": 0}}
未知 types 返回 {"error": "未知类型: xxx"}。
下载完成后自动按本次下载的 types 映射触发对应 fox_ 融合(如 kline→kline_bar、quote→stock_master、finstmt/fin_indicator→finance_indicator、ths_lhb→dragon_tiger 等,无映射类型如 minute_kline 自动跳过),结果写入 results["fox_fusion"]:
{
"status": "success", "total": 120, "saved": 100,
"fox_fusion": {
"status": "success", "batch_id": "fox_api_20260819_224337_fe08",
"results": {
"stock_master": {"status": "success", "saved": 1},
"kline_bar": {"status": "success", "saved": 240}
}
}
}
融合为一次批次(batch_id 落 fox_data_batch,trigger_type=api),任务与落库记录贯穿 fox_sync_task / fox_data_record;融合失败不影响下载结果。
POST /datamgr/download-batch
批量下载多只股票数据。
请求体:
{
"codes": ["600519", "000001", "300750"],
"taskTypes": ["kline", "quote", "finstmt"]
}
响应: 同单股下载,下载完成后按本次 taskTypes 映射自动触发对应 fox_ 融合(去重后一次批次),results["fox_fusion"] 含 batch_id 与各融合类型结果。
POST /datamgr/download/market/northbound
下载北向资金日级数据(全市场级别,非个股)。
全A股基础数据
stock_base_info(149 字段 TDX 全量导出)与精简表 stock_info 已于 2026-08-22 移除,
下列端点全部退化为兼容壳,恒定返回 {"status": "deprecated", "message": "..."},
不再写任何表;多数附带一个计数键(imported / synced / backfilled / count 恒为 0),
fetch-staging / promote / sync-tdx 等只回 status + message:
| 端点 | 原用途 | 现状 |
|---|---|---|
POST /datamgr/stock-base/import | 通达信导出文件导入 | 保留扩展名/大小校验(.xls/.xlsx/.csv/.tsv/.txt,≤50MB),随后返回 deprecated |
POST /datamgr/stock-base/sync | 东财 clist 在线同步 | deprecated |
POST /datamgr/stock-base/sync-tencent | 腾讯全A排行同步 | deprecated(全市场行情现由 tencent_market_sync 定时任务写 tencent_stock_quote_daily,再由 fox_wide_sync 融合) |
POST /datamgr/stock-base/sync-tdx | TDX 行业映射/上市日期同步 | deprecated |
POST /datamgr/stock-base/sync-full | 腾讯行情 + Excel 基本面全量 | 保留上传校验(扩展名同 import、≤50MB、非空),随后返回 deprecated |
POST /datamgr/stock-base/backfill | 补齐 OHLC/PE/PB/行业/月涨幅 | deprecated(相应字段由 fox 融合链统一提供) |
POST /datamgr/stock-base/fetch-staging | 阶段1 staging 拉取 | deprecated |
POST /datamgr/stock-base/promote | 阶段2 staging→base | deprecated |
GET /datamgr/stock-base/staging | staging 摘要 | 恒返回 {"status": "deprecated", "count": 0} |
POST /datamgr/stock-base/backfill-stock-info | 精简表回填 | deprecated(原实现在函数不存在时仍会被调用,已改为直接返回提示) |
全A股数据的正确获取路径:定时任务 fox_wide_sync(16:20)融合
fox_stock_master / fox_stock_wide,或手动触发 POST /datamgr/fox/sync。
GET /datamgr/stock-base/list
分页查询全A股行情列表(数据源:fox_stock_wide 融合宽表,非已删除的 stock_base_info)。
路径在 EnvelopeMiddleware._ENVELOPE_SKIP_EXACT 中,响应不包裹信封,
直接透传原始 {data, items, total, page, pageSize, industries, latestDate}——
否则信封会拆走 results 并丢掉分页元数据(items 与 data 同值,为兼容旧解包方保留)。
参数:
| 参数 | 说明 |
|---|---|
page / pageSize | 页码(≥1)/ 每页条数(10~200,默认 50) |
keyword | 代码前缀或名称模糊 |
industry | 腾讯三级行业名称筛选(来自 fox_stock_wide.industry) |
sw_l1 / sw_l2 | 申万一级/二级行业代码筛选(如 801010/801012),按需 JOIN fox_industry;每行附带 sw_l1/sw_l2 代码与 sw_l1_name/sw_l2_name 名称 |
sort | 排序 key:change_desc/change_asc/price_desc/price_asc/amount_desc/volume_desc/cap_desc/cap_asc/turnover_desc/pe_desc/main_desc/main_asc(默认涨幅降序) |
codes | 逗号分隔精确代码列表(上限 500 只) |
price_min/price_max | 价格区间 |
change_min/change_max | 涨跌幅区间(%) |
cap_min/cap_max | 流通市值区间(万元,内部换算为元比较) |
fields | 保留兼容参数,实现始终返回核心全量字段 |
响应:
{
"data": [{"code": "000001", "name": "平安银行", "current_price": 12.5, "change_pct": 1.2,
"total_volume": 123456, "float_market_cap": 2400000.0, "sw_l1": "801780", "sw_l1_name": "银行", "...": "..."}],
"items": [ "同上(兼容别名)" ],
"total": 5280,
"page": 1,
"pageSize": 50,
"industries": ["银行", "房地产", "医药生物", "..."],
"latestDate": "2026-09-18T16:22:41"
}
单位口径:市值 元 → 万元、成交量 股 → 手(保持旧契约,前端无需换算);
latestDate 为宽表 MAX(updated_at)(融合新鲜度)。DB 不可用或查询异常时返回同结构的空结果并带 status: "deprecated" + message。
TDX 数据接口(通达信 TCP,项目自实现协议)
以下接口基于项目自实现的 TDX 协议客户端(backend/app/services/data_sources/tdx/,
TCP 7709,零第三方依赖;TDX 协议已全量自实现)直连通达信服务器,
不封 IP、无需 HTTP 限流。
POST /datamgr/finance/sync-tdx — [已废弃]
原为「通达信批量财务 → stock_base_info」。表已移除,恒定返回 deprecated;
财务数据现由 fox_finance_indicator 融合器产出(新浪主源 + TDX 快照兜底)。
请求体(可选,仍接受但不再写表):
{"codes": ["600519", "000001", "300750"]}
POST /datamgr/block/sync
从通达信同步板块数据到 tdx_block_info 表(按 block_type 先删后写:zs 指数板块 /
gn 概念板块 / fg 风格板块,源文件 block_zs.dat、block_gn.dat、block_fg.dat)。
响应:
{
"status": "success",
"total": 450,
"saved": 450,
"message": "板块同步完成:450 个板块"
}
GET /datamgr/market/stat
获取A股全市场涨跌统计(TDX TCP 协议实时获取,不封IP)。
响应:
{
"up_count": 3200,
"down_count": 1500,
"neutral_count": 380,
"suspended_count": 25,
"total_count": 5105,
"limit_up_count": 68,
"limit_down_count": 12,
"total_amount": 1250000000000,
"total_volume": 89000000000,
"total_market_cap": 95000000000000
}
GET /datamgr/stock/{code}/xdxr
获取个股除权除息历史(分红送转、股本变动)。
响应:
{
"code": "600519",
"records": [
{"date": "20240620", "category": 1, "name": "分红", "hongli": 30.876, "peigujia": 0, "songzhuangu": 0, "peigu": 0},
{"date": "20230621", "category": 1, "name": "分红", "hongli": 25.911, "peigujia": 0, "songzhuangu": 0, "peigu": 0}
]
}
GET /datamgr/stock/{code}/fund-flow?days=20
获取个股资金流向(当日四级资金流 + 历史日线资金流)。
参数:
days: 历史天数(1~120,默认 20)
响应:
{
"code": "600519",
"today": {
"super_large_in": 150000000,
"super_large_out": 80000000,
"large_in": 200000000,
"large_out": 180000000,
"medium_in": 100000000,
"medium_out": 120000000,
"small_in": 50000000,
"small_out": 90000000
},
"history": [
{"date": "2026-07-18", "main_inflow": 350000000, "main_netflow": 120000000}
]
}
实时数据(不入库)
GET /datamgr/realtime/{code}/quote
个股实时盘口行情。
GET /datamgr/realtime/{code}/minute-kline?period=5
分钟K线(period: 1/5/15/30/60)。
GET /datamgr/realtime/{code}/fund-flow-minute
分钟级资金流向。
GET /datamgr/realtime/northbound
北向资金实时分钟流向。
市场级数据
GET /datamgr/market/industry-ranking?top_n=20
全行业涨跌幅排名(实时拉取,不入库)。
GET /datamgr/market/global-news?page_size=50
东财 7x24 滚动快讯。
GET /datamgr/market/hot-stocks
同花顺当日强势股 + 题材标签。
fox_ 融合层(统一数据处理引擎)
fox_ 融合层将各数据源原始表(ODS)经多源交叉验证融合为 fox_* 标准表(DWD),应用层只读融合结果。架构:ODS → DWD(fox_*) → 应用只读,幂等 UPSERT,冲突/缺失记 fox_data_quality。
POST /datamgr/fox/sync
触发 fox_ 融合层同步(需 admin)。不传 codes 时全市场全量融合(21 类,耗时 1h+);
传 codes 仅融合指定股票(≤500 只,快)。融合为幂等 UPSERT,可重复触发,
冲突/缺失写入 fox_data_quality。
请求体(可选):
{"codes": ["600519", "000001"]}
响应(202 Accepted,后台线程执行,不再阻塞请求):
{"ok": true, "results": {"status": "accepted", "mode": "full_market",
"message": "已提交后台融合", "codes": null}}
- 全市场模式需同时持有三域锁(K线域/事件市场域/宽表域),任一被占 →
409; - 指定股票模式仅防两次手动融合重叠(不强占域锁)。
- 进度查
GET /datamgr/fox/status的recent_tasks。
手动融合会创建批次(fox_data_batch,trigger_type=manual)。批次血缘:
fox_data_batch(批次元数据,trigger_type ∈ manual/scheduled/api)→
fox_sync_task.batch_id(任务级)→ fox_data_record.batch_id(落库表级,target_table
由融合器模型推导),可审计「下载批次 → 融合任务 → 落库表」全链路。
GET /datamgr/fox/status
fox_ 融合层状态概览(各表行数 / 质量统计 / 最近任务)。
GET /datamgr/fox/stock/{code}
查询单只股票 fox_ 融合层全维度数据:master(主数据)+ profile(公司概况)+ finance(财务指标近 8 期,降序)。code 无融合记录时返回 404。
响应(信封 results 内):
{
"code": "600519",
"master": {"name": "贵州茅台", "total_shares": 1250080000, "float_shares": 1250080000, "quality": "warning"},
"profile": {"code": "600519"},
"finance": [
{"report_period": "2026-08-15", "revenue": 90703264000, "net_profit": 44516880000},
{"report_period": "2026-06-30", "revenue": 92278000000, "net_profit": 44517000000}
],
"latest_finance": {"report_period": "2026-08-15", "revenue": 90703264000},
"quality": {"master": "warning", "profile": "ok", "finance": "ok"}
}
GET /datamgr/fox/stock/{code}/finance?periods=8
查询单只股票 fox_ 财务指标序列(升序,旧→新,供图表绘制)。periods 1~20,默认 8。
响应: results 为该股票的财务指标列表,periods 为期数:
{
"code": "000858",
"periods": 1,
"results": [
{"report_period": "2026-08-11", "revenue": 22838024000, "net_profit": 8062765000, "eps": null, "bvps": 32.975}
]
}
GET /datamgr/fox/stock/{code}/valuation?snapshots=20
查询单只股票 fox_ 估值融合结果:valuation(最新估值行,腾讯 quote 主源 + 东财扩展字段)+ snapshots(近 N 期主源行情快照,升序,供趋势绘图)。snapshots 1~60,默认 20。code 无估值记录时返回 404。
响应: 信封 results 内为 {code, valuation, snapshots, total_snapshots}:
{
"code": "600519",
"valuation": {"code": "600519", "pe_ttm": 19.93, "pb": 6.46, "total_market_cap": 1622593367309.38, "price": 1297.99, "as_of_date": "2026-08-18", "quality": "ok"},
"snapshots": [
{"date": "2026-07-30", "price": 1301.5, "pe_ttm": 20.11, "pb": 6.52, "total_market_cap": 1620100000000.0},
{"date": "2026-08-18", "price": 1297.99, "pe_ttm": 19.93, "pb": 6.46, "total_market_cap": 1622593367309.38}
],
"total_snapshots": 2
}
GET /datamgr/fox/stock/{code}/industry
查询单只股票 fox_ 行业归属(多口径:腾讯一级 industry 主源 + 东财 em_industry + 通达信 tdx_industry + 申万代码 sw_l1/sw_l2)。code 无融合记录时返回 404。
响应: 信封 results 内为行业行:
{
"code": "600519",
"name": "贵州茅台",
"industry": "酿酒行业",
"em_industry": "",
"tdx_industry": "",
"sw_l1": "801120",
"sw_l2": "801121",
"quality": "ok"
}
sw_l1/sw_l2 为申万一级/二级行业代码(名称映射见 /industry/class/list)。
GET /datamgr/fox/stock/{code}/holder?periods=20
查询单只股票 fox_ 股东户数历史序列(升序,旧→新;东财全历史 + 通达信最新期补充)。periods 1~60,默认 20。无数据时返回空序列。
响应: 信封 results 为 items 列表,periods 在信封层:
{
"code": "600519",
"periods": 2,
"results": [
{"date": "2026-04-30", "holder_num": 301230, "change_num": -10000, "change_ratio": -3.21, "avg_shares": 41500.0},
{"date": "2026-08-15", "holder_num": 296404, "change_num": null, "change_ratio": null, "avg_shares": null}
]
}
GET /datamgr/fox/stock/{code}/dividend
查询单只股票 fox_ 分红送转历史(降序,新→旧;bonus_rmb 为每 10 股派息口径,元)。无数据时返回空序列。
响应: 信封 results 为 items 列表,total 在信封层 stats:
{
"code": "600519",
"results": [
{"ex_date": "2025-12-19", "bonus_rmb": 2395.7, "transfer_ratio": null, "bonus_ratio": null, "progress": "实施分配"},
{"ex_date": "2025-06-26", "bonus_rmb": 2767.3, "transfer_ratio": null, "bonus_ratio": null, "progress": "实施分配"}
]
}
GET /datamgr/fox/stock/{code}/dragon-tiger?periods=30
查询单只股票 fox_ 龙虎榜事件(降序,新→旧;东财 em_dragon_tiger 主源 + 同花顺 ths_f10_lhb 横向补充,net_buy 单位为万元)。periods 1~120,默认 30。无数据时返回空序列。
响应: 信封 results 为 items 列表,total 在信封层 stats:
{
"code": "000007",
"results": [
{"date": "2026-07-07", "reason": "日振幅值达到15%的前5只证券", "net_buy": -2702.2, "turnover": 4.85, "close": null, "next_change_pct": null, "buy_amt": null, "sell_amt": null, "quality": "ok"}
]
}
GET /datamgr/fox/stock/{code}/margin?periods=30
查询单只股票 fox_ 融资融券日级序列(升序,旧→新,供趋势绘图;东财 em_margin_trading 主源 + 同花顺 ths_f10_rzrq 交叉验证,金额单位为元)。periods 1~120,默认 30。无数据时返回空序列。
响应: 信封 results 为 items 列表,periods 在信封层:
{
"code": "000001",
"periods": 5,
"results": [
{"date": "2026-06-14", "rzye": 5215285121.0, "rzmre": 127290581.0, "rqye": 18597256.0, "rzrqye": 5238689681.0, "fin_ratio_pct": null, "loan_volume": null}
]
}
GET /datamgr/fox/stock/{code}/block-trade?periods=50
查询单只股票 fox_ 大宗交易历史(降序,新→旧;东财 em_block_trade 主源 + 同花顺 ths_f10_dzjy 横向补充,金额单位为元,volume 为股)。periods 1~200,默认 50。无数据时返回空序列。
响应: 信封 results 为 items 列表,total 在信封层 stats:
{
"code": "300938",
"results": [
{"date": "2026-04-14", "buyer": "国泰海通证券股份有限公司北京德外大街证券营业部", "seller": "华泰证券股份有限公司深圳益田路荣超商务中心证券营业部", "price": 32.7, "volume": 240000, "close": 45.02, "premium_pct": -27.37, "amount": 7848000.0, "quality": "ok"}
]
}
GET /datamgr/fox/stock/{code}/announcements?periods=30
查询单只股票 fox_ 公告历史(降序,新→旧,按发布日期;巨潮 cninfo_announcement 主源单源标准化,备源 szse_official/em_announcement 待接入)。periods 1~120,默认 30。无数据时返回空序列。
响应: 信封 results 为 items 列表,total 在信封层 stats:
{
"code": "000007",
"results": [
{"pub_date": "2026-08-14", "title": "关于董事、副总经理辞职的公告", "ann_type": "", "url": "https://www.cninfo.com.cn/new/disclosure/detail?annoId=1225472378", "quality": "ok"},
{"pub_date": "2026-07-15", "title": "深圳市全新好股份有限公司2026年半年度业绩预告", "ann_type": "", "url": "https://www.cninfo.com.cn/new/disclosure/detail?annoId=1225422735", "quality": "ok"}
]
}
GET /datamgr/fox/stock/{code}/news?periods=30
查询单只股票 fox_ 新闻/研报列表(降序,新→旧,按发布时间;eastmoney_stock_news() API 主源透传 news + ths_f10_news 同花顺研报 JSON 展开补录 research,标题等价去重,研报带 rating/researcher)。纯 API 驱动,不依赖 stock_news ODS 表。periods 1~120,默认 30。无数据时返回空序列。
响应: 信封 results 为 items 列表,total 在信封层 stats:
{
"code": "002594",
"results": [
{"pub_time": "2026-08-07", "title": "国海证券:公司动态研究:7月海外销量续创新高,国内新车放量或开启", "content": "", "source": "国海证券", "url": "http://news.10jqka.com.cn/field/sr/19700101/59164945.shtml", "news_type": "research", "rating": "买入", "researcher": "戴畅", "quality": "ok"},
{"pub_time": "2026-07-15 21:38:00", "title": "5只个股大宗交易超5000万元", "content": "3.25 4.45 ...", "source": "证券时报网", "url": "http://finance.eastmoney.com/a/202607153807764123.html", "news_type": "news", "rating": "", "researcher": "", "quality": "ok"}
]
}
GET /datamgr/fox/stocks?codes=600519,000858
批量查询 fox_ 融合摘要(master 核心字段 + 最新一期财务关键指标),单次上限 500 只。
响应: results 内为 stocks 数组(每只股票一条摘要)+ total 总数。
fox_ 时序融合层(日级及以上低频 K 线)
时序融合层承载"对新鲜度要求不高"的时序数据(日/周/月/季/年),应用读取优先走本层;分钟级/盘中 bar 不纳入,继续走 TDX TCP / 腾讯实时接口。
GET /datamgr/fox/index/daily?codes=sh000001,sz399001&periods=240&ascending=true
批量查询大盘指数日线序列(fox_index_daily,腾讯 HTTP 主源不复权)。codes 腾讯格式(sh000001/hkHSI/us.DJI),单次上限 20 只,默认 A 股三大宽基;periods 每只返回根数 1~1500,默认 240;ascending=true 升序(旧→新,供绘图)/ false 降序。
响应:
{
"total": 240,
"items": [
{"code": "sh000001", "date": "2026-08-19", "name": "上证指数", "open": 3952.12, "close": 3894.42, "high": 3961.14, "low": 3879.58, "volume": 572191213.0, "amount": 0.0, "quality": "ok"}
]
}
POST /datamgr/fox/index/daily/sync
手动触发大盘指数日线同步(需 admin,腾讯 HTTP,约 30 只核心指数,耗时约 10~30s)。不传参数,同步完成返回 {status, total, warning, scope}。
GET /datamgr/fox/stock/{code}/kline-bar?period=week&periods=240&ascending=true
查询单只股票多周期 K 线(fox_kline_bar:腾讯前复权 HTTP 主源)。period 仅支持 week/month/quarter/year(日 K 线请走 /api/v1/stocks/kline,分钟级 K 线走 TDX TCP 实时接口)。periods 1~1500,默认 240;ascending 同指数日线。前端 KLineSection 周/月/季/年周期已切换读本端点(getFoxKlineBar,空数据/失败回退日线聚合)。
响应:
{
"code": "600519",
"period": "week",
"total": 240,
"items": [
{"period": "week", "date": "2026-08-19", "open": 1295.0, "close": 1307.88, "high": 1308.88, "low": 1280.34, "volume": 38294000.0, "amount": 5025810000.0, "bar_count": null, "quality": "ok"}
]
}
POST /datamgr/fox/stock/{code}/kline-bar/sync
手动触发单只股票多周期 K 线同步(需 admin,周/月/季/年 4 个周期各拉 ~240 根,季/年由月线内存聚合)。
GET /datamgr/fox/interfaces
数据引擎能力清单(无需 admin,machine-readable,供外部应用自发现)。
当前注册 180 个只读接口(FOX_INTERFACES)。返回元数据:name(接口名)/
dimension(stock/timeseries/market)/ params(参数名/类型/必填/默认值/说明)/
returns(返回结构)/ ttl(进程缓存秒数)。写/管理接口(persist_daily/invalidate)不对外暴露。
POST /datamgr/fox/call
统一数据服务调用(无需 admin,Tushare pro.xxx 模式:接口名 + 参数动态调用)。仅开放只读查询接口(get_*);参数错误 422、未知接口 404、写接口 403、执行异常 500。
请求:
{"interface": "get_stock_profile", "params": {"code": "600519"}}
响应: 接口返回值(plain dict / list[dict] / float / null),与对应 /datamgr/fox/* 端点返回结构一致。
错误示例:
{"detail": "接口 get_stock_profile 缺少必填参数: code"} // 422
{"detail": "未知数据接口: get_foo"} // 404
{"detail": "接口 persist_daily 为写/管理接口..."} // 403
fox_ 实时/信号路由(直连实时数据源,不落融合表)
实时类数据不进入 fox_ 低频融合层(DWD),但由 fox_engine 门面统一路由(ttl=None 不缓存),与 /datamgr/fox/call 的 get_* 接口等价,提供直接 HTTP 入口。失败时返回空结构(引擎层静默降级),消费方自行兜底。
GET /datamgr/fox/market/realtime-quote?codes=600519,000001
实时行情快照(腾讯 qt.gtimg.cn 主源,同步批量,单次上限 600)。覆盖 A股/ETF/港股/指数。
响应:
{
"600519": {"name": "贵州茅台", "price": 1291.5, "open": 1299.8, "high": 1306.88, "low": 1291.0, "last_close": 1307.88, "change_pct": -1.25, "turnover_pct": 0.2, "pe_ttm": 21.3, "pb": 7.8, "mcap_yi": 16223.0, "limit_up": 1438.67, "limit_down": 1177.09}
}
GET /datamgr/fox/market/limit-up?date=20260818
涨停板池(东财 push2ex 独有数据,getTopicZTPool)。date 为 YYYYMMDD,缺省最近交易日。返回涨停池原始列表。
GET /datamgr/fox/market/industry-ranking?top_n=20
行业板块涨跌排名(腾讯 getRank 主源,失败自动降级新浪/东财)。top_n 1~100,默认 20。返回 {top, bottom, total}。
GET /datamgr/fox/stock/{code}/lockup?forward_days=90
限售解禁日历(东财独有数据)。forward_days 1~365,默认 90,返回未来 N 日内的解禁事件。
GET /datamgr/fox/market/northbound
北向资金实时概况(东财独有数据)。返回各通道净买入列表。
系统探针
GET /datamgr/probe-all
一键探测所有核心数据源连通性(需管理员;code 参数供需要股票代码的源使用,默认 600519)。
并发探测 18 个探针(线程池 8 并发,保持输入顺序):TDX TCP K线、腾讯实时行情、 东财 em_get 连通、同花顺热点归因、东财资金流(120d)、东财龙虎榜、北向资金实时、 行业板块排名、东财全球资讯、百度 K线(MA)、涨停板池、跌停板池、炸板板池、 财联社快讯、同花顺 7x24 快讯、东财人气榜、东财概念命中、东财研报列表。
响应:
{
"sources": [
{"name": "腾讯实时行情", "ok": true, "latency_ms": 95, "sample_count": 1},
{"name": "TDX TCP K线", "ok": true, "latency_ms": 45, "sample_count": 5},
{"name": "东财人气榜", "ok": false, "latency_ms": 1203, "error": "..."}
],
"summary": {"ok": 16, "fail": 2},
"counters": {"tencent_quote": {"ok": 12, "fail": 0}, "...": "进程内健康计数"},
"breakers": {
"em_breaker": {"state": "CLOSED", "failure_count": 0},
"push2ex_breaker": {"state": "CLOSED", "failure_count": 0}
}
}
单探针失败不影响其余探针(各自捕获异常,错误截断至 200 字);breakers 暴露
东财与 push2ex 熔断器状态,便于区分「数据源真挂了」与「本进程已熔断暂缓请求」。
配置管理
GET /datamgr/config
获取系统配置项。
PUT /datamgr/config
更新配置项。
请求体:
{"key": "DATA_SOURCE", "value": "real"}