Technical Analysis Library in Python for financial time series datasets with 43 indicators across Volume, Volatility, Trend, Momentum, and Others categories
High-level wrapper functions that add multiple technical indicators to a DataFrame at once. These functions provide the most convenient way to perform comprehensive technical analysis by adding all indicators from specific categories or all categories simultaneously.
Adds all 43 technical analysis features from all categories (Volume, Volatility, Trend, Momentum, Others) to the DataFrame in a single operation.
def add_all_ta_features(df, open, high, low, close, volume, fillna=False, colprefix="", vectorized=False):
"""
Add all technical analysis features to dataframe.
Parameters:
- df (DataFrame): Base dataframe to add features to
- open (str): Column name for 'Open' prices
- high (str): Column name for 'High' prices
- low (str): Column name for 'Low' prices
- close (str): Column name for 'Close' prices
- volume (str): Column name for 'Volume' data
- fillna (bool): If True, fill NaN values with 0 (default: False)
- colprefix (str): Prefix to add to all new column names (default: "")
- vectorized (bool): If True, use only vectorized functions (default: False)
Returns:
DataFrame: Original DataFrame with all technical analysis features added
"""Adds all 9 volume-based technical indicators including Money Flow Index, On-Balance Volume, VWAP, and others.
def add_volume_ta(df, high, low, close, volume, fillna=False, colprefix="", vectorized=False):
"""
Add volume technical analysis features to dataframe.
Parameters:
- df (DataFrame): Base dataframe to add features to
- high (str): Column name for 'High' prices
- low (str): Column name for 'Low' prices
- close (str): Column name for 'Close' prices
- volume (str): Column name for 'Volume' data
- fillna (bool): If True, fill NaN values with 0 (default: False)
- colprefix (str): Prefix to add to all new column names (default: "")
- vectorized (bool): If True, use only vectorized functions (default: False)
Returns:
DataFrame: Original DataFrame with volume indicators added
"""Adds all 5 volatility-based technical indicators including Bollinger Bands, Average True Range, Keltner Channel, and others.
def add_volatility_ta(df, high, low, close, fillna=False, colprefix="", vectorized=False):
"""
Add volatility technical analysis features to dataframe.
Parameters:
- df (DataFrame): Base dataframe to add features to
- high (str): Column name for 'High' prices
- low (str): Column name for 'Low' prices
- close (str): Column name for 'Close' prices
- fillna (bool): If True, fill NaN values with 0 (default: False)
- colprefix (str): Prefix to add to all new column names (default: "")
- vectorized (bool): If True, use only vectorized functions (default: False)
Returns:
DataFrame: Original DataFrame with volatility indicators added
"""Adds all 20 trend-based technical indicators including MACD, Moving Averages, ADX, Ichimoku, and others.
def add_trend_ta(df, high, low, close, fillna=False, colprefix="", vectorized=False):
"""
Add trend technical analysis features to dataframe.
Parameters:
- df (DataFrame): Base dataframe to add features to
- high (str): Column name for 'High' prices
- low (str): Column name for 'Low' prices
- close (str): Column name for 'Close' prices
- fillna (bool): If True, fill NaN values with 0 (default: False)
- colprefix (str): Prefix to add to all new column names (default: "")
- vectorized (bool): If True, use only vectorized functions (default: False)
Returns:
DataFrame: Original DataFrame with trend indicators added
"""Adds all 11 momentum-based technical indicators including RSI, Stochastic Oscillator, Williams %R, and others.
def add_momentum_ta(df, high, low, close, volume, fillna=False, colprefix="", vectorized=False):
"""
Add momentum technical analysis features to dataframe.
Parameters:
- df (DataFrame): Base dataframe to add features to
- high (str): Column name for 'High' prices
- low (str): Column name for 'Low' prices
- close (str): Column name for 'Close' prices
- volume (str): Column name for 'Volume' data
- fillna (bool): If True, fill NaN values with 0 (default: False)
- colprefix (str): Prefix to add to all new column names (default: "")
- vectorized (bool): If True, use only vectorized functions (default: False)
Returns:
DataFrame: Original DataFrame with momentum indicators added
"""Adds all 3 other financial analysis indicators for calculating various types of returns.
def add_others_ta(df, close, fillna=False, colprefix=""):
"""
Add others analysis features to dataframe.
Parameters:
- df (DataFrame): Base dataframe to add features to
- close (str): Column name for 'Close' prices
- fillna (bool): If True, fill NaN values with 0 (default: False)
- colprefix (str): Prefix to add to all new column names (default: "")
Returns:
DataFrame: Original DataFrame with return calculation features added
"""import pandas as pd
import ta
# Your OHLCV data
df = pd.read_csv('stock_data.csv')
# Add all 43 technical indicators at once
df_complete = ta.add_all_ta_features(
df,
open='Open',
high='High',
low='Low',
close='Close',
volume='Volume',
fillna=True # Fill NaN values
)
print(f"Original columns: {len(df.columns)}")
print(f"With indicators: {len(df_complete.columns)}")import ta
# Add only trend indicators for trend analysis
df_trend = ta.add_trend_ta(
df,
high='High',
low='Low',
close='Close',
colprefix='trend_' # Prefix all new columns
)
# Add only momentum indicators for momentum analysis
df_momentum = ta.add_momentum_ta(
df,
high='High',
low='Low',
close='Close',
volume='Volume',
vectorized=True # Use only vectorized functions
)import ta
# Start with base data
result_df = df.copy()
# Add indicators by category
result_df = ta.add_volume_ta(result_df, 'High', 'Low', 'Close', 'Volume')
result_df = ta.add_volatility_ta(result_df, 'High', 'Low', 'Close')
result_df = ta.add_trend_ta(result_df, 'High', 'Low', 'Close')
# Now result_df contains volume, volatility, and trend indicatorsInstall with Tessl CLI
npx tessl i tessl/pypi-ta