Skip to content

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

A-Share Options Research Lab

This repository is an A-share index options research workspace. It combines daily option-chain structure, Wind option-chain history, VAMP chart research, and MO / CSI1000 intraday options-flow reporting into one local Streamlit app.

The project is for research, visualization, and post-trade review only. It does not place orders and does not output direct buy/sell instructions.

Current Version

The current repo is organized around three workflows:

  • VAMP Research Lab: aggregates Wind EOD option chains into daily market-state factors, VAMP charts, signal diagnostics, and event-study rankings.
  • Options Playbook: preserves the original daily options engine for regime state, gamma walls, volatility surface, trigger levels, alerts, and Markdown reports.
  • MO Intraday Flow Radar: turns minute-level MO option-chain data into intraday flow, wall movement, OI attribution, synthetic forward, charts, CSVs, and a Markdown report.

Run the combined UI from the repository root:

python -m streamlit run app.py

Then open:

http://127.0.0.1:8501

Wind 数据与环境

main 使用官方 Wind 终端的 WindPy。上证50、沪深300、中证1000分别对应 HO、IO、MO。原 iFinD 实现和当时的历史快照保存在 archive/ifind-idle(2491253)。Wind 数据、SQLite 和生成的报告保存在本机。

在项目根目录创建虚拟环境并安装依赖。以下命令用于 macOS。Windows PowerShell 的激活命令是 .\.venv\Scripts\Activate.ps1。

python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt

安装并登录 Wind 终端及其官方 Python API。程序会加载已配置的 WindPy,或查找 macOS 的 /Applications/Wind API.app/Contents/python 和 Windows 用户目录下的 Wind/Wind.NET.Client/WindNET/x64。其他安装位置可将环境变量 WIND_PYTHON_DIR 指向包含官方 WindPy.py 的目录。查看已经生成的图表和报告只需本地文件。

取数

从项目根目录运行。默认取三个品种,--products 可以指定其中一项或多项。

python cem_options_engine/scripts/fetch_wind_chains.py daily
python cem_options_engine/scripts/fetch_wind_chains.py daily --start-date 2026-11-20 --end-date 2026-11-23 --skip-existing
python cem_options_engine/scripts/fetch_wind_chains.py intraday --date 2026-11-23 --products CSI1000
python cem_options_engine/scripts/fetch_wind_chains.py snapshot --products CSI1000
模式 Wind 调用 本地目录及用途
daily WSET 当日合约链 + WSS 指定交易日的价格、持仓量、IV 和 Greeks normalized_chain,供日频 VAMP 和历史 ATM IV 使用
intraday WSET 当日合约链 + WSI 一分钟 OHLC、成交量、成交额和持仓量 intraday_chain,供日内 ATM 和 MO 雷达使用
snapshot WSET + WSQ 逐合约报价日期、时间、盘口、持仓量、IV 和 Greeks snapshots,保留对应交易日最近一次抓取的实时截面

文件路径为 cem_options_engine/data/options_wind/<目录>/product_group=<品种>/trade_date=YYYY-MM-DD/data.parquet。历史查询按中金所交易日历取数。日度模式默认取最近一个已收盘交易日。分钟模式在盘中把已结束的分钟保存到 live.parquet,收盘后重跑会生成全天的 data.parquet,页面优先读取全天文件。实时快照只保留报价日期与目标交易日一致的标的和合约。需要 CSV 时可加 --write-csv。

期权到期日取自 WSET 的 last_tradedate,乘数取自 multiplier。日终 us_impliedvol 和实时 rt_imp_volatility 直接使用小数,例如 0.20 表示 20%。日终买卖一档留空,盘口从 WSQ 快照读取。分钟持仓量来自 WSI 的 oi。日历区间回补会逐品种、逐交易日写入,失败后可用 --skip-existing 继续。

Streamlit Pages

VAMP Research Lab

Loads normalized option-chain partitions, aggregates them to daily state, generates VAMP factor columns, plots selected factors, marks technical events, and ranks signal combinations by forward-return / volatility diagnostics.

Typical use:

  • choose product group such as CSI1000
  • choose date range
  • choose a VAMP factor
  • inspect chart, recent event table, ranking table, and interpretation

Options Playbook

Displays generated files from cem_options_engine/output/wind/:

  • daily Markdown report
  • metrics CSV
  • key levels CSV
  • data quality CSV

This is the original daily options-engine workflow: regime state, gamma walls, volatility structure, triggers, invalidation, sizing bias, alerts, and postmortem fields.

MO Flow Radar

