Quickstart

Welcome to Pandas TA Classic! This guide will help you get started quickly with calculating technical indicators for your financial data analysis.

Table of Contents

Installation

See the Installation page for full installation instructions, optional dependencies (TA-Lib, tulipy, yfinance, numba), and development setup.

Your First Indicators

Method 1: Standard Approach (Explicit)

Perfect for when you want full control:

import pandas as pd
import pandas_ta_classic as ta

# Create sample data
df = pd.DataFrame({
 'open': [100, 101, 102, 103, 104],
 'high': [105, 106, 107, 108, 109],
 'low': [99, 100, 101, 102, 103],
 'close': [104, 105, 106, 107, 108],
 'volume': [1000, 1100, 1200, 1300, 1400]
})

# Calculate a Simple Moving Average
sma_20 = ta.sma(df['close'], length=20)
print(sma_20)

# Calculate RSI (Relative Strength Index)
rsi_14 = ta.rsi(df['close'], length=14)
print(rsi_14)

# Calculate MACD
macd = ta.macd(df['close'])
print(macd) # Returns a DataFrame with MACD, signal, and histogram

Method 2: DataFrame Extension (Convenient)

The easiest way for most users:

import pandas as pd
import pandas_ta_classic as ta

# Load your data
df = pd.read_csv('your_data.csv')

# Calculate and append indicators directly
df.ta.sma(length=20, append=True) # Adds SMA_20 column
df.ta.rsi(length=14, append=True) # Adds RSI_14 column
df.ta.macd(append=True) # Adds MACD columns
df.ta.bbands(length=20, append=True) # Adds Bollinger Bands

# View your DataFrame with new indicators
print(df.tail())

Method 3: Strategy System (Powerful)

Run multiple indicators at once:

import pandas as pd
import pandas_ta_classic as ta

df = pd.read_csv('your_data.csv')

# Use a built-in strategy (the Strategy object, not its name)
df.ta.strategy(ta.CommonStrategy)

# Or create your own custom strategy
my_strategy = ta.Strategy(
 name="MyStrategy",
 ta=[
 {"kind": "sma", "length": 20},
 {"kind": "sma", "length": 50},
 {"kind": "rsi", "length": 14},
 {"kind": "macd", "fast": 12, "slow": 26, "signal": 9},
 {"kind": "bbands", "length": 20},
 ]
)

# Run your strategy
df.ta.strategy(my_strategy)
print(df.columns) # See all new indicator columns

Method 4: Fluent Chaining (Expressive)

Chain multiple indicators in a single readable expression (v0.6+):

import pandas as pd
import pandas_ta_classic as ta

df = pd.read_csv('your_data.csv')

# Chain multiple indicators in one line
df.ta.chain().sma(20).ta.rsi(14).ta.macd().ta.bbands(20)

# With prefixes for clarity
df.ta.chain().sma(20, prefix="FAST").ta.sma(50, prefix="SLOW")

# Rename output columns inline
df.ta.chain().bbands(20, col_names=("LOWER", "MID", "UPPER", "BW", "PCT"))

# Exit chain mode mid-expression
df.ta.chain().sma(20).ta.unchain().ta.rsi(14)  # RSI returned as Series

How it works:

  • chain() activates chain mode — every indicator auto-appends to the DataFrame.

  • Each indicator returns the DataFrame (which has .ta), so you can keep chaining.

  • unchain() exits chain mode, returning the DataFrame for normal use.

  • All kwargs like prefix, suffix, and col_names work as usual.

  • Chain mode applies only to the DataFrame you called chain() on: df.copy() and slices such as df.iloc[-100:] are not chained.

Working with Real Data

From CSV Files

import pandas as pd
import pandas_ta_classic as ta

# Load CSV with OHLCV data
df = pd.read_csv('stock_data.csv', parse_dates=['date'], index_col='date')

# Ensure column names are lowercase (optional but recommended)
df.columns = [col.lower() for col in df.columns]

# Calculate indicators
df.ta.sma(length=20, append=True)
df.ta.atr(length=14, append=True) # Average True Range

Common Use Cases

1. Trend Following

Identify the trend direction:

# Moving averages for trend
df.ta.sma(length=20, append=True) # Short-term
df.ta.sma(length=50, append=True) # Medium-term 
df.ta.sma(length=200, append=True) # Long-term

# Trend indicator
df.ta.adx(length=14, append=True) # Average Directional Index

2. Momentum Trading

Identify overbought/oversold conditions:

# RSI for momentum
df.ta.rsi(length=14, append=True)

# Stochastic Oscillator
df.ta.stoch(append=True)

# Williams %R
df.ta.willr(length=14, append=True)

3. Volatility Analysis

Measure market volatility:

# Bollinger Bands
df.ta.bbands(length=20, std=2, append=True)

# Average True Range
df.ta.atr(length=14, append=True)

# Keltner Channels
df.ta.kc(length=20, append=True)

4. Volume Analysis

Analyze trading volume:

# On-Balance Volume
df.ta.obv(append=True)

# Volume Weighted Average Price
df.ta.vwap(append=True)

# Accumulation/Distribution
df.ta.ad(append=True)

5. Support & Resistance

Find key price levels using the Parabolic SAR and Donchian Channel:

# Parabolic Stop and Reverse
df.ta.psar(append=True)

# Donchian Channel (high/low price channels)
df.ta.donchian(lower_length=20, upper_length=20, append=True)

Understanding Indicator Output

Single Column Output

Some indicators return a single Series:

# Returns a Series
sma = df.ta.sma(length=20)
print(type(sma)) # pandas.Series
print(sma.name) # 'SMA_20'

Multiple Column Output

Others return a DataFrame with multiple columns:

# Returns a DataFrame
bbands = df.ta.bbands(length=20)
print(type(bbands)) # pandas.DataFrame
print(bbands.columns) # ['BBL_20_2.0', 'BBM_20_2.0', 'BBU_20_2.0', 'BBB_20_2.0', 'BBP_20_2.0']

# Access individual bands
lower_band = bbands['BBL_20_2.0']
middle_band = bbands['BBM_20_2.0']
upper_band = bbands['BBU_20_2.0']

Custom Column Names

Use suffixes for clarity:

# Add custom suffix
df.ta.sma(length=20, suffix="Daily", append=True)
# Creates column: SMA_20_Daily

# Calculate on different prices
df.ta.ema(close=df['high'], length=20, suffix="High", append=True)
# Creates column: EMA_20_High

Exploring Available Indicators

List All Indicators

import pandas_ta_classic as ta

# See all indicator categories
print(ta.Category)

# List indicators by category
print(ta.Category["momentum"]) # All momentum indicators
print(ta.Category["overlap"]) # All overlap indicators
print(ta.Category["trend"]) # All trend indicators
print(ta.Category["volatility"]) # All volatility indicators
print(ta.Category["volume"]) # All volume indicators

Get Help on Indicators

# Get indicator documentation
help(ta.sma)
help(ta.macd)
help(ta.rsi)

# Or use Python's built-in
print(ta.sma.__doc__)

Performance Tips

1. Use append=True Carefully

# Good: Calculate once, append once
indicators = df.ta.sma(length=20)
df = pd.concat([df, indicators], axis=1)

# Better: Use append=True for convenience
df.ta.sma(length=20, append=True)

# Best: Use strategies for multiple indicators
df.ta.strategy(ta.CommonStrategy)

2. Group Indicators Into a Strategy

my_strategy = ta.Strategy(
 name="FastStrategy",
 ta=[
 {"kind": "sma", "length": 20},
 {"kind": "ema", "length": 20},
 {"kind": "rsi", "length": 14},
 {"kind": "macd"},
 ]
)
df.ta.strategy(my_strategy)

# Runs serially by default. On large frames (from roughly 100,000 rows)
# hand it worker processes; see the Strategies guide.
df.ta.strategy(my_strategy, cores=8)

