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
Trend-following indicators and moving averages that smooth price data to identify trends and provide support/resistance levels. These indicators "overlay" on price charts and help traders identify trend direction and potential reversal points.
Calculates the arithmetic mean of prices over a specified time period, providing trend direction and support/resistance levels.
def SMA(real, timeperiod=30):
"""
Simple Moving Average
Parameters:
- real: array-like, input price data (typically close prices)
- timeperiod: int, number of periods for averaging (default: 30)
Returns:
numpy.ndarray: SMA values
"""Calculates exponentially weighted moving average giving more weight to recent prices, making it more responsive to price changes than SMA.
def EMA(real, timeperiod=30):
"""
Exponential Moving Average
Parameters:
- real: array-like, input price data
- timeperiod: int, number of periods (default: 30)
Returns:
numpy.ndarray: EMA values
"""Creates volatility bands around a moving average to identify overbought/oversold conditions and potential breakouts.
def BBANDS(real, timeperiod=5, nbdevup=2, nbdevdn=2, matype=MA_Type.SMA):
"""
Bollinger Bands
Parameters:
- real: array-like, input price data
- timeperiod: int, moving average period (default: 5)
- nbdevup: float, upper band deviation multiplier (default: 2)
- nbdevdn: float, lower band deviation multiplier (default: 2)
- matype: MA_Type, moving average type (default: SMA)
Returns:
tuple: (upper_band, middle_band, lower_band)
"""Double-smoothed exponential moving average that reduces lag while maintaining smoothness.
def DEMA(real, timeperiod=30):
"""
Double Exponential Moving Average
Parameters:
- real: array-like, input price data
- timeperiod: int, number of periods (default: 30)
Returns:
numpy.ndarray: DEMA values
"""Triple-smoothed exponential moving average providing even less lag than DEMA.
def TEMA(real, timeperiod=30):
"""
Triple Exponential Moving Average
Parameters:
- real: array-like, input price data
- timeperiod: int, number of periods (default: 30)
Returns:
numpy.ndarray: TEMA values
"""Double-smoothed simple moving average creating a triangular weighting pattern.
def TRIMA(real, timeperiod=30):
"""
Triangular Moving Average
Parameters:
- real: array-like, input price data
- timeperiod: int, number of periods (default: 30)
Returns:
numpy.ndarray: TRIMA values
"""Linear weighted moving average giving more weight to recent prices in a linear fashion.
def WMA(real, timeperiod=30):
"""
Weighted Moving Average
Parameters:
- real: array-like, input price data
- timeperiod: int, number of periods (default: 30)
Returns:
numpy.ndarray: WMA values
"""Adaptive moving average that adjusts its smoothing based on market volatility and trending conditions.
def KAMA(real, timeperiod=30):
"""
Kaufman Adaptive Moving Average
Parameters:
- real: array-like, input price data
- timeperiod: int, number of periods (default: 30)
Returns:
numpy.ndarray: KAMA values
"""Generic moving average function allowing selection of different MA types.
def MA(real, timeperiod=30, matype=MA_Type.SMA):
"""
Moving Average
Parameters:
- real: array-like, input price data
- timeperiod: int, number of periods (default: 30)
- matype: MA_Type, type of moving average (default: SMA)
Returns:
numpy.ndarray: Moving average values
"""Adaptive moving average based on MESA (Maximum Entropy Spectral Analysis) algorithm.
def MAMA(real, fastlimit=0, slowlimit=0):
"""
MESA Adaptive Moving Average
Parameters:
- real: array-like, input price data
- fastlimit: float, fast limit (default: 0)
- slowlimit: float, slow limit (default: 0)
Returns:
tuple: (mama, fama) - MESA Adaptive MA and Following Adaptive MA
"""Moving average with variable time periods allowing period changes over time.
def MAVP(real, periods, minperiod=2, maxperiod=30, matype=MA_Type.SMA):
"""
Moving Average Variable Period
Parameters:
- real: array-like, input price data
- periods: float, period value for calculation
- minperiod: int, minimum period allowed (default: 2)
- maxperiod: int, maximum period allowed (default: 30)
- matype: MA_Type, moving average type (default: SMA)
Returns:
numpy.ndarray: Variable period MA values
"""Calculates the midpoint of the highest and lowest values over a specified period.
def MIDPOINT(real, timeperiod=14):
"""
MidPoint over period
Parameters:
- real: array-like, input price data
- timeperiod: int, number of periods (default: 14)
Returns:
numpy.ndarray: Midpoint values
"""Calculates the midpoint of high and low prices over a specified period.
def MIDPRICE(high, low, timeperiod=14):
"""
Midpoint Price over period
Parameters:
- high: array-like, high prices
- low: array-like, low prices
- timeperiod: int, number of periods (default: 14)
Returns:
numpy.ndarray: Midprice values
"""Stop and Reverse system that provides trailing stop levels and trend reversal signals.
def SAR(high, low, acceleration=0, maximum=0):
"""
Parabolic SAR
Parameters:
- high: array-like, high prices
- low: array-like, low prices
- acceleration: float, acceleration factor (default: 0)
- maximum: float, maximum acceleration (default: 0)
Returns:
numpy.ndarray: SAR values
"""Extended version of Parabolic SAR with additional customization parameters.
def SAREXT(high, low, startvalue=0, offsetonreverse=0, accelerationinitlong=0,
accelerationlong=0, accelerationmaxlong=0, accelerationinitshort=0,
accelerationshort=0, accelerationmaxshort=0):
"""
Parabolic SAR Extended
Parameters:
- high: array-like, high prices
- low: array-like, low prices
- startvalue: float, start value (default: 0)
- offsetonreverse: float, offset on reverse (default: 0)
- accelerationinitlong: float, initial acceleration for long positions (default: 0)
- accelerationlong: float, acceleration for long positions (default: 0)
- accelerationmaxlong: float, maximum acceleration for long positions (default: 0)
- accelerationinitshort: float, initial acceleration for short positions (default: 0)
- accelerationshort: float, acceleration for short positions (default: 0)
- accelerationmaxshort: float, maximum acceleration for short positions (default: 0)
Returns:
numpy.ndarray: Extended SAR values
"""Smoothed moving average with optional volume factor for fine-tuning responsiveness.
def T3(real, timeperiod=5, vfactor=0):
"""
Triple Exponential Moving Average (T3)
Parameters:
- real: array-like, input price data
- timeperiod: int, number of periods (default: 5)
- vfactor: float, volume factor (default: 0)
Returns:
numpy.ndarray: T3 values
"""Uses Hilbert Transform to generate instantaneous trendline values.
def HT_TRENDLINE(real):
"""
Hilbert Transform - Instantaneous Trendline
Parameters:
- real: array-like, input price data
Returns:
numpy.ndarray: Trendline values
"""