Skip to main content

Polars Extension for Ta-Lib

Version 0.2.1 bundles TA-Lib 0.8.1: all 201 batch indicators, including SuperTrend, VWAP, HMA, KDJ and Heikin-Ashi. Python 3.10+; Polars 1.20+ and 2.x. Binary wheels include the C library.

Native AI plugin installation

The repository supports the same native marketplace/install flow as Shioaji:

# Claude Code
claude plugin marketplace add Yvictor/polars_ta_extension
claude plugin install polars-talib@polars-ta-extension

# Codex
codex plugin marketplace add Yvictor/polars_ta_extension
codex plugin add polars-talib@polars-ta-extension

See skill installation for invocation, updates, local checkouts, standalone installation, and Cursor support. The plugin supplies coding guidance; install the Python library separately.

Getting Started

pip install 'polars-talib==0.2.1'
# or, in a uv project
uv add 'polars-talib==0.2.1'

and

import polars
import polars_talib as plta

Usage

single symbol usage

df.with_columns(
    pl.col("close").ta.ema(5).alias("ema5"),
    pl.col("close").ta.macd(12, 26, 9).struct.field("macd"),
    pl.col("close").ta.macd(12, 26, 9).struct.field("macdsignal"),
    pl.col("open").ta.cdl2crows(pl.col("high"), pl.col("low"), pl.col("close")).alias("cdl2crows"),
    pl.col("close").ta.wclprice("high", "low").alias("wclprice"),
)

typed namespace access

plta.col(...) returns the same .ta namespace with a static return type, so editors and type checkers resolve every indicator method:

df.with_columns(
    plta.col("close").ema(5).alias("ema5"),
    plta.col(pl.col("close") * 2).rsi(14).alias("rsi_doubled"),
)

multiple symbol usage using over syntax

Sort by symbol and timestamp before computing history-dependent indicators.

df.with_columns(
    pl.col("close").ta.ema(5).over("symbol").alias("ema5"),
    pl.col("close").ta.macd(12, 26, 9).over("symbol").struct.field("macd"),
    pl.col("close").ta.macd(12, 26, 9).over("symbol").struct.field("macdsignal"),
    pl.col("open").ta.cdl2crows(
        pl.col("high"), pl.col("low"), pl.col("close")
    ).over("symbol").alias("cdl2crows"),
    pl.col("close").ta.wclprice("high", "low").over("symbol").alias("wclprice"),
)

missing values

A Polars null marks a missing observation. Leading nulls are skipped as warm-up. After that, every output row that can depend on a null input is null: to the end of the partition for recursive indicators such as RSI, EMA, MACD or OBV, and for the indicator's lookback window for window-bounded ones such as MAX, WILLR or the math operators. A null never turns into a plausible number, and under .over("symbol") it only affects its own symbol. NaN and infinity are ordinary float values and are passed to TA-Lib unchanged, so its results for them are undefined; use pl.col("close").fill_nan(None) when NaN means missing. To restart an indicator after each gap instead, or to skip gaps:

# restart after every gap, per symbol
gap = pl.col("close").is_null().cum_sum()
df = df.with_columns(pl.col("close").ta.rsi(14).over("symbol", gap).alias("rsi_restart"))

# compute over observed rows only (e.g. market-closed days), then join back
observed = df.filter(pl.col("close").is_not_null()).with_columns(
    pl.col("close").ta.rsi(14).over("symbol").alias("rsi_observed")
)
df = df.join(observed.select("symbol", "date", "rsi_observed"), on=["symbol", "date"], how="left")

usage just like talib.abstract with more flexible

df.with_columns(
    plta.ht_dcperiod(),
    plta.ht_dcperiod(pl.col("close")),
    plta.aroon(),
    plta.aroon(pl.col("high"), pl.col("low"), timeperiod=10),
    plta.wclprice(),
    plta.wclprice(
        pl.col("high"), pl.col("low"), pl.col("close"), 
        timeperiod=10
    ),
)

Performance

See the 0.2.0 release benchmark for a controlled comparison against 0.1.6, raw samples and a reproducible script. The notebook comparison below is historical and measures a different workload.

Polars with polars_talib

%%timeit
df = p.with_columns(
    plta.sma(timeperiod=5).over("Symbol").alias("sma5"),
    plta.macd(fastperiod=10, slowperiod=20, signalperiod=5).over("Symbol").alias("macd"),
    plta.stoch(pl.col("high"), pl.col("low"), pl.col("close"), fastk_period=14, slowk_period=7, slowd_period=7).over("Symbol").alias("stoch"),
    plta.wclprice().over("Symbol").alias("wclprice"),
).with_columns(
    pl.col("macd").struct.field("macd"),
    pl.col("macd").struct.field("macdsignal"),
    pl.col("macd").struct.field("macdhist"),
    pl.col("stoch").struct.field("slowk"),
    pl.col("stoch").struct.field("slowd"),
).select(
    pl.exclude("stoch")
).filter(
    pl.col("Symbol") == "AAPL"
).collect()

135 ms ± 5.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

Pandas with talib

%%timeit
df["sma5"] = df.groupby("Ticker")["close"].transform(lambda x: ta.SMA(x, timeperiod=5))
df["macd"] = df.groupby("Ticker")["close"].transform(lambda x: ta.MACD(x, fastperiod=10, slowperiod=20, signalperiod=5)[0])
df["macdsignal"] = df.groupby("Ticker")["close"].transform(lambda x: ta.MACD(x, fastperiod=10, slowperiod=20, signalperiod=5)[1])
df["macdhist"] = df.groupby("Ticker")["close"].transform(lambda x: ta.MACD(x, fastperiod=10, slowperiod=20, signalperiod=5)[2])
df["slowk"] = df.groupby("Ticker").apply(lambda x: ta.STOCH(x, fastk_period=14, slowk_period=7, slowd_period=7)).droplevel(0)["slowk"] 
df["slowd"] = df.groupby("Ticker").apply(lambda x: ta.STOCH(x, fastk_period=14, slowk_period=7, slowd_period=7)).droplevel(0)["slowd"]
df["wclprice"] = df.groupby("Ticker").apply(lambda x: ta.WCLPRICE(x)).droplevel(0)
df.loc["AAPL"]

