QBT-Lite 📈
A lightweight quantitative backtesting framework in Python
🌟 Project Overview
QBT-Lite is a lightweight quantitative backtesting framework written in Python.
It covers the full workflow:
data import → strategy execution → order simulation → performance evaluation → automated reporting → interactive visualization.
Designed as both a learning-friendly framework and a portfolio project showcasing quantitative research & engineering skills.
Resume Highlights:
- End-to-end backtesting: from data loading to reporting
- Supports multi-asset portfolio backtesting and strategy evaluation
- Multiple trading strategies (SMA, Momentum, Bollinger Bands, RSI, MACD)
- Key metrics (Sharpe, Sortino, Calmar, Max Drawdown, etc.)
- Automated reports (CSV, Markdown, PNG charts)
- Interactive Streamlit app for strategy testing
- NEW in v0.3.0: Event-driven backtesting engine (intraday), trade-level metrics (win rate, profit factor, etc.)
⚙️ Tech Stack
- Python 3.10+
- pandas, numpy, tabulate for data handling & calculations
- matplotlib for visualization
- pytest for testing
- streamlit + plotly (optional, for interactive UI)
- yfinance / tushare (optional, for real market data)
🚀 Quick Start
1. Installation
git clone https://github.com/LinShuyue2003/qbt-lite.git
cd qbt-lite
python -m venv .venv
source .venv/bin/activate # Linux / Mac
.\.venv\Scripts\Activate.ps1 # Windows PowerShell
pip install -U pip
pip install -e .
Optional features:
pip install 'qbt-lite' # streamlit, plotly, yfinance, pytest, pyyaml
2. Run a Demo
Run SMA strategy:
python -m examples.run_sma_example
Run momentum strategy with CLI:
qbt-lite --strategy momentum --symbol MOCK --lookback 60 --report_name cli_mom
3. View Reports
Reports are saved in reports/:
- Performance metrics (
.csv,.md) - Equity curve (
.png) - Drawdown curve (
.png)
🔹 Features
Daily Backtests
- Vectorized backtesting on daily bars
- Configurable via CLI or YAML
- Supports multi-asset Top-N momentum
Event-Driven Backtests (NEW 🚀)
- Processes intraday/minute bars via event queue (Market → Strategy → Order → Fill)
- Broker applies commission + slippage
- Portfolio logs fills & equity
- Produces both return-based & trade-level metrics
Interactive Dashboard
Run Streamlit app:
python -m streamlit run streamlit_app.py
Features: upload CSV, choose strategy, set parameters, see equity in real time.
📊 Example Metrics
| annual_return | sharpe | sortino | calmar | max_drawdown |
|---|---|---|---|---|
| 0.1858 | 1.5473 | 2.4103 | 2.8895 | -0.0643 |
Trade-level (event-driven SMA, minute bars):
| num_trades | win_rate | profit_factor | avg_win | avg_loss |
|---|---|---|---|---|
| 37 | 0.2973 | 1.2227 | 37.21 | -12.87 |
🧪 Tests & CI
Run unit tests:
pytest -q
GitHub Actions CI included.
🔮 Roadmap
- More advanced strategies (pairs trading, factor models, CTA futures)
- Portfolio allocation (Kelly, risk parity, volatility targeting)
- Live data integration (tushare, Alpaca API, ccxt for crypto)
- Full Streamlit/Flask dashboard with parameter tuning
- More order types (stop/limit, latency modeling)
📜 License
MIT License
🤝 Acknowledgements
For learning & demonstration purposes only. Not financial advice.
Release files for qbt-lite 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qbt_lite-0.3.0.tar.gz | 18.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qbt_lite-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.2 kB
Release files / qbt_lite-0.3.0.tar.gz
| Download URL | qbt_lite-0.3.0.tar.gz |
|---|---|
| Size | 18.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
821e337ea3bb5a428bc951295ccecd7ccef3e98399dbc19f6b5d8a0c0f28b290
|
|
BLAKE2b-256 checksum How to use checksums |
6591481d6294399093f98ac322aba392587f78223246a8deb3225cba97c7f164
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / qbt_lite-0.3.0-py3-none-any.whl
| Download URL | qbt_lite-0.3.0-py3-none-any.whl |
|---|---|
| Size | 20.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
169b6c3f6e8936a1cf5e7495529760cf0fbcf28d7a2f5c0dd0fc2dc762451486
|
|
BLAKE2b-256 checksum How to use checksums |
c9851b6d44085684fe93e760d1f90b469aeba890442b1bd27b79b88da3f18049
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|