Registry / data / ta-lib

ta-lib

JSON →
library0.7.1pypypi✓ verified 21d ago

TA-Lib is a Python wrapper for the widely-used TA-Lib C library, designed for technical analysis of financial market data. It provides over 150 indicators and candlestick pattern recognition functions, optimized for performance using Cython and NumPy. The current Python wrapper version is 0.6.8, and it maintains compatibility branches for different NumPy and underlying C TA-Lib versions.

pip install TA-Lib
INSTALL
IMPORT
SIG · TA-LIB
T
ta-lib
datapythonv0.7.1
Install
4.0s avg
Import
247ms
Disk
100MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.250s · 100MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.0s · import 0.244s · 96MB
100MB installed
● package 100MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

talib
import talib
MA_Type
from talib import MA_Type

This quickstart demonstrates calculating common technical indicators like Simple Moving Average (SMA) and Relative Strength Index (RSI) using `ta-lib` with both NumPy arrays and Pandas Series as input. Note that `ta-lib` functions return `NaN` for the initial 'lookback' periods where insufficient data is available to compute the indicator.

import numpy as np import talib import pandas as pd # Simulate some financial close prices np.random.seed(42) close_prices = np.random.rand(100) * 100 + 50 # Calculate Simple Moving Average (SMA) sma = talib.SMA(close_prices, timeperiod=10) print("SMA (first 15 values):", sma[:15]) # Calculate Relative Strength Index (RSI) rsi = talib.RSI(close_prices, timeperiod=14) print("RSI (first 15 values):", rsi[:15]) # TA-Lib functions return NaN for initial 'lookback' periods # Example with Pandas Series input df = pd.DataFrame({'Close': close_prices}) df['SMA'] = talib.SMA(df['Close'], timeperiod=10) print("\nDataFrame with SMA (first 15 rows):\n", df.head(15))
Debug
Known issues
gotchaThe Python `ta-lib` package is a wrapper for an *external* C library. You must install the TA-Lib C library on your system *before* installing the Python package. Failure to do so is the most common cause of installation errors.
fix
Follow the platform-specific instructions for installing the TA-Lib C library (e.g., Homebrew for macOS, build from source for Linux, Visual Studio compilation for Windows) before running `pip install TA-Lib`.
affects: All versions
breakingVersion compatibility between the Python `ta-lib` wrapper, NumPy, and the underlying TA-Lib C library is crucial. Mismatches can lead to build failures or runtime errors. Specifically, `ta-lib-python 0.6.x` supports TA-Lib C library `0.6.x` and NumPy `2`.
fix
Check the `ta-lib-python` GitHub README or PyPI page for exact compatibility matrix. Consider using `conda` (`conda install -c conda-forge ta-lib libta-lib`) as it often handles these dependencies more smoothly.
affects: All versions, especially when upgrading Python, NumPy, or TA-Lib C library.
breakingThe underlying TA-Lib C library changed its linker name from `-lta_lib` to `-lta-lib` in version 0.6.1. If you compile the C library manually, ensure it aligns with the Python wrapper version you are using, or you may face linkage errors.
fix
Use a compatible version of the Python `ta-lib` wrapper (e.g., `0.6.x` for the C library `0.6.x`) or ensure your C library build and linking paths are correctly configured for the Python wrapper's expectations.
affects: TA-Lib C library 0.6.1+ with older Python wrappers.
gotchaTA-Lib functions calculate indicators over a 'lookback' period. For the initial data points within this period, the indicator cannot be computed and the functions will return `NaN` (Not a Number). Ensure your data processing handles these `NaN` values appropriately.
fix
Always check the output arrays for `NaN` values, especially at the beginning. Use methods like `dropna()` from Pandas if working with DataFrames, or slice your NumPy arrays to exclude the initial `NaN`s.
affects: All versions
gotchaOn Windows, direct `pip install ta-lib` often fails if the C++ build tools are not correctly set up or if the 32-bit C library is installed with a 64-bit Python environment (or vice-versa).
fix
Ensure you have the 'Desktop development with C++' workload installed in Visual Studio. For easier installation, many users resort to downloading pre-compiled `.whl` files for their specific Python version and architecture from unofficial sources (e.g., Gohlke's Python wheels, though availability varies) or using Conda.
affects: All versions on Windows
Errors
Common errors & fixes
Microsoft Visual C++ 14.0 is required
Installing `ta-lib` on Windows requires the Microsoft Visual C++ build tools to compile the underlying Cython extensions.
fix
Download and install "Microsoft C++ Build Tools" (specifically the "Desktop development with C++" workload) from the Visual Studio website, then retry `pip install ta-lib`.
fatal error C1083: Cannot open include file: 'ta-lib/ta_libc.h': No such file or directory
The Python `ta-lib` wrapper requires the core C TA-Lib library to be installed and its header files (`ta_libc.h`) accessible during the Python package installation.
fix
Download and install the C TA-Lib library (e.g., `ta-lib-0.4.0-msvc.zip` for Windows or compile from source on Linux/macOS), then set `TA_INCLUDE_PATH` and `TA_LIBRARY_PATH` environment variables to point to the installed library directories before running `pip install ta-lib`.
AttributeError: 'NoneType' object has no attribute 'astype'
This error typically occurs when TA-Lib functions receive input data that is empty, contains `NaN` values, or is otherwise invalid, causing the underlying C function to return `None` which then fails when a Python method like `astype` is called on it.
fix
Ensure all input series (e.g., `open`, `high`, `low`, `close`) are clean pandas Series or NumPy arrays of float type, with no `NaN`s, and contain sufficient data points before passing them to `ta-lib` functions. Use `dropna()` or `fillna()` for data cleaning.
ValueError: input array is not C-contiguous
Some `ta-lib` functions, particularly when dealing with NumPy arrays created via specific slicing or views, expect the input data to be stored in C-contiguous memory layout.
fix
Explicitly make the input NumPy array or pandas Series values C-contiguous by calling `.copy(order='C')` before passing them to the `ta-lib` function. Example: `talib.SMA(data['close'].values.copy(order='C'))`.
Upgrade
Version history
0.7.1latest on PyPI · released Jul 16, 2026
Audit
Dependencies
numpyrequiredThe Python wrapper for TA-Lib is built with Cython and NumPy for efficient numerical operations and array handling.
TA-Lib (C Library)requiredThis Python package is a wrapper around the original TA-Lib C library, which must be installed separately on the system.
Agent activity
31 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources
ta-lib — pip install ta-lib · libregistry