pandas-ta for Trading
A feature-rich technical analysis library that extends pandas DataFrames with 130+ indicators, candlestick patterns, and performance metrics. The go-to library for efficient indicator calculations.
Installation
Install pandas-ta with pip. It requires pandas and numpy which will be installed automatically.
Available Indicators
Overlap
SMA, EMA, WMA, DEMA, TEMA, VWAP, Bollinger Bands, Keltner Channels
Momentum
RSI, MACD, Stochastic, CCI, Williams %R, ROC, Ultimate Oscillator
Trend
ADX, Aroon, PSAR, Supertrend, Ichimoku, Pivot Points
Volatility
ATR, Bollinger Width, Keltner Width, Donchian Channels
Volume
OBV, CMF, MFI, VWAP, AD, Force Index
Candles
Doji, Hammer, Engulfing, Morning Star, Evening Star, Harami
Key Features
130+ Indicators
Comprehensive library covering momentum, trend, volatility, volume, and overlap indicators.
Native pandas Integration
Works directly with pandas DataFrames using df.ta syntax for seamless workflow.
Strategy Builder
Create custom indicator strategies and apply multiple indicators at once.
Performance Metrics
Built-in functions for returns, drawdown, and other trading performance analytics.
Code Examples
Add Multiple Indicators at Once
Apply common indicators with a single line
Create Custom Indicator Strategy
Define your own indicator combinations
Momentum Indicators Suite
RSI, MACD, Stochastic, and more
Trend & Volatility Indicators
ADX, ATR, Bollinger Bands, and more
Generate Trading Signals
Combine indicators for entry/exit signals
Volume Indicators
OBV, CMF, MFI, and volume analysis
Candlestick Pattern Recognition
Detect candlestick patterns automatically
Performance Metrics
Calculate trading performance statistics
Common Use Cases
Best Practices & Common Pitfalls
Use Strategies for Bulk Indicators
Create ta.Strategy() objects to apply multiple indicators efficiently instead of calling each separately.
Handle Column Names
pandas_ta auto-generates column names. Use df.columns to verify names before accessing (e.g., MACD_12_26_9).
Combine with pandas
Leverage pandas filtering and groupby with pandas_ta indicators for powerful analysis.
Check for NaN Values
Early rows will have NaN for indicators with lookback periods. Always handle these before backtesting.
Verify Indicator Parameters
Different sources may define indicators differently. Verify parameters match your expectations.
Candlestick Pattern Returns
Pattern functions return 0, 100, or -100 (bullish/bearish), not boolean. Handle accordingly.
Additional Resources
Official Documentation
Related Libraries
- TA-Lib - Alternative indicator library
- finta - Financial indicator library
- tulipy - Tulip Indicators wrapper
Next Steps
Now that you can calculate indicators, learn to backtest strategies and connect to live trading: