Technical Analysis Library in Python

0.11.0 · active · verified Sun Apr 12

The `ta` library (Technical Analysis Library in Python, also known as `python-ta`) is a Python library designed for feature engineering on financial time series datasets. It provides a comprehensive collection of over 150 technical indicators and candlestick pattern recognition functions, built entirely on the Pandas library. Version 0.11.0 is the current release, and the project maintains an active, albeit intermittent, release cadence with new features and bug fixes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to load a DataFrame with typical OHLCV (Open, High, Low, Close, Volume) data, clean potential NaN values, and then apply all available technical analysis features using `add_all_ta_features`. The resulting DataFrame will include numerous new columns corresponding to various indicators.

import pandas as pd
from ta import add_all_ta_features
from ta.utils import dropna

# Example DataFrame (replace with your actual data)
data = {
    'Open': [100, 102, 101, 105, 103, 106, 108, 107, 109, 110],
    'High': [103, 104, 105, 106, 107, 108, 110, 110, 112, 113],
    'Low': [98, 100, 99, 102, 100, 103, 105, 104, 106, 107],
    'Close': [102, 101, 104, 103, 106, 107, 109, 108, 111, 112],
    'Volume': [1000, 1200, 1100, 1500, 1300, 1400, 1600, 1550, 1700, 1800]
}
df = pd.DataFrame(data)

# Ensure data has required columns (Open, High, Low, Close, Volume)
# Clean NaN values (optional, but recommended if your data has them)
df_cleaned = dropna(df)

# Add all technical analysis features
df_features = add_all_ta_features(
    df_cleaned, 
    open="Open", high="High", low="Low", close="Close", volume="Volume"
)

print(df_features.head())

view raw JSON →