Skip to content

Advanced quantitative trading system featuring multi-asset portfolios, 8+ data sources (Yahoo, Alpha Vantage, etc.), modular strategies, comprehensive backtesting & reporting

License

Notifications You must be signed in to change notification settings

LouisLetcher/quant-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

68 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Quantitative Analysis System

A comprehensive, production-ready quantitative analysis system with multi-asset support, advanced portfolio optimization, and extensive backtesting capabilities.

✨ Features

πŸ“Š Multi-Asset Trading Support

  • Stocks: Individual stocks, ETFs, indices (5 specialized TraderFox portfolios)
  • Forex: 72+ major, minor, and exotic currency pairs
  • Crypto: 220+ Bybit perpetual futures with real-time data
  • Commodities: 46+ CFD/rolling futures contracts
  • Bonds: 30+ government and corporate bond ETFs
  • Indices: 114+ global country and sector ETFs

🌐 Multiple Data Sources

  • Yahoo Finance (Free, no API key required)
  • Alpha Vantage (Stock/Forex/Crypto data)
  • Twelve Data (Multi-asset financial data)
  • Polygon.io (Real-time market data)
  • Tiingo (Stock and ETF data)
  • Finnhub (Market data)
  • Bybit (Crypto derivatives)
  • Pandas DataReader (Economic data)

🧠 Advanced Portfolio Management

  • 5 Specialized TraderFox Portfolios:
    • German DAX/MDAX stocks (130 symbols)
    • US Technology sector (275 symbols)
    • US Healthcare/Biotech (450 symbols)
    • US Financials (185 symbols)
    • European blue chips (95 symbols)

⚑ Unified CLI System

All functionality accessible through a single command interface:

# Portfolio Testing
poetry run python -m src.cli.unified_cli portfolio test-all --portfolio config/portfolios/crypto.json --metric sharpe_ratio --period max --test-timeframes --open-browser

# Data Management
poetry run python -m src.cli.unified_cli data download --symbols BTC-USD,ETH-USD --start-date 2023-01-01 --source bybit

# Cache Management
poetry run python -m src.cli.unified_cli cache stats
poetry run python -m src.cli.unified_cli cache clear

# Report Generation
poetry run python -m src.cli.unified_cli reports organize

πŸ”„ Smart Symbol Transformation

Automatic symbol format conversion between data sources:

  • Yahoo Finance: EURUSD=X
  • Twelve Data: EUR/USD
  • Bybit: BTCUSDT
  • Polygon: BTC-USD

πŸ“ˆ Interactive Reporting

  • HTML Portfolio Reports with Plotly charts
  • Performance Analytics with risk metrics
  • Comparison Analysis across strategies and timeframes
  • Auto-opening browser for immediate visualization

🐳 Docker Support

Complete containerization with docker-compose:

  • Production deployment
  • Development environment
  • Testing environment
  • Jupyter Lab for analysis
  • API service
  • Database (PostgreSQL)
  • Caching (Redis)
  • Monitoring (Prometheus + Grafana)

πŸš€ Quick Start

Prerequisites

  • Python 3.12+
  • Poetry
  • Docker (optional)

Installation

  1. Clone the repository:

    git clone https://github.com/LouisLetcher/quant-system.git
    cd quant-system
  2. Install dependencies:

    poetry install
  3. Set up environment variables:

    cp .env.example .env
    # Edit .env with your API keys
  4. Test the system:

    poetry run python -m src.cli.unified_cli cache stats

Example Usage

Test a cryptocurrency portfolio:

poetry run python -m src.cli.unified_cli portfolio test-all \
  --portfolio config/portfolios/crypto.json \
  --metric sharpe_ratio \
  --period max \
  --test-timeframes \
  --open-browser

Download forex data:

poetry run python -m src.cli.unified_cli data download \
  --symbols EURUSD=X,GBPUSD=X \
  --start-date 2023-01-01 \
  --end-date 2024-01-01 \
  --source twelve_data

Analyze German DAX stocks:

poetry run python -m src.cli.unified_cli portfolio test-all \
  --portfolio config/portfolios/stocks_traderfox_dax.json \
  --metric sortino_ratio \
  --period 1y \
  --test-timeframes

πŸ“‚ Project Structure

quant-system/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ core/                 # Unified system core
β”‚   β”‚   β”œβ”€β”€ data_manager.py   # Multi-source data management
β”‚   β”‚   β”œβ”€β”€ backtest_engine.py # Unified backtesting
β”‚   β”‚   └── cache_manager.py  # Intelligent caching
β”‚   β”œβ”€β”€ cli/                  # Command-line interface
β”‚   β”‚   └── unified_cli.py    # Main CLI entry point
β”‚   β”œβ”€β”€ reporting/            # Report generation
β”‚   β”œβ”€β”€ portfolio/            # Portfolio optimization
β”‚   └── utils/                # Utilities
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ portfolios/           # Portfolio configurations
β”‚   β”‚   β”œβ”€β”€ crypto.json       # Crypto futures
β”‚   β”‚   β”œβ”€β”€ forex.json        # Currency pairs
β”‚   β”‚   β”œβ”€β”€ bonds.json        # Fixed income
β”‚   β”‚   β”œβ”€β”€ commodities.json  # Commodity CFDs
β”‚   β”‚   β”œβ”€β”€ indices.json      # Global indices
β”‚   β”‚   └── stocks_traderfox_*.json # TraderFox stocks
β”‚   └── optimization_config.json
β”œβ”€β”€ docs/                     # Documentation
β”œβ”€β”€ tests/                    # Test suite
β”œβ”€β”€ docker-compose.yml        # Container orchestration
β”œβ”€β”€ Dockerfile               # Container definition
└── pyproject.toml           # Dependencies

