Python wrapper for TA-LIB providing 175+ technical analysis indicators for financial market data
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Indicators that analyze the relationship between price movements and trading volume to confirm trends, identify potential reversals, and validate price action. Volume analysis helps determine the strength behind price movements.
Accumulation/Distribution Line that combines price and volume to show how much of a security is being accumulated or distributed.
def AD(high, low, close, volume):
"""
Chaikin A/D Line
Parameters:
- high: array-like, high prices
- low: array-like, low prices
- close: array-like, close prices
- volume: array-like, volume data
Returns:
numpy.ndarray: Accumulation/Distribution Line values
"""Cumulative volume indicator that adds volume on up days and subtracts volume on down days to measure buying and selling pressure.
def OBV(close, volume):
"""
On Balance Volume
Parameters:
- close: array-like, close prices
- volume: array-like, volume data
Returns:
numpy.ndarray: OBV values (cumulative volume)
"""Oscillator version of the Accumulation/Distribution Line, showing the momentum of accumulation/distribution.
def ADOSC(high, low, close, volume, fastperiod=3, slowperiod=10):
"""
Chaikin A/D Oscillator
Parameters:
- high: array-like, high prices
- low: array-like, low prices
- close: array-like, close prices
- volume: array-like, volume data
- fastperiod: int, fast EMA period (default: 3)
- slowperiod: int, slow EMA period (default: 10)
Returns:
numpy.ndarray: A/D Oscillator values
"""import talib
import numpy as np
# Sample OHLCV data
high = np.array([10.5, 11.0, 11.2, 10.8, 11.5])
low = np.array([10.0, 10.3, 10.5, 10.2, 10.8])
close = np.array([10.3, 10.8, 10.9, 10.4, 11.2])
volume = np.array([1000, 1200, 800, 1500, 900])
# Calculate volume indicators
ad_line = talib.AD(high, low, close, volume)
obv = talib.OBV(close, volume)
ad_osc = talib.ADOSC(high, low, close, volume, fastperiod=3, slowperiod=10)
print("A/D Line:", ad_line[-1])
print("OBV:", obv[-1])
print("A/D Oscillator:", ad_osc[-1])