A comprehensive quantitative trading system with AI-powered analysis, real-time data processing, and advanced risk management
- Overview
- Features
- Architecture
- Quick Start
- Installation
- Usage Examples
- Documentation
- Contributing
- License
This is a production-ready quantitative trading system that combines traditional financial analysis with cutting-edge AI/ML technologies. The system provides a complete pipeline from data collection to strategy execution, featuring real-time market data processing, advanced factor analysis, AI-powered sentiment analysis, and comprehensive risk management.
- ๐ฌ Advanced Factor Analysis: Multi-factor models with momentum, value, quality, and volatility factors
- ๐ค AI/LLM Integration: OpenAI GPT integration for market analysis and strategy recommendations
- ๐ Real-time Data: WebSocket-based real-time market data from multiple exchanges
- ๐ฏ Strategy Framework: Extensible strategy system with 8+ built-in quantitative strategies
- โก High Performance: C++ core engine for low-latency order execution
- ๐ Visualization: Interactive dashboards with Plotly and Streamlit
- ๐ก๏ธ Risk Management: Comprehensive risk controls and portfolio management
- Multi-source Data: Binance, Yahoo Finance, Alpha Vantage
- Real-time Streaming: WebSocket connections for live market data
- Data Processing: Automated data cleaning and feature engineering
- Storage: SQLite, PostgreSQL, and Redis caching support
- LLM Integration: OpenAI GPT for market analysis and insights
- NLP Processing: Sentiment analysis of news and social media
- ML Models: XGBoost, Random Forest, Neural Networks
- Feature Engineering: Technical indicators and statistical features
- Factor Models: Momentum, Value, Quality, Size, Volatility factors
- Stock Screening: Multi-factor stock selection and filtering
- Portfolio Optimization: Risk parity and mean-variance optimization
- Performance Analysis: Comprehensive backtesting and metrics
- Extensible Design: Easy to add custom strategies
- Built-in Strategies: 8+ proven quantitative strategies
- Strategy Registry: Centralized strategy management
- Parameter Optimization: Automated strategy optimization
- Position Sizing: Dynamic position sizing algorithms
- Risk Limits: VaR, CVaR, drawdown, and leverage limits
- Portfolio Management: Real-time portfolio monitoring
- Alert System: Price and risk alerts
- Web Dashboard: FastAPI-based web interface
- Streamlit App: Interactive data science dashboard
- Real-time Charts: K-line charts with technical indicators
- Mobile Friendly: Responsive design for all devices
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Python Layer (data_service/) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โข Data Fetchers โข Strategy Framework โข AI/ML โ
โ โข Factor Analysis โข Backtesting Engine โข Visualizationโ
โ โข Storage Layer โข Real-time Data โข Web UI โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ C++ Core Engine (backend/) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โข Order Execution โข Risk Management โข Portfolio โ
โ โข Data Loading โข Strategy Engine โข Performance โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
git clone https://github.com/yourusername/tradingsystem.git
cd tradingsystem
# Install all features
pip install -e .[ai,visualization,realtime,web]
# Or install specific features
pip install -e .[ai] # AI/ML features
pip install -e .[visualization] # Charts and dashboards
pip install -e .[realtime] # Real-time data
pip install -e .[web] # Web interface
# Test data fetching (no API keys required)
python examples/fetch_public_data.py
# Start Streamlit dashboard
python run_dashboard.py
# Visit: http://localhost:8501
# Or start web interface
python run_web_interface.py
# Visit: http://localhost:8000
- Python 3.8+
- C++17 compatible compiler (for backend)
- CMake 3.12+ (for backend)
# 1. Clone repository
git clone https://github.com/yourusername/tradingsystem.git
cd tradingsystem
# 2. Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# 3. Install Python dependencies
pip install -e .[ai,visualization,realtime,web]
# 4. Build C++ backend (optional)
cd backend
mkdir build && cd build
cmake ..
make -j4
cd ../..
# 5. Configure API keys (optional)
cp config.example.json config.json
# Edit config.json with your API keys
For full functionality, you can add API keys to config.json
:
{
"binance": {
"api_key": "your_binance_api_key",
"secret_key": "your_binance_secret"
},
"openai": {
"api_key": "your_openai_api_key"
},
"alpha_vantage": {
"api_key": "your_alpha_vantage_key"
}
}
from data_service.fetchers import BinanceFetcher
# Get cryptocurrency data (no API key required)
fetcher = BinanceFetcher()
btc_price = fetcher.get_current_price("BTCUSD")
print(f"BTC Price: ${btc_price:,.2f}")
from data_service.factors import FactorCalculator, FactorScreener
# Calculate factors
calculator = FactorCalculator()
factors = calculator.calculate_all_factors(symbol, prices, volumes)
# Screen stocks
screener = FactorScreener()
results = screener.create_momentum_screener().screen_stocks(factor_data)
from data_service.backtest import BacktestEngine
from data_service.strategies import MomentumStrategy
# Run backtest
engine = BacktestEngine(initial_capital=100000)
strategy = MomentumStrategy()
results = engine.run_backtest(strategy, historical_data)
from data_service.ai import LLMIntegration
# Get AI insights
llm = LLMIntegration(provider="openai")
analysis = llm.analyze_market(factor_data, price_data)
print(f"AI Recommendation: {analysis.content}")
- ๐ Factor Analysis - Multi-factor models and stock screening
- ๐ค AI & LLM Integration - AI-powered market analysis
- ๐ฏ Quantitative Strategies - Trading strategies guide
- ๐ Web Interface - Web dashboard usage
- ๐ LangChain Integration - Advanced LLM features
examples/fetch_public_data.py
- Basic data fetchingexamples/quantitative_strategies.py
- Strategy examplesexamples/factor_analysis_demo.py
- Factor analysis demoexamples/llm_nlp_complete_demo.py
- AI features demo
# Run all tests
pytest tests/ -v
# Run specific test modules
pytest tests/test_data_processor.py -v
pytest tests/test_llm_integration.py -v
We welcome contributions! Please see our Contributing Guide for details.
# Install development dependencies
pip install -e .[test,dev]
# Run tests
pytest tests/ -v
# Run linting
flake8 data_service/
black data_service/
- Follow PEP 8 for Python code
- Use type hints
- Add docstrings for all functions
- Write tests for new features
This project is licensed under the MIT License - see the LICENSE file for details.
This software is for educational and research purposes only. Trading involves substantial risk of loss and is not suitable for all investors. Past performance does not guarantee future results. Please consult with a financial advisor before making any investment decisions.
- Binance API for cryptocurrency data
- Yahoo Finance for stock market data
- OpenAI for AI capabilities
- Streamlit for dashboard framework
- FastAPI for web framework