mantis-ta
Composable technical analysis and strategy engine for Rust.
Pure Rust technical indicators with a type-safe strategy composition API. No C dependencies. No FFI. No unsafe in the default build.
Every indicator is verified against TA-Lib reference outputs.
[]
= "0.1"
Quick Start
Indicators — Streaming
Feed candles one at a time. Get values out. O(1) per update, zero heap allocations in the hot path.
use *;
let mut ema = EMAnew;
let mut rsi = RSInew;
for candle in candles.iter
Indicators — Batch
Compute over a full series at once. Returns Vec<Option<f64>> aligned with input candles (None during warmup).
use *;
let sma_values = SMAnew.calculate;
let bb_values = new.calculate;
for in bb_values.iter.enumerate
Strategy Composition
Define complete trading strategies as composable, type-checked rules. Invalid strategies don't compile.
use *;
use *;
let strategy = builder
.timeframe
.entry
.exit
.stop_loss
.take_profit
.max_position_size_pct
.build?;
// Evaluate against historical data
let signals: = strategy.evaluate?;
// Or stream live — same strategy, bar by bar
let mut engine = strategy.into_engine;
for candle in live_feed
Backtesting
Honest simulation with realistic slippage, commissions, and next-bar execution.
use *;
let result = backtest?;
println!;
println!;
println!;
println!;
println!;
Available Indicators
Trend
SMA · EMA · WMA · DEMA · TEMA · MACD · Ichimoku · Parabolic SAR · ADX · Supertrend
Momentum
RSI · Stochastic · CCI · Williams %R · ROC · MFI
Volatility
Bollinger Bands · ATR · Keltner Channels · Standard Deviation
Volume
OBV · Volume SMA · VWAP · Accumulation/Distribution
Support/Resistance
Pivot Points · Donchian Channels · Fibonacci Retracement
See the full indicator list in the API docs.
Features
[]
= { = "0.1", = ["strategy", "backtest"] }
| Feature | Default | Description |
|---|---|---|
serde |
✓ | Serialize strategies, indicators, and results to JSON |
strategy |
Strategy composition engine | |
backtest |
Backtesting engine (requires strategy) |
|
ndarray |
Interop with the ndarray ecosystem |
|
full-indicators |
All 50+ indicators (default includes 30 most common) | |
simd |
SIMD-accelerated batch computation (uses unsafe) |
|
all |
Everything |
Design Principles
- Correctness first. Every indicator verified against TA-Lib (< 1e-10 relative error).
- Streaming-first. O(1) incremental updates for live data. Batch is also first-class.
- Zero allocation in the hot path.
next()never heap-allocates. - No unsafe by default. Safe Rust is fast enough.
- Type system enforces validity. A strategy without a stop-loss is a compile error, not a runtime surprise.
- Honest backtesting. No lookahead bias. Slippage and commissions are mandatory, not optional.
Performance
Benchmarked on Apple M-series, single core:
| Operation | Time |
|---|---|
| EMA(20) per bar (streaming) | < 100 ns |
| RSI(14) batch, 2000 bars | < 15 µs |
| Strategy eval (5 conditions), 2000 bars | < 200 µs |
| Full backtest, 2 years daily | < 5 ms |
Run benchmarks yourself: cargo bench
Custom Indicators
Implement the Indicator trait to create your own:
use *;
Contributing
Contributions welcome! Please read CONTRIBUTING.md before opening a PR.
Adding a new indicator? See the Contributor Guide for the full checklist: implement the trait, add TA-Lib verification, write benchmarks, document it.
License
Licensed under either of:
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate shall be dual-licensed as above, without any additional terms or conditions.