A professional Python quantitative trading library
Project description
DeltaFQ
A professional Python quantitative trading library providing a complete toolkit for quantitative strategy development and research.
Features
- 📊 Multi-source Data Support - Unified data interface supporting multiple data sources
- 📈 Rich Technical Indicators - Built-in common technical indicators with custom extension support
- 🎯 Flexible Strategy Framework - Clean API for rapid trading strategy development
- ⚡ Efficient Backtest Engine - Vectorized computation for fast strategy validation
- 📉 Comprehensive Risk Management - Position management, risk control, and performance analysis
- 🔧 Parameter Optimization Tools - Multiple optimization algorithms for finding optimal parameters
- 📱 Live Trading Interface - Unified trading interface for seamless simulation and live trading
Installation
pip install deltafq
Or install from source:
git clone https://github.com/Delta-F/deltafq.git
cd deltafq
pip install -e .
Quick Start
Get Data
import deltafq as dfq
# Get stock data
data = dfq.data.get_stock_daily('000001.SZ', start='2020-01-01', end='2023-12-31')
print(data.head())
Calculate Technical Indicators
# Calculate moving averages
data['ma5'] = dfq.indicators.SMA(data['close'], 5)
data['ma20'] = dfq.indicators.SMA(data['close'], 20)
# Calculate MACD
macd = dfq.indicators.MACD(data['close'])
data = data.join(macd)
Build Trading Strategy
class MAStrategy(dfq.strategy.Strategy):
"""Dual Moving Average Strategy"""
def on_bar(self, bar):
if bar.ma5 > bar.ma20:
self.buy()
elif bar.ma5 < bar.ma20:
self.sell()
Run Backtest
# Create backtest engine
engine = dfq.backtest.BacktestEngine(
initial_cash=100000,
commission=0.0003
)
# Run backtest
result = engine.run(data, MAStrategy())
# View results
print(result.summary())
result.plot()
Module Overview
- data - Data acquisition and management
- indicators - Technical indicator calculations
- strategy - Strategy development framework
- backtest - Backtest engine
- risk - Risk management
- performance - Performance analysis
- optimization - Parameter optimization
- trade - Live trading interface
- utils - Utility functions
Examples
Check the examples/ directory for more example code:
ma_strategy.py- Dual Moving Average Strategymacd_strategy.py- MACD Strategyoptimization_example.py- Parameter Optimization Example
Documentation
- User Guide: docs/GUIDE.md | 中文指南
- API Reference: docs/API.md
- Development Guide: docs/CONTRIBUTING.md
- Changelog: docs/CHANGELOG.md
Dependencies
- Python >= 3.8
- pandas >= 1.3.0
- numpy >= 1.21.0
Development
# Clone repository
git clone https://github.com/Delta-F/deltafq.git
cd deltafq
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Code formatting
black deltafq/
# Type checking
mypy deltafq/
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Issues and Pull Requests are welcome!
Contact
- Project Homepage: https://github.com/Delta-F/deltafq
- PyPI Homepage: https://pypi.org/project/deltafq/
- Issue Tracker: https://github.com/Delta-F/deltafq/issues
⚠️ Risk Warning: Quantitative trading involves risk. This library is for educational and research purposes only and does not constitute investment advice. Please exercise caution when trading live, as you bear the risk yourself.
Language Support
This project supports both English and Chinese documentation:
- English: README.md (current)
- 中文: README_zh.md
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deltafq-0.1.1.tar.gz.
File metadata
- Download URL: deltafq-0.1.1.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1698101e00dad97226f803947a980136bec5f82388d6606843204048c1587b0d
|
|
| MD5 |
b72e1a70e287726248f581a78bde1c3b
|
|
| BLAKE2b-256 |
3d5323989e9c25ac11d78469b347df216259aa33d4e39cbf285e6a6f9d2ab63e
|
File details
Details for the file deltafq-0.1.1-py3-none-any.whl.
File metadata
- Download URL: deltafq-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
341fe8fd01401906c7365157c022115af07e278e94be6bc7711a89365c7e7730
|
|
| MD5 |
d45a7595b3c9433788ef8015b9d3baa1
|
|
| BLAKE2b-256 |
f783cc348658d712928cf0b620b8899998d6c019db5a0b4b2eebf9124d5d1d94
|