or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

abstract-streaming.mdcycle-indicators.mdindex.mdmath-operations.mdmomentum-indicators.mdoverlap-studies.mdpattern-recognition.mdprice-transform.mdstatistical-functions.mdvolatility-indicators.mdvolume-indicators.md
tile.json

tessl/pypi-ta-lib

Python wrapper for TA-LIB providing 175+ technical analysis indicators for financial market data

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/ta-lib@0.6.x

To install, run

npx @tessl/cli install tessl/pypi-ta-lib@0.6.0

index.mddocs/

TA-Lib

TA-Lib is a comprehensive Python wrapper for the TA-LIB C library, providing 175+ technical analysis indicators for financial market data analysis. This library is widely used by trading software developers requiring professional-grade technical analysis of financial data, offering efficient computations that are 2-4 times faster than alternative implementations.

Package Information

  • Package Name: TA-Lib
  • Language: Python
  • Installation: pip install TA-Lib
  • Dependencies: numpy (required), pandas (optional), polars (optional)

Core Imports

import talib

For abstract interface:

import talib.abstract
from talib.abstract import Function

For streaming API:

import talib.stream
from talib import stream

Basic Usage

import talib
import numpy as np

# Create sample OHLC data
close = np.random.random(100)
high = np.random.random(100)
low = np.random.random(100)
open_prices = np.random.random(100)

# Calculate simple moving average
sma = talib.SMA(close, timeperiod=30)

# Calculate RSI
rsi = talib.RSI(close, timeperiod=14)

# Calculate Bollinger Bands
upper, middle, lower = talib.BBANDS(close, timeperiod=20, nbdevup=2, nbdevdn=2)

# Calculate MACD
macd, macdsignal, macdhist = talib.MACD(close, fastperiod=12, slowperiod=26, signalperiod=9)

Architecture

TA-Lib provides three distinct APIs for different use cases:

  • Function API: Direct function calls for batch processing of arrays
  • Abstract API: Flexible interface supporting DataFrames and named inputs
  • Streaming API: Real-time processing returning only the latest value

All functions support numpy arrays as primary input, with automatic conversion from pandas Series and polars Series. The library handles initialization and cleanup automatically, with robust NaN propagation and lookback period management.

Capabilities

Overlap Studies

Trend-following indicators and moving averages that smooth price data to identify trends and provide support/resistance levels. Includes moving averages, Bollinger Bands, and trend line indicators.

def SMA(real, timeperiod=30): ...
def EMA(real, timeperiod=30): ...
def BBANDS(real, timeperiod=5, nbdevup=2, nbdevdn=2, matype=MA_Type.SMA): ...
def KAMA(real, timeperiod=30): ...
def SAR(high, low, acceleration=0, maximum=0): ...

Overlap Studies

Momentum Indicators

Oscillators and momentum-based indicators that measure the rate of price change and help identify overbought/oversold conditions and potential reversal points.

def RSI(real, timeperiod=14): ...
def MACD(real, fastperiod=12, slowperiod=26, signalperiod=9): ...
def STOCH(high, low, close, fastk_period=5, slowk_period=3, slowk_matype=MA_Type.SMA, slowd_period=3, slowd_matype=MA_Type.SMA): ...
def ADX(high, low, close, timeperiod=14): ...
def CCI(high, low, close, timeperiod=14): ...
def IMI(open, close, timeperiod=14): ...

Momentum Indicators

Volume Indicators

Indicators that analyze the relationship between price movements and trading volume to confirm trends and identify potential reversals.

def AD(high, low, close, volume): ...
def OBV(close, volume): ...
def ADOSC(high, low, close, volume, fastperiod=3, slowperiod=10): ...

Volume Indicators

Volatility Indicators

Measures of price volatility and range to assess market conditions and potential breakout scenarios.

def ATR(high, low, close, timeperiod=14): ...
def NATR(high, low, close, timeperiod=14): ...
def TRANGE(high, low, close): ...
def ACCBANDS(high, low, close, timeperiod=20): ...

Volatility Indicators

Pattern Recognition

Candlestick pattern recognition functions that identify traditional Japanese candlestick patterns for technical analysis and trading signals.

def CDLDOJI(open, high, low, close): ...
def CDLHAMMER(open, high, low, close): ...
def CDLENGULFING(open, high, low, close): ...
def CDLMORNINGSTAR(open, high, low, close, penetration=0): ...
def CDL3BLACKCROWS(open, high, low, close): ...

Pattern Recognition

Price Transform

Functions that transform OHLC data into standardized price representations for further analysis.

def AVGPRICE(open, high, low, close): ...
def MEDPRICE(high, low): ...
def TYPPRICE(high, low, close): ...
def WCLPRICE(high, low, close): ...

Price Transform

Cycle Indicators

Hilbert Transform-based indicators for cycle analysis and trend vs cycle mode determination.

def HT_DCPERIOD(real): ...
def HT_SINE(real): ...
def HT_TRENDMODE(real): ...
def HT_PHASOR(real): ...
def HT_DCPHASE(real): ...

Cycle Indicators

Statistical Functions

Statistical analysis functions for correlation, regression, and statistical measures of price data.

def BETA(real0, real1, timeperiod=5): ...
def CORREL(real0, real1, timeperiod=30): ...
def LINEARREG(real, timeperiod=14): ...
def STDDEV(real, timeperiod=5, nbdev=1): ...
def VAR(real, timeperiod=5, nbdev=1): ...
def AVGDEV(real, timeperiod=14): ...

Statistical Functions

Math Operations

Mathematical transformation and operator functions for array manipulation and calculations.

def ADD(real0, real1): ...
def SUM(real, timeperiod=30): ...
def MAX(real, timeperiod=30): ...
def MIN(real, timeperiod=30): ...
def SQRT(real): ...
def SIN(real): ...
def LOG10(real): ...

Math Operations

Abstract and Streaming APIs

Alternative interfaces providing flexible DataFrame support and real-time processing capabilities.

# Abstract API
class Function:
    def __init__(self, function_name, *args, **kwargs): ...

# Streaming functions return single values
def stream_SMA(real, timeperiod=30): ...  # Returns latest SMA value only

Abstract and Streaming APIs

Common Types

from enum import Enum
from typing import Tuple
import numpy as np

class MA_Type(Enum):
    """Moving Average Types"""
    SMA = 0    # Simple Moving Average
    EMA = 1    # Exponential Moving Average  
    WMA = 2    # Weighted Moving Average
    DEMA = 3   # Double Exponential Moving Average
    TEMA = 4   # Triple Exponential Moving Average
    TRIMA = 5  # Triangular Moving Average
    KAMA = 6   # Kaufman Adaptive Moving Average
    MAMA = 7   # MESA Adaptive Moving Average
    T3 = 8     # Triple Exponential Moving Average (T3)

# Type aliases
NDArray = np.ndarray
PriceArray = np.ndarray[np.float64]
IntArray = np.ndarray[np.int32]

Utility Functions

def get_functions() -> list[str]:
    """Returns a list of all supported TA-Lib function names"""

def get_function_groups() -> dict[str, list[str]]:
    """Returns functions organized by group (e.g., 'Overlap Studies', 'Momentum Indicators')"""

def set_unstable_period(func_id: int, period: int) -> None:
    """Set unstable period for a function"""

def get_unstable_period(func_id: int) -> int:
    """Get unstable period for a function"""

def set_compatibility(value: int) -> None:
    """Set compatibility mode"""

def get_compatibility() -> int:
    """Get compatibility mode"""