CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-ta

Technical Analysis Library in Python for financial time series datasets with 43 indicators across Volume, Volatility, Trend, Momentum, and Others categories

Overview
Eval results
Files

volume-indicators.mddocs/

Volume Indicators

Volume-based technical indicators that analyze the relationship between price movements and trading volume. These indicators help identify buying and selling pressure, confirm price trends, and detect potential reversals by examining how volume relates to price action.

Capabilities

Accumulation/Distribution Index (ADI)

Acts as a leading indicator of price movements by measuring the flow of money into and out of a security.

class AccDistIndexIndicator:
    def __init__(self, high, low, close, volume, fillna=False):
        """
        Accumulation/Distribution Index (ADI).
        
        Parameters:
        - high (Series): Dataset 'High' column
        - low (Series): Dataset 'Low' column  
        - close (Series): Dataset 'Close' column
        - volume (Series): Dataset 'Volume' column
        - fillna (bool): If True, fill NaN values (default: False)
        """
    
    def acc_dist_index(self):
        """Returns: Series with Accumulation/Distribution Index values"""

def acc_dist_index(high, low, close, volume, fillna=False):
    """Functional interface for Accumulation/Distribution Index"""

On-Balance Volume (OBV)

Relates price and volume in the stock market by maintaining a running total of volume based on whether prices close higher or lower.

class OnBalanceVolumeIndicator:
    def __init__(self, close, volume, fillna=False):
        """
        On-balance volume (OBV).
        
        Parameters:
        - close (Series): Dataset 'Close' column
        - volume (Series): Dataset 'Volume' column
        - fillna (bool): If True, fill NaN values (default: False)
        """
    
    def on_balance_volume(self):
        """Returns: Series with On-balance volume values"""

def on_balance_volume(close, volume, fillna=False):
    """Functional interface for On-balance volume"""

Chaikin Money Flow (CMF)

Measures the amount of Money Flow Volume over a specific period to assess buying and selling pressure.

class ChaikinMoneyFlowIndicator:
    def __init__(self, high, low, close, volume, window=20, fillna=False):
        """
        Chaikin Money Flow (CMF).
        
        Parameters:
        - high (Series): Dataset 'High' column
        - low (Series): Dataset 'Low' column
        - close (Series): Dataset 'Close' column
        - volume (Series): Dataset 'Volume' column
        - window (int): Period for calculation (default: 20)
        - fillna (bool): If True, fill NaN values (default: False)
        """
    
    def chaikin_money_flow(self):
        """Returns: Series with Chaikin Money Flow values"""

def chaikin_money_flow(high, low, close, volume, window=20, fillna=False):
    """Functional interface for Chaikin Money Flow"""

Force Index (FI)

Illustrates how strong the actual buying or selling pressure is by combining price and volume.

class ForceIndexIndicator:
    def __init__(self, close, volume, window=13, fillna=False):
        """
        Force Index (FI).
        
        Parameters:
        - close (Series): Dataset 'Close' column
        - volume (Series): Dataset 'Volume' column
        - window (int): Period for smoothing (default: 13)
        - fillna (bool): If True, fill NaN values (default: False)
        """
    
    def force_index(self):
        """Returns: Series with Force Index values"""

def force_index(close, volume, window=13, fillna=False):
    """Functional interface for Force Index"""

Ease of Movement (EoM, EMV)

Relates an asset's price change to its volume to identify the ease with which a price can move.

class EaseOfMovementIndicator:
    def __init__(self, high, low, volume, window=14, fillna=False):
        """
        Ease of movement (EoM, EMV).
        
        Parameters:
        - high (Series): Dataset 'High' column
        - low (Series): Dataset 'Low' column
        - volume (Series): Dataset 'Volume' column
        - window (int): Period for smoothing (default: 14)
        - fillna (bool): If True, fill NaN values (default: False)
        """
    
    def ease_of_movement(self):
        """Returns: Series with Ease of Movement values"""
    
    def sma_ease_of_movement(self):
        """Returns: Series with Signal Ease of Movement (smoothed) values"""

def ease_of_movement(high, low, volume, window=14, fillna=False):
    """Functional interface for Ease of Movement"""

def sma_ease_of_movement(high, low, volume, window=14, fillna=False):
    """Functional interface for Signal Ease of Movement"""

Volume-Price Trend (VPT)

Based on a running cumulative volume that adds or subtracts volume based on price changes.

class VolumePriceTrendIndicator:
    def __init__(self, close, volume, fillna=False, smoothing_factor=None, dropnans=False):
        """
        Volume-price trend (VPT).
        
        Parameters:
        - close (Series): Dataset 'Close' column
        - volume (Series): Dataset 'Volume' column
        - fillna (bool): If True, fill NaN values (default: False)
        - smoothing_factor (int, optional): Will smooth VPT with SMA if provided
        - dropnans (bool): Drop NaNs after indicator calculated (default: False)
        """
    
    def volume_price_trend(self):
        """Returns: Series with Volume-price trend values"""