Displays generated files from mo_flow_radar/output/wind/YYYY-MM-DD/:

  • MO intraday Markdown report
  • call / put volume and amount PCR charts
  • OI-by-strike and volume-by-strike charts
  • call wall / put wall timeline
  • synthetic forward by expiry
  • flow-event and wall CSV tables

Flow labels are proxy classifications based on volume, amount, price change, and OI change. They include confidence fields and should not be read as confirmed dealer inventory.

生成报告

从项目根目录运行。日报复用通过品种、交易日、字段和现货收盘价检查的 Wind 日线分区,缺少分区时自动下载。Wind 修订历史数据后,可加 --refresh-chain 强制重取。区间重建按交易日顺序生成报告,每个品种共用一份 WSD 标的历史,每日计算只读取截至当日的收盘价。

python cem_options_engine/main.py --date 2026-11-23 --all
python cem_options_engine/main.py --start-date 2026-10-19 --end-date 2026-11-23 --all
python mo_flow_radar/main.py --date 2026-11-23 --previous-eod cem_options_engine/data/options_wind/normalized_chain/product_group=CSI1000/trade_date=2026-11-20/data.parquet
python -m streamlit run app.py

MO 雷达默认读取最近的本地 MO 分钟分区,并按 Wind 交易日历查找上一交易日的本地持仓。可用 --previous-eod 显式指定基准文件。基准缺失时使用盘中起始持仓并在报告中标记。日报的 --sample 模式将演示输出和数据库保存在 cem_options_engine/output/sample/。

看板口径

项目 读法
净 GEX 与总 GEX 单位为指数每变动 1% 对应的名义金额。Call 取正,Put 取负。总 GEX 先对每个合约取绝对值再汇总。覆盖率为拥有有效 Gamma 和持仓量的合约比例。
持仓墙与翻转点 分别汇总同一行权价所有到期月份的 Call、Put 持仓,取各侧最大值。持仓无法提供排序时使用绝对 GEX。翻转点需要动态曲线两侧存在相反符号。
IV Rank 与 RV20 IV Rank 比较当日 ATM IV 与此前连续 252 个交易日的有效 ATM IV 区间,结果限制在 0 到 1。RV20 需要 21 个收盘价。日历中断后,VAMP 重新累计窗口。
MO 五分钟资金流 按每一分钟收齐的合约截面,用当时为止的正成交量和正持仓观测计算分位数。午休、缺失分钟和换日都会重启五分钟窗口。持仓增减与价格方向用于推断开平仓。
事件研究 排名按所选信号和已到期的收益或波动率样本筛选。十日最大回撤涵盖触发日收盘至第十日收盘间的峰谷跌幅。相邻事件可能重叠,表内 t 值仅用于描述样本。
策略收益代理 方向策略使用持有期标的涨跌。跨式策略比较绝对涨跌与入场 ATM IV 估算的同期预期波幅。多腿结构需要逐腿报价才可核算实际损益。

后续验证建议

  1. 先补历史窗口。 按 Wind 交易日顺序补齐三个品种的日线,分别核对 IV 历史天数、合约数与 GEX 字段覆盖。凑足 252 个历史交易日后,再比较年度 IV Rank 和波动率状态。
  2. 独立检验信号。 先固定阈值,再按时间滚动检验后续月份。每组列出触发次数、完整样本、去除重叠持有期后的收益区间,并与同品种同期无条件收益比较。
  3. 验证成交可行性。 按交易日积累带时间戳的盘口快照。使用次个可成交报价、合约乘数、双边费用和滑点重放各条腿,单独记录缺报价或无法成交的事件。

本地对账与测试

运行下列命令可用本地 Wind 期权链逐行权价核对净 GEX、总 GEX 和持仓。有完整 MO 分钟报告的日期,还会核对分钟成交量和收盘总持仓。默认检查最新日报,首次出现差异时返回非零退出码。

python cem_options_engine/scripts/check_wind_reports.py
python cem_options_engine/scripts/check_wind_reports.py --all-dates
python -m pip install pytest
python -m pytest -q tests mo_flow_radar/tests
(cd cem_options_engine && python -m pytest -q tests)

Research Limits

  • No automatic trading.
  • No direct buy/sell recommendations.
  • Dealer gamma, Vanna / Charm, wall strength, and flow labels are estimates from available chain data.
  • Without bid / ask, IV history, Greeks, and underlying minute prices, intraday flow classification remains a proxy.
  • If open interest is only updated at end of day, MO Flow Radar automatically degrades to EOD-only OI analysis.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages