Welcome to the comprehensive documentation for the py_rt (Python + Rust Trading) system - a high-performance algorithmic trading platform combining Python's ML ecosystem with Rust's speed and safety.
- Quick Start Guide - Get up and running in 10 minutes
- Installation - Detailed installation instructions
- Configuration Guide - System configuration
- First Strategy - Build your first trading strategy
- System Overview - High-level architecture
- Component Design - Detailed component descriptions
- Data Flow - Message flow and communication
- Deployment - Production deployment guide
- Python API - Python modules and classes
- Rust API - Rust crates and types
- REST API - REST endpoints
- WebSocket API - WebSocket protocol
- ZMQ Messages - ZeroMQ message formats
- Contributing - How to contribute
- Code Style - Coding standards
- Testing - Testing strategies
- Performance Tuning - Optimization guide
- Troubleshooting - Common issues
- Strategy Development - Build trading strategies
- Backtesting - Test strategies on historical data
- ML Integration - Integrate ML models
- Risk Management - Configure risk limits
- Monitoring - System monitoring and alerts
py_rt is a hybrid trading system that combines:
- Python for strategy development, ML models, and backtesting
- Rust for low-latency execution, risk management, and market data processing
- ZeroMQ for high-performance inter-process communication
- Alpaca Markets API for live trading and market data
- Low Latency: Sub-5ms end-to-end order execution
- Type Safety: Compile-time guarantees across Rust and Python
- ML Ready: PyO3 bindings for seamless Python ML integration
- Risk Controls: Pre-trade risk checks and circuit breakers
- Observability: Prometheus metrics and structured logging
- Scalable: Microservices architecture scales horizontally
graph TD
A[Market Data Service] -->|ZMQ| B[Signal Bridge]
B -->|ZMQ| C[Risk Manager]
C -->|ZMQ| D[Execution Engine]
D -->|REST| E[Alpaca Markets]
E -->|WebSocket| A
- Market Data Service (Rust) - Real-time market data ingestion
- Signal Bridge (Rust + Python) - ML-based signal generation
- Risk Manager (Rust) - Pre-trade risk checks and position tracking
- Execution Engine (Rust) - Smart order routing and execution
- Market Data Processing: 50,000+ updates/second
- Order Book Updates: <50μs latency (p99)
- Signal to Execution: <5ms end-to-end
- Memory Footprint: <100MB per component
- ML/Data: pandas, numpy, scipy, scikit-learn
- Backtesting: Custom engine with walk-forward analysis
- API: alpaca-py, pydantic
- Testing: pytest, hypothesis
- Runtime: Tokio async
- Messaging: ZeroMQ
- Serialization: serde
- API: reqwest, tungstenite
- Testing: cargo test, proptest
This documentation is organized into five main sections:
- Guides - Step-by-step tutorials for common tasks
- Architecture - System design and technical decisions
- API Reference - Complete API documentation
- Developer - Contributing and development guides
- Examples - Code examples and use cases
- GitHub Issues: Report bugs and request features
- GitHub Discussions: Ask questions and share ideas
- Documentation: You're here!
Licensed under the Apache License 2.0. See LICENSE for details.
Davi Castro Samora
- GitHub: @SamoraDC
Version: 0.1.0 | Last Updated: 2025-10-14