caizongxun/btc-us-stock-ml-strategy
GitHub: caizongxun/btc-us-stock-ml-strategy
一个面向 BTC 与美股的机器学习交易策略流水线,通过 XGBoost、市场状态检测和二元规则挖掘生成可直接集成至 QuantDingers 的量化交易信号。
Stars: 0 | Forks: 0
# BTC + 美股机器学习策略
一个完整的机器学习流水线,用于生成**二元交易规则**和**ML 驱动信号**,目标为 BTC 和美股 (SPY/QQQ)。
专为 **QuantDingers** 集成设计 —— 直接输出 `+1 / 0 / -1` 信号。
## 架构
```
btc-us-stock-ml-strategy/
├── data/
│ ├── fetch_btc.py # Binance OHLCV
│ ├── fetch_stocks.py # yfinance SPY/QQQ/VIX
│ └── fetch_onchain.py # Fear & Greed + SOPR proxy
├── features/
│ ├── price_features.py # momentum, returns, drawdown
│ ├── volatility_features.py# ATR, rolling std, VIX regime
│ ├── cross_asset_features.py# BTC-SPY correlation, beta, divergence
│ ├── technical_features.py # RSI, MACD, BB, MFI, etc.
│ ├── regime_features.py # HMM/GMM market regime
│ └── build_features.py # master feature assembler
├── models/
│ ├── xgboost_model.py # XGBoost classifier
│ ├── lightgbm_model.py # LightGBM classifier
│ ├── regime_detector.py # HMM regime segmentation
│ └── binary_rule_miner.py # Decision tree rule extractor
├── strategy/
│ ├── signal_generator.py # model -> +1/0/-1 signal
│ ├── multi_signal.py # N-of-M signal voting
│ └── quantdingers_export.py# export strategy code
├── backtest/
│ ├── backtester.py # vectorbt-based backtester
│ └── evaluate.py # Sharpe, Calmar, drawdown
├── config.py # global settings
├── main.py # full pipeline runner
└── requirements.txt
```
## 快速开始
```
pip install -r requirements.txt
python main.py --asset BTC --target_days 3 --mode full
```
## 模式
- `full` — 训练 XGBoost + LightGBM + Regime + 提取二元规则
- `rules_only` — 仅进行决策树规则挖掘
- `regime_only` — 仅进行 HMM Regime 检测
- `export` — 导出兼容 QuantDingers 的策略
标签:Apex, XGBoost, 加密货币, 回测系统, 机器学习, 特征工程, 美股, 逆向工具, 量化交易, 金融量化