| title | Quant AI - Advanced Quant Trading Engine & Backtest Simulator |
|---|---|
| emoji | 📈 |
| colorFrom | blue |
| colorTo | indigo |
| sdk | docker |
| app_port | 7860 |
| pinned | false |
🚀 Interactive Terminal Demo: Experience the deployed terminal live on Hugging Face Spaces 👉 huggingface.co/spaces/Ypeng12/quant-ai
Quant.ai is an end-to-end, Point-in-Time Consistent Quantitative Trading & Paper/Live Execution Platform. Designed following Hudson River Trading (HRT) and Quantitative Hedge Fund engineering standards, it bridges the gap between rigorous signal research, microstructure execution, and real-time broker integration (Alpaca API).
- Direct Broker Connectivity: Seamless REST & WebSocket integration with Alpaca Markets for real-time order routing, position tracking, and market streaming.
- Paper & Live Mode Switch: Flexible environment toggling (
https://paper-api.alpaca.marketsfor risk-free simulation vs. live brokerage execution). - Execution Algorithmic Suite: Smart order routing with TWAP, VWAP, and Implementation Shortfall (IS) execution algorithms.
- Dynamic Portfolio Risk Controls:
- Real-time position tracking and ledger recording.
- Trailing stop-loss triggers and volatility-based position sizing.
- Drawdown-contingent risk multipliers & consecutive loss protections.
-
Point-in-Time Data Hygiene: Strict timestamp truncation at date
$t$ to eliminate lookahead bias across U.S. Equity & ETF universes. - Purged Walk-Forward Cross Validation + Embargo: Eliminates overlap leakage across rolling 3-year train / 6-month validation / 6-month OOS test windows with a 5-day embargo.
-
Novel Risk-Adjusted Signals:
- Sortino Momentum: $\text{Return}{20d} / \text{DownsideVol}{20d}$
-
Residual Momentum: 60-day rolling OLS stripping
SPYMarket Beta:$R_i(\tau) = \alpha_i + \beta_i R_{\text{SPY}}(\tau) + \epsilon_i(\tau)$ - Robust Z-Score Normalization: Cross-sectional Median/MAD standardization.
- Multiple Testing Correction: Deflated Sharpe Ratio (DSR) and Stationary Bootstrap 95% Confidence Intervals.
- Order Flow Imbalance (OFI): Real-time L2/L3 orderbook imbalance calculation for high-frequency price impact prediction.
- Friction & Shortfall Modeling: Multi-tiered transaction cost models with 2–15 bps slippage sensitivity checks.
- Low-Latency Engine Core: C++ accelerated order matching engine headers (
orderbook.hpp).
- LLM-assisted hypothesis compilation translating natural language ideas into validated, executable Pydantic model configurations.
"Can volatility-adjusted and market-beta-residualized cross-sectional momentum signals across liquid U.S. ETFs predict short-term excess returns after transaction costs and execution friction?"
git clone https://github.com/ypeng12/Quant.ai.git
cd Quant.ai
# Install Python requirements
pip install -r requirements.txtCreate a .env file in the project root:
# Alpaca Broker Credentials (Use Paper Trading for risk-free testing)
ALPACA_API_KEY=your_alpaca_paper_key
ALPACA_SECRET_KEY=your_alpaca_paper_secret
ALPACA_BASE_URL=https://paper-api.alpaca.markets
# Server Configuration
PORT=7860python -m pytest tests/ -vpython run_experiment.pyOutputs:
================================================================================
QUANT.AI OUT-OF-SAMPLE EXPERIMENT RUNNER
Hypothesis: Volatility-Adjusted Momentum across Liquid U.S. ETFs
Lookback: 20d | Holding: 5d | Transaction Cost: 5.0 bps
================================================================================
--> Raw_Momentum_Baseline | OOS Rank IC: -0.0182 | Net Sharpe: 0.33 | MaxDD: -55.2%
--> Vol_Adj_Momentum_Baseline | OOS Rank IC: -0.0196 | Net Sharpe: 0.33 | MaxDD: -59.4%
--> Ridge_Linear | OOS Rank IC: 0.0102 | Net Sharpe: 1.58 | MaxDD: -23.5%
# Launch FastAPI Backend
uvicorn backend.app.main:app --host 0.0.0.0 --port 7860 --reloadNavigate to http://localhost:7860 in your browser.
Quant.ai/
├── .github/
│ └── workflows/
│ └── sync_to_hf.yml # CI/CD GitHub Action auto-syncing to Hugging Face
├── backend/
│ └── app/
│ ├── trading_engine.py # Live/Paper Trading Engine & Portfolio Risk Control
│ ├── simulator.py # Execution Simulator & Implementation Shortfall Model
│ ├── orderbook_ofi.py # Microstructure Order Flow Imbalance (OFI) Engine
│ ├── execution_algo.py # TWAP / VWAP Order Execution Algorithms
│ ├── low_latency_engine.py # High-Frequency Matching Engine Adapter
│ └── cpp_engine/ # C++ Orderbook & Level-2 Matching Headers
├── frontend/ # React / TypeScript Institutional Dashboard UI
├── src/
│ ├── data/
│ ├── features/
│ ├── labels/
│ ├── validation/
│ ├── models/
│ └── portfolio/
├── tests/ # Zero Future Leak & Purged CV Unit Tests
├── Dockerfile # Hugging Face Space Docker Deployment spec
├── run_experiment.py # One-command OOS research executable
└── requirements.txt # Production Python dependencies
This repository features automated GitHub Actions CI/CD (.github/workflows/sync_to_hf.yml).
Whenever changes are merged into the main branch, GitHub automatically mirrors and deploys the latest codebase directly to the Hugging Face Space, guaranteeing 24/7 live deployment without manual intervention.
To ensure platform stability:
- Feature Branches: Developers work on dedicated feature branches (e.g.
ypeng12,lxc). - Pull Requests (PR): Code is tested locally and submitted via PRs to
main. - Deployment Trigger: Merging to
mainautomatically triggers Hugging Face live deployment.
Developed with ❤️ for Quantitative Finance, Machine Learning, and Automated Execution Research.