zuytan/rustrade

Algorithmic trading bot in Rust with multi-agent architecture, 10 strategies, risk management, and native egui UI. Supports Alpaca & Binance. 🚧 Work in progress

0 stars0 forksUpdated Jan 24, 2026
npx skills add zuytan/rustrade

README

RustTrade Agentic Bot 🦀

CI License: MIT Rust

[!WARNING] This project is not production-ready and should not be used with real money. Using this trading bot involves significant financial risks. Use it only in simulation mode (Paper Trading) or for educational purposes.

A high-performance, multi-agent algorithmic trading system built in Rust. Capable of real-time market surveillance, trend analysis, and autonomous execution. Now featuring a full Native Desktop Interface.

📸 Screenshots

Rustrade Dashboard

🚀 Key Features

🧠 Intelligent Agents

  • Multi-Agent Architecture: 6 specialized agents (Sentinel, Scanner, Analyst, Risk Manager, Order Throttler, Executor).
  • Regime Detection: Automatically detects Bull, Bear, Sideways, and Volatile market regimes.
  • Dynamic Scanning: Real-time discovery of "Top Movers" and volatility opportunities (Stocks & Crypto).
  • System Health Monitoring: Centralized ConnectionHealthService that tracks physical connectivity and broadcasts status to all agents for safe execution.
  • Advanced Observability: Full tracing instrumentation, custom Prometheus metrics (win rate, drawdown, latency), and structured logging.

🖥️ Native User Interface (New)

  • High-Performance Dashboard: Built with egui (0.31) for zero-latency monitoring.
  • Real-Time Visuals: Live charts, interactive metric cards, and scrolling activity feed.
  • Internationalization (i18n): Fully localized in English 🇬🇧 and French 🇫🇷.
  • Manual Control: "Panic Button" and manual strategy overrides directly from the UI.

📈 Trading Strategies

  • Standard: Dual SMA Crossover (Golden/Death Cross).
  • Advanced: Triple Filter System (SMA Trend + RSI Momentum + MACD + ADX Trend Strength).
  • Dynamic: Automatically switches strategies based on Market Regime (e.g., Trend Riding vs Mean Reversion).
  • Statistical: Z-Score Mean Reversion & Statistical Momentum (Regression Slope).
  • Machine Learning: Random Forest Classifier trained on technical features (MLStrategy).
  • Trend Riding: Long-term trend following with trailing stops.
  • Mean Reversion: Contrarian strategy for overbought/oversold conditions (BB + RSI).

🛡️ Advanced Risk Management

  • Correlation Filters: Prevents exposure to highly correlated assets (Pearson matrix).
  • Sector Exposure Limits: Caps risk per industry sector.
  • Circuit Breakers: Daily Loss Limit, Max Drawdown Halt, Composite Risk Score.
  • Persistence ("No Amnesia"): Retains critical risk state (HWM, Daily Loss) across restarts.
  • Panic Mode: Blind emergency liquidation during data outages.
  • PDT Protection: Pattern Day Trader safeguards for accounts < $25k.
  • Singleton Connectivity: Unified WebSocket architecture preventing multi-connection conflicts and 406 errors.

🔬 Backtesting & Optimization

  • Historical Backtesting: Simulate strategies against past data with S&P500 benchmark comparison.
  • Parallel Execution: Ultra-fast multi-symbol batched backtesting using CPU parallelization.
  • Grid Search Optimizer: Systematically find best parameters (Sharpe, Sortino, Calmar optimization).
  • Performance Metrics: Calculates Alpha, Beta, Win Rate, and Risk-Adjusted Returns.

🛠️ Technical Stack

Core

  • Language: Rust 2024 Edition 🦀
  • Runtime: tokio (Asynchronous I/O, Channels, Actors)
  • Database: sqlx (SQLite 0.8) for local persistence of trades and candles
  • GUI: egui 0.31 + eframe (Immediate Mode GUI)

Data & Networking

  • Market Data: Alpaca API v2 (WebSocket & REST), OANDA (Forex), Polygon
  • WebSockets: tokio-tungstenite
  • Serialization: serde, serde_json

Intelligence & Math

  • Technical Indicators: ta crate + Custom Implementations (ADX, Pivots)
  • Financial Math: rust_decimal (Fixed-point arithmetic for zero precision loss)

⚙️ Configuration

The application is configured primarily via environment variables. You can set these in your shell or use a .env file in the project root.

Core & Connectivity

VariableDefaultDescription
MODEmockTrading mode: mock, alpaca, oanda.
ASSET_CLASSstockAsset class: stock or crypto.
ALPACA_API_KEY-Your Alpaca API Key.
ALPACA_SECRET_KEY-Your Alpaca Secret Key.

Risk Management

VariableDefaultDescription
RISK_APPETITE_SCORE-Master Override (1-9). Sets risk profile automat

...

Read full README