Skip to content

rameshgitter/QuantX-Engine

Repository files navigation

πŸš€ QuantX Engine

Ultra-Low Latency High-Frequency Trading Platform

Version License Build Language Python

Production-ready HFT platform combining C++ performance with Python ML capabilities

🎯 Quick Start β€’ πŸ“– Documentation β€’ πŸ§ͺ Testing β€’ πŸš€ Deployment


✨ Core Features

πŸ”₯ Ultra-Low Latency Engine

  • < 100ΞΌs market data processing
  • < 500ΞΌs order placement
  • < 1ms ML inference
  • < 2ms end-to-end execution

🧠 Advanced ML Integration

  • LSTM & Transformer models
  • ONNX runtime optimization
  • Real-time prediction pipeline
  • Feature engineering automation

πŸ›‘οΈ Risk Management

  • Real-time position tracking
  • VaR calculation & monitoring
  • Emergency stop mechanisms
  • Multi-symbol risk controls

πŸ—οΈ Production Infrastructure

  • Docker containerization
  • Prometheus/Grafana monitoring
  • PostgreSQL & Redis integration
  • Automated VPS deployment

🎯 Quick Start

πŸš€ One-Command Setup

# πŸ”₯ Automated installation (recommended)
git clone <repository-url> && cd quantx-engine
chmod +x scripts/setup.sh && ./scripts/setup.sh

What this does: Installs dependencies β†’ Sets up Python env β†’ Trains ML models β†’ Builds C++ engine β†’ Runs tests

⚑ Instant Deployment Options

Method Setup Time Best For
🐳 Docker docker-compose up -d Local development
☁️ VPS ./scripts/deploy.sh Paper trading
πŸ–₯️ Local ./build/quantx_engine Testing & debug

πŸ“‹ System Requirements

πŸ–₯️ Hardware & OS Requirements
Component Minimum Recommended
OS Ubuntu 20.04+ / macOS 10.15+ Ubuntu 22.04 LTS
CPU Multi-core x64 Intel/AMD 8+ cores
RAM 8GB 16GB+
Storage 10GB free 50GB SSD
Network Stable broadband Low-latency connection
πŸ› οΈ Software Dependencies
# Core dependencies
- C++17 compiler (GCC 9+, Clang 10+)
- CMake 3.16+
- Python 3.8+
- Docker & Docker Compose (optional)

# Libraries (auto-installed)
- Boost 1.70+
- ONNX Runtime 1.16+
- WebSocket++
- nlohmann/json

πŸ› οΈ Manual Installation

Step 1: System Dependencies

🐧 Ubuntu/Debian
sudo apt-get update && sudo apt-get install -y \
    build-essential cmake git wget curl pkg-config \
    libboost-all-dev libssl-dev nlohmann-json3-dev \
    libwebsocketpp-dev python3 python3-pip python3-venv
🍎 macOS
brew install cmake boost openssl nlohmann-json websocketpp python3

Step 2: ONNX Runtime Setup