def volume_price_trend(close, volume, fillna=False, smoothing_factor=None, dropnans=False):
    """Functional interface for Volume-price trend"""

Negative Volume Index (NVI)

Focuses on days when volume decreases from the previous day, used to identify periods of smart money activity.

class NegativeVolumeIndexIndicator:
    def __init__(self, close, volume, fillna=False):
        """
        Negative Volume Index (NVI).
        
        Parameters:
        - close (Series): Dataset 'Close' column
        - volume (Series): Dataset 'Volume' column
        - fillna (bool): If True, fill NaN values with 1000 (default: False)
        """
    
    def negative_volume_index(self):
        """Returns: Series with Negative Volume Index values"""

def negative_volume_index(close, volume, fillna=False):
    """Functional interface for Negative Volume Index"""

Money Flow Index (MFI)

Uses both price and volume to measure buying and selling pressure, often called the "volume-weighted RSI".

class MFIIndicator:
    def __init__(self, high, low, close, volume, window=14, fillna=False):
        """
        Money Flow Index (MFI).
        
        Parameters:
        - high (Series): Dataset 'High' column
        - low (Series): Dataset 'Low' column
        - close (Series): Dataset 'Close' column
        - volume (Series): Dataset 'Volume' column
        - window (int): Period for calculation (default: 14)
        - fillna (bool): If True, fill NaN values (default: False)
        """
    
    def money_flow_index(self):
        """Returns: Series with Money Flow Index values (0-100 scale)"""

def money_flow_index(high, low, close, volume, window=14, fillna=False):
    """Functional interface for Money Flow Index"""

Volume Weighted Average Price (VWAP)

Calculates the average price weighted by volume, providing a benchmark for intraday trading decisions.

class VolumeWeightedAveragePrice:
    def __init__(self, high, low, close, volume, window=14, fillna=False):
        """
        Volume Weighted Average Price (VWAP).
        
        Parameters:
        - high (Series): Dataset 'High' column
        - low (Series): Dataset 'Low' column
        - close (Series): Dataset 'Close' column
        - volume (Series): Dataset 'Volume' column
        - window (int): Period for calculation (default: 14)
        - fillna (bool): If True, fill NaN values (default: False)
        """
    
    def volume_weighted_average_price(self):
        """Returns: Series with VWAP values"""

def volume_weighted_average_price(high, low, close, volume, window=14, fillna=False):
    """Functional interface for VWAP"""

Usage Examples

Using Class-Based API

from ta.volume import MFIIndicator, OnBalanceVolumeIndicator
import pandas as pd

# Create indicators using classes
mfi = MFIIndicator(
    high=df['High'],
    low=df['Low'], 
    close=df['Close'],
    volume=df['Volume'],
    window=14
)

obv = OnBalanceVolumeIndicator(
    close=df['Close'],
    volume=df['Volume']
)

# Calculate indicator values
df['MFI'] = mfi.money_flow_index()
df['OBV'] = obv.on_balance_volume()

Using Functional API

from ta.volume import money_flow_index, on_balance_volume, chaikin_money_flow

# Calculate indicators using functions
df['MFI'] = money_flow_index(
    df['High'], df['Low'], df['Close'], df['Volume'], 
    window=14, fillna=True
)

df['OBV'] = on_balance_volume(df['Close'], df['Volume'])

df['CMF'] = chaikin_money_flow(
    df['High'], df['Low'], df['Close'], df['Volume'],
    window=20
)

Volume Analysis Workflow

from ta.volume import *
import pandas as pd

# Comprehensive volume analysis
def analyze_volume_indicators(df):
    # Trend confirmation indicators
    df['OBV'] = on_balance_volume(df['Close'], df['Volume'])
    df['ADI'] = acc_dist_index(df['High'], df['Low'], df['Close'], df['Volume'])
    
    # Momentum indicators with volume
    df['MFI'] = money_flow_index(df['High'], df['Low'], df['Close'], df['Volume'])
    df['CMF'] = chaikin_money_flow(df['High'], df['Low'], df['Close'], df['Volume'])
    
    # Price-volume relationship
    df['VWAP'] = volume_weighted_average_price(df['High'], df['Low'], df['Close'], df['Volume'])
    df['Force_Index'] = force_index(df['Close'], df['Volume'])
    
    return df

# Apply to your data
df_with_volume = analyze_volume_indicators(df)

Install with Tessl CLI

npx tessl i tessl/pypi-ta

docs

index.md

momentum-indicators.md

others-indicators.md

trend-indicators.md

utilities.md

volatility-indicators.md

volume-indicators.md

wrapper-functions.md

tile.json