Files
QuanTAlib/python/README.md
T

79 lines
2.6 KiB
Markdown
Raw Permalink Normal View History

# quantalib — Python NativeAOT Wrapper
2026-02-28 14:14:35 -08:00
High-performance Python wrapper for [QuanTAlib](https://github.com/mihakralj/quantalib), a .NET NativeAOT technical analysis library.
2026-02-28 14:14:35 -08:00
## Features
2026-02-28 14:14:35 -08:00
- **~391 indicators** across 15 categories: channels, core, cycles, dynamics, errors, filters, momentum, numerics, oscillators, reversals, statistics, trends (FIR & IIR), volatility, volume
- **Zero-copy FFI** — ctypes bridge to pre-compiled NativeAOT shared library
- **NumPy native** — all inputs/outputs are `float64` arrays
- **Optional pandas support** — pass `pd.Series` in, get `pd.Series` out with preserved index
- **pandas-ta compatible** — `quantalib._compat` provides alias mapping for drop-in migration
2026-02-28 14:14:35 -08:00
## Installation
2026-02-28 14:14:35 -08:00
```bash
pip install quantalib
```
2026-02-28 14:14:35 -08:00
> **Note:** The NativeAOT shared library (`quantalib_native.dll` / `.so` / `.dylib`) must be present in `quantalib/native/<platform>/`. Pre-built binaries are included in wheel distributions.
2026-02-28 14:14:35 -08:00
## Quick Start
2026-02-28 14:14:35 -08:00
```python
import numpy as np
import quantalib as qtl
2026-02-28 14:14:35 -08:00
close = np.random.randn(200).cumsum() + 100
# Simple Moving Average
sma = qtl.sma(close, length=20)
# Bollinger Bands (multi-output → tuple or DataFrame)
upper, mid, lower = qtl.bbands(close, length=20, std=2.0)
# With pandas
import pandas as pd
s = pd.Series(close, name="close")
rsi = qtl.rsi(s, length=14) # returns pd.Series with preserved index
```
## Categories
| Category | Module | Examples |
|----------|--------|----------|
| Channels | `channels` | bbands, kchannel, dchannel, aberr |
| Core | `core` | ha, midpoint, avgprice, typprice |
| Cycles | `cycles` | ht_dcperiod, ht_sine, cg, dsp |
| Dynamics | `dynamics` | adx, aroon, ichimoku, supertrend |
| Errors | `errors` | mse, rmse, mae, mape, huber |
| Filters | `filters` | kalman, sgf, hp, butter2, wavelet |
| Momentum | `momentum` | rsi, macd, roc, mom, tsi |
| Numerics | `numerics` | fft, normalize, sigmoid, slope |
| Oscillators | `oscillators` | stoch, cci, fisher, qqe, willr |
| Reversals | `reversals` | psar, pivot, fractals, swings |
| Statistics | `statistics` | zscore, correlation, entropy, linreg |
| Trends FIR | `trends_fir` | sma, wma, hma, alma, trima |
| Trends IIR | `trends_iir` | ema, dema, tema, kama, jma |
| Volatility | `volatility` | atr, bbw, stddev, hv, tr |
| Volume | `volume` | obv, vwma, mfi, cmf, adl |
## Local Development
```bash
cd python/
python -m venv .venv && .venv/Scripts/activate # or source .venv/bin/activate
pip install -e ".[dev]"
pytest
```
### Building the native library
```bash
dotnet publish python.csproj -c Release
```
## License
[MIT](../LICENSE)