# Download and install ONNX Runtime
wget https://github.com/microsoft/onnxruntime/releases/download/v1.16.3/onnxruntime-linux-x64-1.16.3.tgz
tar -xzf onnxruntime-linux-x64-1.16.3.tgz
sudo cp -r onnxruntime-linux-x64-1.16.3/include/* /usr/local/include/
sudo cp -r onnxruntime-linux-x64-1.16.3/lib/* /usr/local/lib/
sudo ldconfig

Step 3: Python Environment

# Create and activate virtual environment
python3 -m venv venv && source venv/bin/activate

# Install ML dependencies
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install numpy pandas scikit-learn onnx onnxruntime joblib matplotlib seaborn

Step 4: Build & Deploy

# Train ML models
source venv/bin/activate && python scripts/export_models_to_onnx.py

# Build C++ engine
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release && make -j$(nproc)

# πŸŽ‰ Launch the engine
./quantx_engine

βš™οΈ Configuration

πŸ”§ Main Config (config/config.json)

{
  "engine": {
    "initial_capital": 1000000.0,
    "paper_trading": true,
    "log_level": "INFO"
  },
  "market_data": {
    "websocket_url": "wss://api.kite.trade/ws",
    "api_key": "your_api_key_here",
    "symbols": ["NSE:NIFTY50", "NSE:BANKNIFTY", "NSE:RELIANCE"]
  },
  "risk_management": {
    "max_position_value": 100000.0,
    "max_daily_loss": 50000.0,
    "max_drawdown": 0.15,
    "leverage_limit": 2.0
  }
}

πŸ”‘ API Keys Setup

Provider Purpose Setup Link
Zerodha Kite NSE/BSE Market Data kite.trade
Paper Trading Risk-free Testing No keys required βœ…

πŸ“Š Monitoring & Analytics

πŸŽ›οΈ Grafana Dashboard

  • URL: http://localhost:3000
  • Credentials: admin / admin
  • Real-time metrics: Latency, P&L, Risk, System health

πŸ“ˆ Performance Metrics

Component Target Achieved Status
Market Data Processing < 100ΞΌs ~50ΞΌs βœ…
Order Placement < 500ΞΌs ~200ΞΌs βœ…
ML Inference < 1ms ~0.3ms βœ…
Risk Checks < 50ΞΌs ~20ΞΌs βœ…
End-to-End < 2ms ~1ms πŸš€

πŸ“ Log Monitoring

# Main engine logs
tail -f logs/quantx_engine.log

# Performance metrics
tail -f logs/performance.log

# Trade execution logs
tail -f logs/trades.log

πŸ§ͺ Testing

πŸ”¬ Test Suite

# Unit tests
cd build && ./test_quantx

# Performance benchmarks
./quantx_engine --benchmark

# ML model validation
python scripts/benchmark_models.py

# Paper trading simulation
./quantx_engine --paper-trading --duration=3600

βœ… Validation Checklist

  • All unit tests passing
  • Latency targets met
  • ML models converged
  • Risk limits enforced
  • Paper trading profitable

πŸ—οΈ Project Architecture

quantx-engine/
β”œβ”€β”€ πŸ”§ src/                    # C++ Core Engine
β”‚   β”œβ”€β”€ core/                  # Market data processing
β”‚   β”œβ”€β”€ ml/                    # ONNX ML inference
β”‚   β”œβ”€β”€ risk/                  # Risk management
β”‚   └── trading/               # Order execution
β”œβ”€β”€ 🧠 scripts/               # Python ML pipeline
β”œβ”€β”€ βš™οΈ config/                # Configuration files
β”œβ”€β”€ πŸ§ͺ tests/                 # Unit & integration tests
β”œβ”€β”€ πŸ“Š monitoring/            # Grafana dashboards
└── 🐳 docker-compose.yml    # Container orchestration

πŸš€ Production Deployment

πŸ”’ Security Checklist

  • Change default passwords
  • Enable SSL/TLS encryption
  • Configure firewall rules
  • Set up log rotation
  • Enable monitoring alerts
  • Implement backup procedures

⚑ Performance Optimization

  • CPU affinity for critical threads
  • Huge pages memory allocation
  • Network buffer optimization
  • Kernel bypass (DPDK) setup
  • Hot path profiling & optimization

πŸ“‹ Compliance Requirements

  • Audit logging implementation
  • Regulatory reporting setup
  • Data retention policies
  • Trade reconstruction capability
  • Emergency kill switches

🀝 Contributing

We welcome contributions! Here's how to get started:

  1. 🍴 Fork the repository
  2. 🌿 Create a feature branch
  3. ✨ Make your changes
  4. πŸ§ͺ Add comprehensive tests
  5. βœ… Run the test suite: ./build/test_quantx
  6. πŸ“ Submit a pull request

πŸ“ Code Style Guidelines

Language Style Guide Formatter
C++ Google C++ Style clang-format
Python PEP 8 black
Documentation Markdown prettier

πŸ“š Documentation

πŸ“– API Reference

πŸŽ“ Tutorials


πŸ› οΈ Troubleshooting

πŸ”¨ Build Issues
# Missing ONNX Runtime
export CMAKE_PREFIX_PATH=/usr/local:$CMAKE_PREFIX_PATH

# Boost libraries not found
sudo apt-get install libboost-all-dev

# WebSocket++ headers missing
sudo apt-get install libwebsocketpp-dev
🚨 Runtime Errors
# Market data connection failed
# β†’ Check API keys in config/config.json

# ONNX model not found
# β†’ Run: python scripts/export_models_to_onnx.py

# Permission denied
# β†’ Run: chmod +x scripts/*.sh
⚑ Performance Issues
# Enable CPU performance mode
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

# Increase network buffer sizes
echo 'net.core.rmem_max = 134217728' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

πŸ“ž Support & Community

Platform Link Purpose
πŸ› Issues GitHub Issues Bug reports
πŸ’¬ Discussions GitHub Discussions Q&A
πŸ“§ Email support@quantx-engine.com Direct support
πŸ’¬ Discord QuantX Community Real-time chat

πŸ“„ License

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


⚠️ Important Disclaimer

🚨 Risk Warning: This software is for educational and research purposes only. Trading financial instruments involves substantial risk of loss and is not suitable for all investors. Past performance is not indicative of future results. The authors and contributors are not responsible for any financial losses incurred through the use of this software.


πŸ™ Acknowledgments

Special thanks to the open-source community and these amazing projects:

Library Purpose Link
🧠 ONNX Runtime ML Inference onnxruntime.ai
🌐 WebSocket++ Real-time Data GitHub
πŸ“Š nlohmann/json JSON Parsing GitHub
πŸš€ Boost System Utilities boost.org
πŸ”₯ PyTorch ML Training pytorch.org

πŸ“Š Project Statistics

⭐ Star History

Star History Chart

πŸ“ˆ Repository Stats

GitHub stars GitHub forks GitHub issues GitHub pull requests

πŸ‘₯ Contributors & Activity

GitHub contributors GitHub last commit GitHub commit activity

πŸ“Š Code Statistics

GitHub repo size GitHub language count GitHub top language Lines of code

πŸ“‹ Project Health

GitHub release GitHub downloads

🎯 Built with ❀️ for the quantitative trading community

⭐ Star this repo if you find it useful! ⭐

About

AI-powered Quantitative Trading Engine for backtesting, simulation, and live execution.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published