A 股多因子量化研究 + 交易平台。从数据到回测到实盘的完整流水线。 面向量化开发面试,展示机构级架构设计能力。
Event-driven architecture — all components communicate through EventBus, all state persisted in SQLite.
┌─────────────────────────────────────────────────────────────┐
│ Core Architecture (core/) │
│ AsyncEventBus · Store · StateMachine · AuditLog │
│ Scheduler · MessageBus(Local/Redis/Kafka) · Services │
└────────────────────────────┬────────────────────────────────┘
│ All components communicate via EventBus
│ All state persisted via Store (SQLite WAL)
┌────────────────────────────────────────────────┼────────────────────────────────────────────┐
│ │ │
▼ ▼ ▼
Data Layer Factor Engine Alpha Model Portfolio Optimizer
Synthetic 10 Technical IC/ICIR Weighted Equal Weight
Tushare 5 Fundamental ML Signal (XGBoost/LGBM) Mean Variance
Baostock Cython Hot Paths LLM Sentiment Risk Parity
PostgreSQL IC Monitor + Decay
WebSocket L2 Graph Network Factor
Realtime Fundamentals
│ │ │ │
└────────────────────────┴───────────────────────────┴────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────────────────────────┐
│ Execution & Risk Layer │
│ │
│ Order Book Backtest Engine Risk Engine Execution │
│ Red-Black Tree Tick-Level Event Per-tick Greeks TWAP │
│ Price-Time FIFO Market Impact Pre-Trade Check VWAP │
│ IOC/FOK/Partial TWAP/VWAP Algo Auto Delta-Hedge Iceberg │
│ VPIN Metrics 3 Impact Models Kill Switch SmartRouter│
│ 12 Stress Scenarios │
└────────────────────────────────────────────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────────────────────────┐
│ Live Trading & Monitoring │
│ │
│ Trading Engine Web Dashboard Monitoring │
│ AKShare Realtime FastAPI (91 endpoints) Prometheus + Grafana │
│ Paper Trading Vue 3 + ECharts 16 Dashboard Panels │
│ QMT/xtquant Live WebSocket Push Structured Logging │
└────────────────────────────────────────────────────────────────────────────────┘
17 new source files (~5,000 lines) + 132 new tests — all integrated into the existing system.
One complete pipeline execution: python main.py run
DataProvider → DataPipeline (clean/align/filter ST/suspended) → prices, returns, benchmark, metadata, financials. Supports Synthetic / Tushare / Baostock / PostgreSQL.
FactorEngine computes 15 factors → cross-sectional processing (winsorize → zscore → neutralize) → IC evaluation. Cython hot paths for performance.
AlphaPipeline combines factors (ICIR-weighted) → cross-sectional rank normalization → signal. Optional: ML signal (XGBoost/LGBM) or LLM sentiment.
Covariance estimation (Ledoit-Wolf/EWMA) → PortfolioOptimizer (EW/MVO/RiskParity) → target weights with constraints (long-only, max weight, sector, turnover, lot size).
BacktestEngine multi-period simulation → daily weight drift → rebalance with costs (commission 0.03% + stamp tax 0.1% + slippage). Optional: tick-level engine with LOB matching + market impact.
VaR/CVaR → Stress tests (2008/2015/2020) → Barra decomposition → Regime detection → HTML report with ECharts + KPI + factor analysis + risk metrics.
Architecture patterns are aligned. Remaining gaps are physical limits, not code.
| Dimension | This Project | Jane Street | Gap |
|---|---|---|---|
| Event Bus | AsyncEventBus (backpressure + DLQ + WAL) | Similar architecture | Matched |
| Order Book | Red-black tree + FIFO + IOC/FOK + VPIN | Similar architecture | Matched |
| Backtest | Tick-level event-driven + market impact | Tick-level event-driven | Matched |
| Risk Engine | Per-tick Greeks + pre-trade + Kill Switch | Per-tick pre-trade + auto-hedge | Matched |
| Factor Compute | Cython hot paths | C++/Rust | Close |
| Latency | ~10ms (Python) | ~10μs (OCaml + FPGA + DPDK) | 1000x |
| Type Safety | Runtime (Python) | Compile-time (OCaml) | Fundamental |
| Data | Level 2 (10-level book) | Level 3 (all orders/cancels) | Resource |
| Strategy | Monthly multi-factor stock selection | Microsecond market-making + arb | Category |
Get up and running in 3 commands.
# Baostock real data (free, no API key) python main.py run --use-baostock # Strategy comparison python main.py compare --optimizers equal_weight,mean_variance,risk_parity # Parameter grid search python main.py sweep --optimizers equal_weight,mean_variance --frequencies monthly,weekly # ML Alpha signal python main.py ml train --model lightgbm python main.py ml signal --model xgboost # LLM research agent python main.py research report # Performance profiling python main.py profile
Production-grade technologies across the full stack.
10 real-world A-share traps that every quant must handle. We handle all of them.
84 Python modules organized by domain.
quant_platform/ ├── main.py # CLI entry point ├── app.py # FastAPI application ├── CLAUDE.md # Full architecture docs ├── INTERVIEW_CHEATSHEET.md # Interview prep (12 topics) ├── JANE_STREET_GAP_ANALYSIS.md # Gap analysis vs Jane Street │ ├── core/ # ★ Core Architecture │ ├── event_bus_v2.py # AsyncEventBus (backpressure+DLQ+WAL) │ ├── events.py # Event bus bridge (backward compat) │ ├── message_bus.py # Distributed bus (Local/Redis/Kafka) │ ├── store.py # SQLite persistence (WAL, 8 tables) │ ├── state_machine.py # 8-state lifecycle │ ├── audit.py # Compliance audit trail │ └── scheduler.py # A-share market hours │ ├── data/ # Data Layer │ └── providers/ # Synthetic/Tushare/Baostock/PG/WS/L2 │ ├── factors/ # Factor Engine (15 factors) │ ├── technical.py # 10 technical factors │ ├── fundamental.py # 5 fundamental factors │ ├── network.py # Graph network factor │ └── ic_monitor.py # IC decay monitoring │ ├── alpha/ # Alpha Model (IC/ICIR/ML/LLM) ├── portfolio/ # Portfolio Optimization (EW/MVO/RP) │ ├── backtest/ # Backtest Engine │ ├── engine.py # Vectorized monthly │ └── tick_engine.py # ★ Tick-level event-driven │ ├── execution/ # Execution Layer │ ├── order_book.py # ★ Real LOB (FIFO+IOC/FOK+VPIN) │ └── market_impact.py # ★ Impact models (AC/SR/Kyle) │ ├── risk/ # Risk Management │ ├── realtime_engine.py # ★ Real-time risk (Greeks+pre-trade) │ ├── greeks.py # ★ Black-Scholes Greeks │ └── barra.py # Barra 10-factor model │ ├── trading/ # Live Trading │ ├── broker.py # SimulatedBroker (LOB) + QMTBroker │ └── engine.py # Trading engine (EventBus+Risk+LOB) │ ├── services/ # Microservice skeletons ├── agent/ # LLM modules ├── utils/ # Utilities │ └── cyext/ # ★ Cython hot paths (3 .pyx) │ ├── api/ # FastAPI (91 endpoints) ├── frontend/ # Vue 3 + ECharts ├── monitoring/ # Grafana dashboard (16 panels) │ └── tests/ # 610 unit tests ├── test_core/ # EventBus(38) + Store(16) + SM(15) + ... ├── test_execution/ # OrderBook(22) + OMS(17) + Impact(10) ├── test_risk/ # RealTimeRisk(12) + Greeks(8) + ... ├── test_backtest/ # TickEngine(15) + Cost(4) + ... └── test_utils/ # Cython(18) + Numba + Cache + ...