sngyai / Sequoia-X
Sequoia-X: 王者回归 | The King Returns
简介 | Introduction
Sequoia-X V2 是面向 A 股市场的量化选股系统,基于现代 Python 工程化标准从零重构。 Sequoia-X V2 is a quantitative stock selection system for the A-share market, rebuilt from scratch based on modern Python engineering standards.
系统以 OOP 架构、向量化计算和增量数据更新为核心设计原则,每日收盘后自动选股并推送至飞书群。 The system is designed with OOP architecture, vectorized computation, and incremental data updates as its core principles, automatically selecting stocks after the market closes and pushing results to a Feishu group.
数据层使用 baostock(免费、无需注册、无限流)拉取历史及增量日 K 数据(后复权),存储于本地 SQLite,彻底规避东方财富反爬问题。 The data layer uses baostock (free, no registration required, unlimited streaming) to fetch historical and incremental daily K-line data (backward adjusted), storing it in a local SQLite database to completely avoid anti-scraping issues associated with East Money.
两种运行模式 | Two Running Modes
python main.py # 日常模式:8进程增量补数据 + 跑策略 + 飞书推送(2~3分钟)
python main.py # Daily mode: 8-process incremental data update + strategy execution + Feishu push (2-3 minutes)
python main.py --backfill # 回填模式:全市场历史K线一次性灌入(约12分钟)
python main.py --backfill # Backfill mode: One-time ingestion of historical K-line data for the entire market (approx. 12 minutes)
内置策略 | Strategies
| 策略 | 说明 |
|---|---|
| TurtleTrade | 海龟突破:20日新高 + 成交额过亿 + 阳线防诱多,按涨幅排序 |
| TurtleTrade | Turtle Breakout: 20-day high + turnover > 100M + bullish candle to prevent bull traps, sorted by gain |
| MaVolume | 均线+放量突破 |
| MaVolume | Moving Average + Volume Breakout |
| HighTightFlag | 高而窄的旗形整理突破 |
| HighTightFlag | High-Tight Flag consolidation breakout |
| LimitUpShakeout | 涨停洗盘回踩确认 |
| LimitUpShakeout | Limit-up shakeout and pullback confirmation |
| UptrendLimitDown | 上升趋势中的跌停反包 |
| UptrendLimitDown | Limit-down reversal within an uptrend |
| RpsBreakout | 欧奈尔 RPS 相对强度突破 |
| RpsBreakout | O’Neil RPS (Relative Price Strength) breakout |
快速开始 | Quick Start
环境要求:Python >= 3.10 Environment Requirements: Python >= 3.10
1. 安装依赖 | Install Dependencies
# 推荐使用 uv(快速包管理器)
# Recommended: use uv (fast package manager)
uv sync
# 或者 pip
# Or pip
pip install .
2. 配置环境变量 | Configure Environment Variables
cp .env.example .env
# 编辑 .env,填写飞书 Webhook URL
# Edit .env and fill in the Feishu Webhook URL
3. 首次回填历史数据 | Initial Historical Data Backfill
python main.py --backfill
约 12 分钟完成 ~5200 只 A 股历史后复权日 K 数据回填。 Completes the backfill of historical backward-adjusted daily K-line data for ~5200 A-share stocks in about 12 minutes.
4. 日常运行 | Daily Operation
python main.py
建议配合 crontab 每个交易日收盘后自动执行: It is recommended to use crontab to execute automatically after the market closes each trading day:
15 19 * * 1-5 cd /root/Sequoia-X && .venv/bin/python main.py >> log.txt 2>&1
目录结构 | Project Structure
Sequoia-X/
├── main.py # 入口:argparse 分发日常/回填模式 (Entry point)
├── pyproject.toml # 依赖声明 + ruff/pytest 配置 (Dependencies + Config)
├── .env.example # 环境变量模板 (Env template)
├── data/ # SQLite 数据库 (SQLite database)
├── sequoia_x/ # 核心逻辑 (Core logic)
│ ├── core/ # 配置与日志 (Config & Logger)
│ ├── data/ # 数据引擎 (Data engine)
│ ├── strategy/ # 策略实现 (Strategy implementations)
│ └── notify/ # 飞书推送 (Feishu notification)
└── tests/ # 属性测试 (Property-based testing)
数据说明 | Data Notes
- 数据源 (Data Source): baostock(免费、无需注册、无限流 / Free, no registration, unlimited streaming)
- 复权方式 (Adjustment): 后复权(hfq)— 历史价格不变,适合增量存储,避免除权导致数据错乱 (Backward adjusted — historical prices remain unchanged, suitable for incremental storage, avoids data corruption due to ex-rights)
- 存储 (Storage): 本地 SQLite(data/sequoia_v2.db),可直接拷贝到其他机器使用 (Local SQLite, portable to other machines)
- 日常增量 (Daily Incremental): 8 进程并行通过 baostock 拉取,2~3 分钟完成全市场更新 (8-process parallel fetching via baostock, completes full market update in 2-3 minutes)
许可证 | License
MIT