19.2 s ± 367 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

That historical notebook measured about 150x for this workload; see basic.ipynb

Supported Indicators and Functions

import polars_talib as plta

# list of functions
plta.get_functions()

# dict of functions by group
plta.get_function_groups()

The complete 201-indicator catalog includes every function in the pinned upstream release. New examples:

df.with_columns(
    plta.supertrend().alias("supertrend"),
    plta.vwap().alias("vwap"),
    pl.col("close").ta.hma(timeperiod=20).alias("hma"),
    plta.kdj().alias("kdj"),
)

Multi-output indicators return Struct columns. For example, plta.supertrend().struct.field("trend") returns the Int32 trend flag.

Metadata

Release files for polars-talib 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polars-talib 0.2.1
File Size Uploaded Provenance Actions
polars_talib-0.2.1.tar.gz 2.8 MB Without provenance Details for polars_talib-0.2.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for polars-talib 0.2.1
File Actions
polars_talib-0.2.1-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for polars_talib-0.2.1-cp310-abi3-win_arm64.whl
polars_talib-0.2.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for polars_talib-0.2.1-cp310-abi3-win_amd64.whl
polars_talib-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for polars_talib-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl
polars_talib-0.2.1-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for polars_talib-0.2.1-cp310-abi3-musllinux_1_2_aarch64.whl
polars_talib-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for polars_talib-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl
polars_talib-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for polars_talib-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl
polars_talib-0.2.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for polars_talib-0.2.1-cp310-abi3-macosx_11_0_arm64.whl
polars_talib-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for polars_talib-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 39.3 MB

Release files / polars_talib-0.2.1.tar.gz

Download URL polars_talib-0.2.1.tar.gz
Size 2.8 MB
Tags Source
SHA-256 checksum
How to use checksums
349b0d1a4fee4dc177a5a34263ab30d72f3245e0d8aadf70302616c746a4848c
BLAKE2b-256 checksum
How to use checksums
8347b9feaf64458c26ab6015e4985b7c0eb03d790d0e757a66337c3e460e5542
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / polars_talib-0.2.1-cp310-abi3-win_arm64.whl

Download URL polars_talib-0.2.1-cp310-abi3-win_arm64.whl
Size 3.7 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
84022d59c45af4624f089c7d974796c773cf61f8cad367e2f7d8e933e2a81c9d
BLAKE2b-256 checksum
How to use checksums
0166bea7acf111d26b4a995e8823bbd864e7e997220f86aa80b2bae0077ecd68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / polars_talib-0.2.1-cp310-abi3-win_amd64.whl

Download URL polars_talib-0.2.1-cp310-abi3-win_amd64.whl
Size 4.2 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ad1d35237b31615dc1d6a5f048d1cbdaa2cbb3305f97be93652274c68822d566
BLAKE2b-256 checksum
How to use checksums
6184bbb9b2cd3f6568fd1938624f79a05f59bee1c5a076390381fb9f66c67789
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / polars_talib-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL polars_talib-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl
Size 5.2 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
d9a0662b865ff6a3f4cba492725bc13f94dd88b12c46f420810ce70333592992
BLAKE2b-256 checksum
How to use checksums
1114d03fa7767972008b898bc484dd29261720af18dd4a185111a82c65e4e2b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / polars_talib-0.2.1-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL polars_talib-0.2.1-cp310-abi3-musllinux_1_2_aarch64.whl
Size 5.0 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
6b1e8d79695cfb18179b80dd3bb7ca3d4c23a036ccfd6e030b9cafa75ec41e67
BLAKE2b-256 checksum
How to use checksums
67145fe731e1a053587cc50f241637ba135f6f07e294a7d9bb4e510007dcaac4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / polars_talib-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL polars_talib-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl
Size 5.1 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
ea155b351bce39a40ea6af9a850cd1c4ea831996c2b6876c336faf613a9c36ec
BLAKE2b-256 checksum
How to use checksums
417142ad3064d880cf3df8dec5ecdaf800f33d2d26fc246f9663b3b542235821
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / polars_talib-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL polars_talib-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl
Size 4.8 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
eba448f015f6c9f99d6d5ed7b6a7c6442c729f8f2b47a5b1ba5f8856bfea6962
BLAKE2b-256 checksum
How to use checksums
5aad942454bd739be0b2b9fc47142171ce39a8e8443a16cc4f49ee5cb816d7c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / polars_talib-0.2.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL polars_talib-0.2.1-cp310-abi3-macosx_11_0_arm64.whl
Size 4.1 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a475f0b40a4d9fbd8f917b0ca9d84348ec8a6280119c253ddfe4d4937693014d
BLAKE2b-256 checksum
How to use checksums
c78ec0e0266e2462f15e02172ca62ac36a4c47e09119add43a127fc8f3eee69a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / polars_talib-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL polars_talib-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 4.4 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
7ff5400277ce77d09680cc433f1421fb7de3f6cd3475b4ca682477568d3d04dd
BLAKE2b-256 checksum
How to use checksums
46f4844a9dc510b9072045d8ece135ef8489f738a2ff2e69880a8ab3774ac44a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Security for polars-talib 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page