{"id":51645577,"url":"https://github.com/yucl80/etf-quant","last_synced_at":"2026-07-13T22:02:58.838Z","repository":{"id":344138812,"uuid":"1180424986","full_name":"yucl80/etf-quant","owner":"yucl80","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-13T09:28:42.000Z","size":54,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-13T19:40:50.421Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yucl80.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-13T03:01:04.000Z","updated_at":"2026-03-13T09:19:58.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/yucl80/etf-quant","commit_stats":null,"previous_names":["yucl80/etf-quant"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/yucl80/etf-quant","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yucl80%2Fetf-quant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yucl80%2Fetf-quant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yucl80%2Fetf-quant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yucl80%2Fetf-quant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yucl80","download_url":"https://codeload.github.com/yucl80/etf-quant/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yucl80%2Fetf-quant/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35437768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-13T02:00:06.543Z","response_time":119,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-13T22:02:58.123Z","updated_at":"2026-07-13T22:02:58.827Z","avatar_url":"https://github.com/yucl80.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ETF 中高频机器学习量化交易框架（增强版）\n\n这是一个可运行的 ETF 中高频（5min~30min）机器学习量化交易程序，重点强化了**状态切换、自适应仓位、Purged Walk-forward** 与**预测质量评估**。\n\n## 核心升级\n\n- **多专家状态感知模型**：趋势专家 + 均值回复专家 + 稳健专家（在线学习）。\n- **多策略组合执行**：ML 主策略 + 趋势跟踪 + 均值回复三策略动态加权。\n- **特征增强**：新增 ATR、波动区间 z-score、收益偏度、VPIN 代理因子。\n- **Purged Walk-forward**：支持 `embargo` 隔离窗口，降低标签泄漏风险。\n- **风险约束增强**：概率阈值 + 目标波动率缩放 + 趋势强度降杠杆。\n- **评估更完整**：除 Sharpe/MDD 外，新增 Accuracy、Brier、Win Rate、Calmar、Sortino。\n\n## 目录结构\n\n- `src/etf_quant/data.py`：数据加载与合成数据\n- `src/etf_quant/features.py`：中高频特征工程\n- `src/etf_quant/models.py`：在线多专家状态感知集成\n- `src/etf_quant/strategy.py`：单策略信号映射 + 多策略组合仓位控制\n- `src/etf_quant/backtest.py`：交易成本回测与预测质量评估\n- `src/etf_quant/pipeline.py`：Purged walk-forward 主流程\n- `main.py`：CLI 入口\n\n## 快速开始\n\n```bash\npython main.py --bars 3000 --freq 5min --horizon 6 --embargo 2 --trading-minutes-per-day 240\n```\n\n如有真实数据：\n\n```bash\npython main.py --csv data/510300_5min.csv --freq 5min --horizon 6 --embargo 2 --trading-minutes-per-day 240\n```\n\nCSV 至少包含列：`timestamp,open,high,low,close,volume`。\n\n## 实盘化建议\n\n- 替换 VPIN proxy 为逐笔成交驱动的真实订单流不平衡。\n- 引入盘口冲击模型（与成交量分段函数绑定）替代固定滑点。\n- 接入实时风控（净敞口、行业/指数 beta、单品种风控限额）。\n\n\n## 本次继续优化\n\n- 训练窗口内参数调优改为**成本与换手惩罚感知**的评分。\n- 回测成本模型升级为**波动率 + 交易强度**驱动的动态滑点。\n- 输出新增 `avg_cost` 用于评估交易效率。\n\n\n## 多策略（Multi-Strategy）改进\n\n- 在执行层引入 **ML / Trend / Mean-Reversion** 三策略融合。\n- 根据趋势强弱与波动状态动态切换权重，并对策略分歧进行降杠杆抑制。\n- 在不改变训练接口的前提下，显著降低回撤与换手冲击。\n\n- 年化指标按 `freq` 与 `trading_minutes_per_day` 自适应计算，避免固定 5min 年化偏差。\n\n- 支持频率格式：`5min` / `15m` / `1h`，并对非法频率输入做参数校验。\n- 执行步长会按波动率自适应收缩，高波动时自动降低换仓冲击。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyucl80%2Fetf-quant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyucl80%2Fetf-quant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyucl80%2Fetf-quant/lists"}