Algotrading
A high-performance algorithmic trading library for real-time market systems.
Algotrading provides low-latency statistical and econometric primitives optimized for quantitative trading strategies. It is:
-
Fast: SIMD-accelerated operations deliver nanosecond latencies with 4-8x speedups on modern hardware.
-
No Dependencies: Pure Rust implementation with zero external dependencies for easy integration into trading systems.
-
Zero-cost: Stack-allocated, const-generic data structures with no heap allocations in hot paths.
-
Flexible: Generic over scalar and SIMD types (f64, f64x4, f64x8) with a clean, unified API.
Documentation | API Reference | Examples | Performance Guide
Overview
Algotrading enables you to build high-frequency and medium-frequency trading strategies with:
- Statistical functions — Mean, variance, correlation, skewness, kurtosis with SIMD
- Probability distributions — Normal, Student-T, Log-Normal with fast parametric fitting
- Rolling statistics — Constant-time O(1) updates with compile-time window sizes
- Technical indicators — MACD, RSI, Bollinger Bands, EWMA, ATR
- Options pricing — Black-Scholes, Greeks (Delta, Gamma, Vega, Theta), implied volatility
- Risk metrics — VaR, Sharpe ratio, max drawdown, Kelly criterion
- Matrix operations — Cholesky, eigenvalue decomposition, portfolio optimization
- Regime detection — Markov switching models, Hidden Markov Models
- Data quality — Real-time anomaly detection, staleness monitoring
Quick Start
Add this to your Cargo.toml:
[]
= "0.1.0-alpha.2"
Example: Building a Trading Signal
use *;
SIMD Acceleration
Process multiple assets in parallel with 4-8x speedup:
use *;
use f64x8;
// Process 8 assets simultaneously
let mut stats = new;
let prices = from_array;
let = stats.update;
See examples/ for complete trading strategy implementations.
Features
Enable SIMD acceleration for 4-8x speedup on modern hardware:
[]
= { = "0.1", = ["simd"] }
Performance
Target latencies for trading operations:
| Operation | Latency | Notes |
|---|---|---|
| Rolling stats update | ~10ns | O(1) constant time |
| Mean (10K samples, SIMD) | ~8μs | 5x faster than scalar |
| Distribution fitting (1K samples) | ~2μs | With SIMD acceleration |
| Cholesky decomposition 4×4 | ~300ns | Portfolio variance |
| Options Greeks | ~50ns | Delta, Gamma, Vega |
See the Performance Guide for comprehensive benchmarks and optimization tips.
Documentation
- API Documentation — Complete API reference
- Performance Guide — Benchmarks and optimization
- Examples — Real-world trading strategies
- Module Documentation — Detailed module guides
Core Modules
| Module | Description |
|---|---|
stats |
Core statistics (mean, variance, correlation) + rolling statistics with SIMD |
probability |
Distributions (Normal, Student-T, Log-Normal), KDE, Monte Carlo |
ta |
Technical indicators (MACD, RSI, Bollinger Bands, EWMA, ATR) |
options |
Black-Scholes pricing, Greeks, implied volatility, local volatility |
risk |
VaR, Sharpe ratio, max drawdown, Kelly criterion |
matrix |
Cholesky, eigenvalue decomposition, portfolio optimization |
regime |
Markov switching, Hidden Markov Models |
filters |
Kalman filtering for state estimation |
data |
Real-time data quality monitoring and anomaly detection |
See the Module Documentation for detailed guides.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Before submitting a PR:
- Run
cargo testto ensure all tests pass - Run
cargo clippyto check for common mistakes - Add benchmarks for performance-critical code
- Update documentation as needed
Benchmarks
Run the benchmark suite:
Benchmark results are saved in target/criterion/ with detailed HTML reports.
License
This project is licensed under the MIT License.
Acknowledgments
Built by Nicholas Davidson for the quantitative trading community.
Special thanks to all contributors.