A lightweight quantitative backtesting framework with CLI, strategies, reporting, and Streamlit dashboard.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file qbt_lite-0.3.0.tar.gz
.
File metadata
- Download URL: qbt_lite-0.3.0.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
821e337ea3bb5a428bc951295ccecd7ccef3e98399dbc19f6b5d8a0c0f28b290
|
|
MD5 |
50df6ddbe7b3a145a42500e1b5853964
|
|
BLAKE2b-256 |
6591481d6294399093f98ac322aba392587f78223246a8deb3225cba97c7f164
|
File details
Details for the file qbt_lite-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: qbt_lite-0.3.0-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
169b6c3f6e8936a1cf5e7495529760cf0fbcf28d7a2f5c0dd0fc2dc762451486
|
|
MD5 |
617791703d36a7b1af57e9e315110ad1
|
|
BLAKE2b-256 |
c9851b6d44085684fe93e760d1f90b469aeba890442b1bd27b79b88da3f18049
|