| Crates.io | algotrading |
| lib.rs | algotrading |
| version | 0.1.0-alpha.2 |
| created_at | 2025-10-27 02:26:34.099465+00 |
| updated_at | 2025-10-28 03:12:25.451343+00 |
| description | A high-performance algorithmic trading toolkit written in Rust, with no dependencies. |
| homepage | |
| repository | https://github.com/ndavidson19/algotrading |
| max_upload_size | |
| id | 1902146 |
| size | 504,806 |
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
Algotrading enables you to build high-frequency and medium-frequency trading strategies with:
Add this to your Cargo.toml:
[dependencies]
algotrading = "0.1.0-alpha.2"
use algotrading::prelude::*;
fn main() {
// Rolling statistics with 100-sample window
let mut stats = RollingStats::<f64, 100>::new();
// Technical indicators
let mut rsi = RSI::standard();
let mut macd = MACD::standard();
// Regime detection
let mut regime = MarkovSwitching::spy_default();
for price in price_stream {
// Update indicators
let (mean, std) = stats.update(price);
let rsi_val = rsi.update(price);
let (macd_line, signal, _) = macd.update(price);
// Calculate return and update regime
let ret = (price - prev_price) / prev_price;
regime.update(ret);
// Generate signal
if macd_line > signal && rsi_val < 70.0 && regime.current_state() == 1 {
println!("BUY signal at {}", price);
}
}
}
Process multiple assets in parallel with 4-8x speedup:
use algotrading::prelude::*;
use algotrading::numeric::f64x8;
// Process 8 assets simultaneously
let mut stats = RollingStats::<f64x8, 100>::new();
let prices = f64x8::from_array([100.0, 101.0, 99.0, 102.0, 98.0, 103.0, 97.0, 104.0]);
let (means, stds) = stats.update(prices);
See examples/ for complete trading strategy implementations.
Enable SIMD acceleration for 4-8x speedup on modern hardware:
[dependencies]
algotrading = { version = "0.1", features = ["simd"] }
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.
| 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.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Before submitting a PR:
cargo test to ensure all tests passcargo clippy to check for common mistakesRun the benchmark suite:
cargo bench
Benchmark results are saved in target/criterion/ with detailed HTML reports.
This project is licensed under the MIT License.
Built by Nicholas Davidson for the quantitative trading community.
Special thanks to all contributors.