跳转至

资金流策略

来源同步:/Users/mac/Projects/chatgpt-codex/doc/api_StrategyFlow.md

所属接口集:资金流策略

GET /v1/api/strategy/flow

认证方式

Bearer Token(详见 认证与签名

接口概述

GET /v1/api/strategy/auction/today 同源数据strategy:auction Redis 哈希 + 同花顺 bigorder_1)构建的轻量策略模型接口。默认按 bigorder_main_net(主力净流入金额)降序。

相对 auction/today 的加速点: - 不取 chip_peak_daily_5d(跳过筹码峰日表与 detail 重计算) - 不输出 sectors - 仅保留五红 / 开盘策略,并按 bigorder_1 打上 flow_state / flow_state_code - 与 auction 同源输出 bigorder_main_net(主力净流入金额)

按 day 查历史(与 auction/today 一致)

支持 ?day=YYYYMMDD 查询历史,日期口径与 GET /v1/api/strategy/auction/today 相同:

概念 说明
请求 day 查询日,默认今日
redis_day 交易日则等于 day;非交易日回溯上一交易日(响应字段 data.redis_day
策略候选 {prefix}:strategy:auction:{redis_day}:*
bigorder_1 仅交易日当天走 Redis ths:bigorder非交易日 / 历史交易日一律 MySQL monitor_ths_bigorder_detail(与 auction/today 一致;明细含入库 change_pct 并重建简版 price_series;本接口只用于分类,不输出)
bigorder_main_net 与上同一数据源;Σ amount(trade_type=1) − Σ amount(trade_type=2)(元),输出在 items[]
行情补充 monitor:bigdata / 1m state 取「最近交易日」live_day(与 auction/today 相同,非历史快照重放)

因此:只要对应 redis_day 的策略哈希与(历史)大单数据仍在,即可按 day 回看;空结果通常表示该日无策略候选或大单不可用,而非接口不支持历史。

请求参数

参数 类型 必填 说明
day string YYYYMMDD,默认今日;历史查询口径见上表
page int 页码,默认 1
page_size int 每页条数,默认 100,范围 1–500
limit int 兼容旧参数:未传 page/page_size 时当作 page_size
sort string 排序字段,默认 bigorder_main_net。可选 tspct_chgbigorder_net_shares_todaytoday_vol_ratiopre_vol_ratiopre_price_speed_ratioprice_speed_ratioamountvol
order string asc / desc,默认 desc
flow_state_code string 按英文码过滤;支持单个或多个逗号分隔(如 accumulation,rally)。非法码忽略。不影响 flow_state_counts(仍按全日未按码过滤前汇总)
include_unclassified bool 1/true 时保留未能分类的样本(flow_state/flow_state_code 为 null);默认只返回已分类

分页与模型数量统计

响应 data 始终包含(与 auction/today 分页字段对齐):

字段 说明
page / page_size 当前页与每页条数
total 当前筛选条件下的条目总数(应用 flow_state_code 等过滤后)
total_pages 总页数,ceil(total / page_size)
flow_state_counts 各模型全日汇总(过滤 flow_state_code 之前),键见下表,缺省为 0

flow_state_counts 固定键:

中文
accumulation 吸筹
inducement 诱多
distribution 出货
rally 拉升
transfer_accumulation 换庄抢筹
washout 洗盘
high_absorption_rally 高承接拉升

flow_state_code 可选值(筛选与响应)

flow_state_code flow_state(中文,仅响应)
accumulation 吸筹
inducement 诱多
distribution 出货
rally 拉升
transfer_accumulation 换庄抢筹
washout 洗盘
high_absorption_rally 高承接拉升

示例:

?flow_state_code=accumulation
?flow_state_code=accumulation,rally,washout

策略范围

strategy ∈ {五红策略, 开盘策略}

flow_state 判定(取自 bigorder_1

GET /v1/api/strategy/auction/today 同一选取函数 pick_auction_bigorder_pair,字段口径一致:

字段 口径(同 auction 输出)
amount 对冲净额 = 大单金额(含同向并入) − 对冲金额;若净额 < 0 则取绝对值
hedge_amount Σ反向对冲档金额
nature / trade_type 净额 < 0 时改为对冲单的 nature / trade_type
ratio(仅 flow 后端用) amount / hedge_amount,即 (大单金额 − 对冲金额) / 对冲金额hedge_amount=0 时不可用
change_pct 取自 price_series / 明细入库字段;仍缺失 / null 时按 0 参与比较(对齐前端 JS:null <= 0 为真、null > 1 为假)。旧日未重跑 ingest 时可能仍为 null

前端基于 auction 的 bigorder_1.amount / hedge_amount 计算 ratio 时,应与本接口后端分类使用同一公式。

约束(与大单语义一致): - trade_type=1(买)只会出现 nature ∈ {passive_buy, active_buy} - trade_type=2(卖)只会出现 nature ∈ {active_sell, passive_sell} - 分类器两侧分别只接受对应 nature;买卖分支互不交叉

各侧按下列规则 1→5 顺序 匹配,命中即返回。

trade_type=1(买)

# 条件 code 中文
1 passive_buy + 0 < hedge_count < 3 accumulation 吸筹
2 active_buy + hedge_count = 0 inducement 诱多
3 active_buy + hedge_count > 0 + ratio < 1.5 + change_pct < -1.5 distribution 出货
4 active_buy + hedge_count > 0 + ratio > 0.8 + change_pct > 0 rally 拉升
5 passive_buy + (hedge_count > 2 或 (hedge_count = 10.95 < ratio < 1.5)) transfer_accumulation 换庄抢筹

trade_type=2(卖)

# 条件 code 中文
1 active_sell + hedge_count == 0 + hedge_amount == 0 distribution 出货
2 (active_sell + hedge_count > 1 + (ratio < 0.5ratio > 1.5)) 或 (passive_sell + hedge_count == 1 + ratio < 0.95 + change_pct > 1) high_absorption_rally 高承接拉升
3 passive_sell + hedge_count == 1 + ratio >= 0.95 + change_pct > 1 inducement 诱多
4 passive_sell + hedge_count > 1 + ratio < 0.9 + change_pct > 1 high_absorption_rally 高承接拉升
5 passive_sell + hedge_count > 0 + ratio < 0.9 + change_pct <= 0 washout 洗盘

响应示例

{
  "data": {
    "day": "20260822",
    "redis_day": "20260822",
    "items": [
      {
        "code6": "603327",
        "ts_code": "603327.SH",
        "name": "福蓉科技",
        "strategy": "五红策略",
        "ts": "2026-08-21 09:25:02",
        "buy_price": 8.85,
        "pre_close": 8.86,
        "pre_pct_chg": 4.48,
        "limit_stats": 9,
        "days_ago": 36,
        "free_float_shares": 1045459360,
        "close": 9.33,
        "intraday_low": 8.73,
        "intraday_high": 9.7,
        "intraday_open": 8.85,
        "sector_flow": "in",
        "pre_high": 9.04,
        "pre_ma5": 8.878,
        "pre_ma10": 9.021,
        "pre_ma20": 8.936,
        "pre_ma60": 9.306333333333333,
        "pre_ma180": 9.779393939393941,
        "pct_chg": 5.304740406320549,
        "pre_vol_ratio": 1.3411901378632276,
        "pre_price_speed_ratio": 0.02433214479643044,
        "is_leader": 0,
        "vol": 54728700,
        "amount": 508118431.0,
        "pre_vol": 29901244,
        "avg_vol_per_min_5d": 92894.0,
        "today_vol_ratio": 2.454800632979525,
        "bigorder_net_shares_today": 12707400,
        "bigorder_main_net": 8500000,
        "pct_5d_recent": 4.4811,
        "pct_10d_recent": -5.0375,
        "pct_20d_recent": -5.0375,
        "ma5": 8.878,
        "ma10": 9.021,
        "ma20": 8.936,
        "ma60": 9.306333333333333,
        "ma180": 9.779393939393941,
        "price_speed_ratio": 0.0,
        "price_30m_ago": null,
        "flow_state": "吸筹",
        "flow_state_code": "accumulation"
      }
    ],
    "page": 1,
    "page_size": 30,
    "total": 83,
    "total_pages": 3,
    "flow_state_counts": {
      "accumulation": 20,
      "inducement": 12,
      "distribution": 8,
      "rally": 15,
      "transfer_accumulation": 6,
      "washout": 10,
      "high_absorption_rally": 12
    }
  }
}

相关

  • 数据源接口:竞价策略今日数据
  • 实现:apps/market/views/strategy_flow.pyapps/market/services/strategy_flow.py