3. Preprocess Data

# Ensure data types are correct
df['close'] = pd.to_numeric(df['close'], errors='coerce')
df['volume'] = pd.to_numeric(df['volume'], errors='coerce')

# Remove NaN values
df = df.dropna()

Troubleshooting

Issue: “KeyError: ‘close’”

Solution: Ensure your DataFrame has the required columns (open, high, low, close, volume):

# Check column names
print(df.columns)

# Rename columns if needed
df.columns = ['open', 'high', 'low', 'close', 'volume']

# Or specify columns explicitly
df.ta.sma(close=df['price'], length=20)

Issue: TypeError: ... expected a pandas Series

Cause: The input is not a pandas Series, for example a numpy array from .values:

TypeError: sma() expected a pandas Series but got ndarray. Pass a Series,
e.g. df['close'] rather than df['close'].values.

Version 0.8.32 returned None with a FutureWarning here; since 0.9.0 it raises.

Solution: Pass the Series itself:

ta.sma(df['close'], length=20)         # works
ta.sma(df['close'].values, length=20)  # TypeError

Issue: “All NaN values”

Solution: Check if you have enough data points:

# Most indicators need minimum data
print(len(df)) # Should be > indicator length

# Example: SMA(20) needs at least 20 data points
if len(df) >= 20:
 df.ta.sma(length=20, append=True)

Issue: “All NaN values” after resampling

Cause: A gap inside the series, rather than too little data. df.resample('D') on a feed that only trades on weekdays inserts a NaN row for every weekend, and many indicators cannot see past those rows. On a 300-row daily frame with weekend gaps, more than 80 of 224 indicators return all-NaN — among them sma, stoch, macd, linreg, willr and stdev — while ema, rma and atr still produce values.

Which side an indicator falls on depends on its internals: a rolling(length) window needs length consecutive non-NaN bars, an ewm recursion does not. So two indicators called with the same length can legitimately start at different bars on gapped data.

Candle patterns (cdl_pattern, cdl_doji, cdl_inside) are the exception: they skip NaN rows and report 0 on them, so on gapped data they give the same signals as on the dropna() frame.

Solution: Drop the empty periods before computing, not after:

# resample() emits one row per calendar period, gap or not
daily = df.resample('D').agg({'open': 'first', 'high': 'max',
                              'low': 'min', 'close': 'last'})

daily = daily.dropna()  # drop the empty periods first
daily.ta.sma(length=14, append=True)

dropna() returns a copy, so daily.dropna() on a line of its own does nothing — assign it back.

Issue: “Import Error: No module named ‘pandas_ta_classic’”

Solution: Verify installation:

pip list | grep pandas-ta-classic
# or
pip install --upgrade pandas-ta-classic

Issue: Want TA-Lib acceleration for core indicators

Solution: TA-Lib is optional and only used for supported core indicators (candlestick patterns are native). Install TA-Lib separately:

pip install "ta-lib>=0.6.8"

Binary wheels (v0.6.5+) bundle the C library — no separate TA-Lib C installation needed on any platform. Versions before 0.6.5 lack binary wheels and require manual C library setup.

Next Steps

Now that you’ve got the basics, explore more:

  1. Full Documentation - Complete API reference

  2. Tutorials - Step-by-step guides for common tasks

  3. Indicator Reference - 224 indicators plus 62 CDL patterns (284 unique total)

  4. Strategy Guide - Advanced strategy system

  5. Examples - Jupyter notebooks with real examples

Quick Reference Card

Task

Code

Install

pip install pandas-ta-classic

Import

import pandas_ta_classic as ta

Simple indicator

df.ta.sma(length=20, append=True)

Multiple indicators

df.ta.strategy(ta.CommonStrategy)

Custom strategy

ta.Strategy(name="My", ta=[...])

List categories

print(ta.Category)

Get help

help(ta.sma)

Fetch data

yf.download("AAPL") (via yfinance; pandas-ta-classic does not fetch data)

Need Help?

Happy Trading!