polars_ta_lib
TA-Lib indicators as Polars expression plugins.
- 237 indicators, covering all of TA-Lib 0.8.3.
- Pure Rust backend: the official
ta-libport. No C toolchain. - One generic Polars expression, driven by TA-Lib's own metadata.
- Top-level Python functions with conventional column defaults.
- Strict input contract and Polars-native null output.
Install
# from PyPI
pip install polars_ta_lib_extension
# from source
uv venv
uv pip install maturin "polars>=2.1,<3"
uv run maturin develop --uv
Requires Python 3.11+ and Polars 2.1+.
PyPI distribution is polars_ta_lib_extension; the Python import remains
polars_ta_lib.
Quick start
import polars as pl
import polars_ta_lib as pta
df = pl.DataFrame(
{
"open": [1.0, 2.0, 3.0, 4.0, 5.0],
"high": [2.0, 3.0, 4.0, 5.0, 6.0],
"low": [0.5, 1.5, 2.5, 3.5, 4.5],
"close": [1.0, 2.0, 3.0, 4.0, 5.0],
"volume": [10.0, 20.0, 30.0, 40.0, 50.0],
}
)
out = df.with_columns(
pta.sma(time_period=3).alias("sma3"),
pta.atr(time_period=3).alias("atr3"),
pta.macd().struct.field("macd_signal").alias("macd_signal"),
pta.cdlengulfing().alias("engulfing"),
)
Semantics
- Single-series indicators default to
close; price components default to the column of the same name; multiple real inputs are required. - Inputs must be dense and finite. Null, NaN, or ±Inf raises a
ComputeErrornaming the column and position. - Rows before an indicator's lookback are Polars null, including integer outputs.
0is never a missing sentinel. - Multi-output functions return a
Struct.