πŸ”§ Configuration

Portfolio Configuration

Each portfolio is defined in JSON format with:

  • symbols: List of trading instruments
  • data_sources: Primary and fallback data sources
  • intervals: Supported timeframes
  • risk_parameters: Position sizing and risk management
  • optimization: Strategy and metric preferences

Example:

{
  "crypto": {
    "name": "Crypto Portfolio",
    "symbols": ["BTCUSDT", "ETHUSDT", ...],
    "data_sources": {
      "primary": ["bybit", "polygon", "twelve_data"],
      "fallback": ["alpha_vantage", "yahoo_finance"]
    },
    "intervals": ["1m", "5m", "15m", "30m", "1h", "4h", "1d", "1w"],
    "risk_profile": "high",
    "leverage": 10
  }
}

Environment Variables

Required API keys and configuration:

# Data Sources
ALPHA_VANTAGE_API_KEY=your_key
TWELVE_DATA_API_KEY=your_key
POLYGON_API_KEY=your_key
BYBIT_API_KEY=your_key
BYBIT_API_SECRET=your_secret

# System Configuration
CACHE_ENABLED=true
CACHE_DURATION_HOURS=24

🐳 Docker Deployment

Quick Start with Docker

# Run production system
docker-compose up quant-system

# Run with full stack
docker-compose --profile database --profile api --profile monitoring up

Available Profiles

  • dev: Development environment
  • test: Testing environment
  • api: Web API service
  • database: PostgreSQL database
  • cache: Redis caching
  • monitoring: Prometheus + Grafana
  • jupyter: Jupyter Lab analysis

πŸ“Š Portfolio Portfolios

Crypto (220+ symbols)

Bybit perpetual futures covering:

  • Major cryptocurrencies (BTC, ETH, etc.)
  • DeFi tokens
  • Layer 1/2 protocols
  • Meme coins
  • Emerging altcoins

Forex (72+ pairs)

Complete currency coverage:

  • Major pairs (EUR/USD, GBP/USD, etc.)
  • Minor pairs (cross currencies)
  • Exotic pairs (emerging markets)

TraderFox Stocks (1000+ symbols)

Research-based stock selection:

  • German DAX: SAP, Siemens, BMW, etc.
  • US Tech: FAANG, semiconductors, software
  • US Healthcare: Pharma, biotech, devices
  • US Financials: Banks, fintech, insurance
  • European: ASML, NestlΓ©, LVMH, etc.

Bonds (30+ ETFs)

Fixed income diversification:

  • Government bonds (US, international)
  • Corporate bonds
  • TIPS (inflation-protected)
  • Municipal bonds

Commodities (46+ CFDs)

Direct commodity exposure:

  • Precious metals (Gold, Silver, Platinum)
  • Energy (Oil, Natural Gas, Coal)
  • Agriculture (Wheat, Corn, Coffee)
  • Industrial metals (Copper, Aluminum)

Indices (114+ ETFs)

Global market coverage:

  • Country-specific ETFs
  • Sector ETFs
  • Factor-based ETFs
  • Regional groupings

πŸ“š Documentation

πŸ§ͺ Testing & Development

Testing Commands

# Run all tests with coverage
pytest

# Run only unit tests
pytest -m "not integration"

# Run only integration tests
pytest -m "integration"

# Run tests with verbose output
pytest -v

# Run specific test file
pytest tests/test_data_manager.py

# Run tests in parallel
pytest -n auto

Code Quality

# Format code
poetry run black .

# Sort imports
poetry run isort .

# Lint code
poetry run ruff check .

# Pre-commit checks (aligned with CI)
pre-commit run --all-files

Development Setup

# Install dependencies with dev tools
poetry install --with dev

# Activate virtual environment
poetry shell

# Install pre-commit hooks
pre-commit install

# Build package
poetry build

CI/CD Pipeline (Simplified for Showcase)

  • Essential checks: Format, lint, test, build on every push/PR
  • GitHub native features: CodeQL security scanning, Dependabot dependency updates
  • Automated releases: GitHub releases with artifacts on tags
  • KISS principle: Minimal, focused workflows leveraging GitHub's built-in capabilities

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

  • Documentation: Check the docs/ directory
  • Issues: Open a GitHub issue
  • Discord: Join our trading community

πŸ”— Links


⚑ Built for speed, designed for scale, optimized for profit.

About

Advanced quantitative trading system featuring multi-asset portfolios, 8+ data sources (Yahoo, Alpha Vantage, etc.), modular strategies, comprehensive backtesting & reporting

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •