mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-08 14:07:44 +00:00
5c3b3fbab45a2f57a907f235d98debf130d17000
- Updated the Prime method signature in multiple indicators (Jma, Kama, Lsma, Mama, Mgdi, Pwma, Rma, Sma, Ssf, Super, T3, Tema, Trima, Usf, Vidya, Wma, Atr) to accept an optional TimeSpan parameter for improved flexibility. - Added unit tests for Lsma to verify Dispose functionality, ensuring proper unsubscription from the source and thread safety. - Enhanced Mama and Wma classes to handle non-finite inputs gracefully and added checks for valid parameters in constructors. - Introduced additional tests for T3 to validate constructor behavior with invalid volume factors. - Ensured all indicators maintain consistent behavior when handling edge cases, such as empty buffers and non-finite values.
QuanTAlib - Quantitative Technical Indicators Without Compromises
TA libraries face a fundamental choice: accept approximations for simplicity OR enforce math rigor. QuanTAlib chooses rigor.
Quantitative TA library (QuanTAlib) is a C# library built on the premise that you shouldn't have to choose. Modern CPUs process 4-8 FLOPS per cycle via SIMD. Modern .NET exposes memory layouts making hardware acceleration trivial. QuanTAlib exploits both. Result: mathematically rigorous indicators at speeds making real-time multi-symbol analysis practical on ordinary hardware.
Key Features
- Zero Allocation: Hot paths are allocation-free. No GC pauses during trading.
- SIMD Accelerated: Uses AVX2/AVX-512 for 8x throughput on modern CPUs.
- O(1) Streaming: Constant time updates regardless of lookback period.
- Platform Agnostic: Runs on .NET 8/9/10, compatible with Quantower, NinjaTrader, QuantConnect.
- Mathematically Rigorous: Validated against original research papers and established libraries.
Indicators
| Category | What It Measures | Representative Indicators |
|---|---|---|
| Trends | Direction and strength of price movement through smoothing and filtering | SMA, EMA, WMA, HMA, JMA, KAMA, ALMA, DEMA, TEMA, T3 |
| Volatility | Size and variability of price movements | ATR, StdDev, Bollinger Bands, Keltner Channels, Historical Volatility |
| Momentum | Speed and magnitude of price changes | RSI, Stochastic, CCI, Williams %R, MACD, Momentum, ROC |
| Volume | Trading activity and price-volume relationships | OBV, VWAP, Volume ROC, A/D, MFI |
| Channels | Price boundaries and range definitions | Donchian Channels, Keltner Channels, Price Channels |
| Statistics | Mathematical relationships between price series | Correlation, Covariance, Beta, Z-Score, Linear Regression |
| Numerics | Mathematical transformations and signal processing | Convolution, Filters, Integration, Differentiation, Smoothing |
| Errors | Measurement accuracy and model fit quality | MAE, RMSE, Residuals, R-Squared |
| Forecasts | Future price prediction and projection | Linear Regression Forecast, Moving Average Projection |
| Cycles | Periodic patterns and dominant frequencies | Hilbert Transform, Dominant Cycle, Instantaneous Phase, Sine Wave |
Quick Start
Install from NuGet:
dotnet add package QuanTAlib
Calculate an SMA in real-time:
using QuanTAlib;
var sma = new Sma(period: 14);
double price = 100.0;
// Update with new price
var result = sma.Update(new TValue(DateTime.UtcNow, price));
if (result.IsHot)
{
Console.WriteLine($"SMA: {result.Value}");
}
Performance Snapshot
QuanTAlib is designed for speed. Here is how it compares calculating a 500,000 bar SMA against other libraries:
| Library | Mean Time | Allocations | Relative Speed |
|---|---|---|---|
| QuanTAlib (Span) | 318.3 μs | 0 B | 1.00x (baseline) |
| TA-Lib | 356.4 μs | 34 B | 1.12x slower |
| Tulip Indicators | 359.3 μs | 0 B | 1.13x slower |
| Skender Indicators | 71,277 μs | 50.8 MB | 224x slower |
See Benchmarks for full details and methodology.
Documentation
- Architecture: Learn about SoA layout, SIMD, and design philosophy.
- Indicators: Full catalog of available indicators and their mathematical families.
- Benchmarks: Detailed performance evidence and test methodology.
- Usage Guides: Detailed patterns for Span, Streaming, Batch, and Eventing modes.
- Integration: Setup guides for Quantower, NinjaTrader, and QuantConnect.
- Glossary: Definitions of core QuanTAlib concepts, types, and terminology.
Languages
C#
97.7%
Python
2.1%