Skip to content

Latest commit

 

History

History
123 lines (92 loc) · 4.52 KB

File metadata and controls

123 lines (92 loc) · 4.52 KB

py_rt Trading System Documentation

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 Navigation

Getting Started

Architecture

API Reference

Development

User Guides

What is py_rt?

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

Key Features

  • 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

System Components

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
Loading
  1. Market Data Service (Rust) - Real-time market data ingestion
  2. Signal Bridge (Rust + Python) - ML-based signal generation
  3. Risk Manager (Rust) - Pre-trade risk checks and position tracking
  4. Execution Engine (Rust) - Smart order routing and execution

Performance

  • 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

Technology Stack

Python Stack

  • ML/Data: pandas, numpy, scipy, scikit-learn
  • Backtesting: Custom engine with walk-forward analysis
  • API: alpaca-py, pydantic
  • Testing: pytest, hypothesis

Rust Stack

  • Runtime: Tokio async
  • Messaging: ZeroMQ
  • Serialization: serde
  • API: reqwest, tungstenite
  • Testing: cargo test, proptest

Documentation Structure

This documentation is organized into five main sections:

  1. Guides - Step-by-step tutorials for common tasks
  2. Architecture - System design and technical decisions
  3. API Reference - Complete API documentation
  4. Developer - Contributing and development guides
  5. Examples - Code examples and use cases

Support and Community

License

Licensed under the Apache License 2.0. See LICENSE for details.

Author

Davi Castro Samora


Version: 0.1.0 | Last Updated: 2025-10-14