mirror of
https://github.com/wassname/pandas-ta.git
synced 2026-06-27 16:10:07 +08:00
ENH #336 ENH talib optional arg DOC updates
This commit is contained in:
@@ -4,7 +4,7 @@ from pandas_ta.overlap import ma
|
||||
from pandas_ta.utils import get_offset, tal_ma, verify_series
|
||||
|
||||
|
||||
def apo(close, fast=None, slow=None, mamode=None, offset=None, **kwargs):
|
||||
def apo(close, fast=None, slow=None, mamode=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Absolute Price Oscillator (APO)"""
|
||||
# Validate Arguments
|
||||
fast = int(fast) if fast and fast > 0 else 12
|
||||
@@ -14,11 +14,12 @@ def apo(close, fast=None, slow=None, mamode=None, offset=None, **kwargs):
|
||||
close = verify_series(close, max(fast, slow))
|
||||
mamode = mamode if isinstance(mamode, str) else "sma"
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import APO
|
||||
apo = APO(close, fast, slow, tal_ma(mamode))
|
||||
else:
|
||||
@@ -63,6 +64,9 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
fast (int): The short period. Default: 12
|
||||
slow (int): The long period. Default: 26
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'sma'
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -53,7 +53,7 @@ Calculation:
|
||||
Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): The period. Default: 26
|
||||
mamode (str): Options: 'ema', 'hma', 'rma', 'sma', 'wma'. Default: 'sma'
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'sma'
|
||||
drift (int): The short period. Default: 1
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, non_zero_range, verify_series
|
||||
|
||||
|
||||
def bop(open_, high, low, close, scalar=None, offset=None, **kwargs):
|
||||
def bop(open_, high, low, close, scalar=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Balance of Power (BOP)"""
|
||||
# Validate Arguments
|
||||
open_ = verify_series(open_)
|
||||
@@ -12,9 +12,10 @@ def bop(open_, high, low, close, scalar=None, offset=None, **kwargs):
|
||||
close = verify_series(close)
|
||||
scalar = float(scalar) if scalar else 1
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import BOP
|
||||
bop = BOP(open_, high, low, close)
|
||||
else:
|
||||
@@ -56,6 +57,8 @@ Args:
|
||||
low (pd.Series): Series of 'low's
|
||||
close (pd.Series): Series of 'close's
|
||||
scalar (float): How much to magnify. Default: 1
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -5,7 +5,7 @@ from pandas_ta.statistics.mad import mad
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def cci(high, low, close, length=None, c=None, offset=None, **kwargs):
|
||||
def cci(high, low, close, length=None, c=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Commodity Channel Index (CCI)"""
|
||||
# Validate Arguments
|
||||
length = int(length) if length and length > 0 else 14
|
||||
@@ -14,11 +14,12 @@ def cci(high, low, close, length=None, c=None, offset=None, **kwargs):
|
||||
low = verify_series(low, length)
|
||||
close = verify_series(close, length)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if high is None or low is None or close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import CCI
|
||||
cci = CCI(high, low, close, length)
|
||||
else:
|
||||
@@ -71,6 +72,8 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 14
|
||||
c (float): Scaling Constant. Default: 0.015
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -4,7 +4,7 @@ from pandas_ta.overlap import rma
|
||||
from pandas_ta.utils import get_drift, get_offset, verify_series
|
||||
|
||||
|
||||
def cmo(close, length=None, scalar=None, drift=None, offset=None, **kwargs):
|
||||
def cmo(close, length=None, scalar=None, talib=None, drift=None, offset=None, **kwargs):
|
||||
"""Indicator: Chande Momentum Oscillator (CMO)"""
|
||||
# Validate Arguments
|
||||
length = int(length) if length and length > 0 else 14
|
||||
@@ -12,12 +12,12 @@ def cmo(close, length=None, scalar=None, drift=None, offset=None, **kwargs):
|
||||
close = verify_series(close, length)
|
||||
drift = get_drift(drift)
|
||||
offset = get_offset(offset)
|
||||
talib_mode = kwargs.pop("talib", True)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if talib_mode and Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import CMO
|
||||
cmo = CMO(close, length)
|
||||
else:
|
||||
@@ -25,7 +25,7 @@ def cmo(close, length=None, scalar=None, drift=None, offset=None, **kwargs):
|
||||
positive = mom.copy().clip(lower=0)
|
||||
negative = mom.copy().clip(upper=0).abs()
|
||||
|
||||
if talib_mode:
|
||||
if mode_tal:
|
||||
pos_ = rma(positive, length)
|
||||
neg_ = rma(negative, length)
|
||||
else:
|
||||
@@ -71,6 +71,9 @@ Calculation:
|
||||
Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
scalar (float): How much to magnify. Default: 100
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. If TA Lib is not installed but talib is True, it runs the Python
|
||||
version TA Lib. Default: True
|
||||
drift (int): The short period. Default: 1
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from pandas_ta.overlap import ma
|
||||
from pandas_ta.utils import get_offset, verify_series, get_drift, zero
|
||||
|
||||
|
||||
def dm(high, low, length=None, mamode=None, drift=None, offset=None, **kwargs):
|
||||
def dm(high, low, length=None, mamode=None, talib=None, drift=None, offset=None, **kwargs):
|
||||
"""Indicator: DM"""
|
||||
# Validate Arguments
|
||||
length = int(length) if length and length > 0 else 14
|
||||
@@ -14,11 +14,12 @@ def dm(high, low, length=None, mamode=None, drift=None, offset=None, **kwargs):
|
||||
low = verify_series(low)
|
||||
drift = get_drift(drift)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if high is None or low is None:
|
||||
return
|
||||
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import MINUS_DM, PLUS_DM
|
||||
pos = PLUS_DM(high, low, length)
|
||||
neg = MINUS_DM(high, low, length)
|
||||
@@ -86,6 +87,9 @@ Calculation:
|
||||
Args:
|
||||
high (pd.Series): Series of 'high's
|
||||
low (pd.Series): Series of 'low's
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'rma'
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
drift (int): The difference period. Default: 1
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
|
||||
@@ -78,6 +78,9 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 20
|
||||
rvi_length (int): RVI period. Default: 14
|
||||
refined (bool): Use 'refined' calculation. Default: False
|
||||
thirds (bool): Use 'thirds' calculation. Default: False
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'ema'
|
||||
drift (int): The difference period. Default: 1
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from pandas_ta.overlap import ema
|
||||
from pandas_ta.utils import get_offset, verify_series, signals
|
||||
|
||||
|
||||
def macd(close, fast=None, slow=None, signal=None, offset=None, **kwargs):
|
||||
def macd(close, fast=None, slow=None, signal=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Moving Average, Convergence/Divergence (MACD)"""
|
||||
# Validate arguments
|
||||
fast = int(fast) if fast and fast > 0 else 12
|
||||
@@ -15,13 +15,14 @@ def macd(close, fast=None, slow=None, signal=None, offset=None, **kwargs):
|
||||
fast, slow = slow, fast
|
||||
close = verify_series(close, max(fast, slow, signal))
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
as_mode = kwargs.setdefault("asmode", False)
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import MACD
|
||||
macd, signalma, histogram = MACD(close, fast, slow, signal)
|
||||
else:
|
||||
@@ -133,6 +134,8 @@ Args:
|
||||
fast (int): The short period. Default: 12
|
||||
slow (int): The long period. Default: 26
|
||||
signal (int): The signal period. Default: 9
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -3,17 +3,18 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def mom(close, length=None, offset=None, **kwargs):
|
||||
def mom(close, length=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Momentum (MOM)"""
|
||||
# Validate Arguments
|
||||
length = int(length) if length and length > 0 else 10
|
||||
close = verify_series(close, length)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import MOM
|
||||
mom = MOM(close, length)
|
||||
else:
|
||||
@@ -53,6 +54,8 @@ Calculation:
|
||||
Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 1
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -5,7 +5,7 @@ from pandas_ta.overlap import ma
|
||||
from pandas_ta.utils import get_offset, tal_ma, verify_series
|
||||
|
||||
|
||||
def ppo(close, fast=None, slow=None, signal=None, scalar=None, mamode=None, offset=None, **kwargs):
|
||||
def ppo(close, fast=None, slow=None, signal=None, scalar=None, mamode=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Percentage Price Oscillator (PPO)"""
|
||||
# Validate Arguments
|
||||
fast = int(fast) if fast and fast > 0 else 12
|
||||
@@ -17,11 +17,12 @@ def ppo(close, fast=None, slow=None, signal=None, scalar=None, mamode=None, offs
|
||||
fast, slow = slow, fast
|
||||
close = verify_series(close, max(fast, slow, signal))
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import PPO
|
||||
ppo = PPO(close, fast, slow, tal_ma(mamode))
|
||||
else:
|
||||
@@ -90,7 +91,9 @@ Args:
|
||||
slow(int): The long period. Default: 26
|
||||
signal(int): The signal period. Default: 9
|
||||
scalar (float): How much to magnify. Default: 100
|
||||
mamode (str): Options: 'ema', 'hma', 'rma', 'sma', 'wma'. Default: 'sma'
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'sma'
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset(int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -143,8 +143,7 @@ Args:
|
||||
length (int): RSI period. Default: 14
|
||||
smooth (int): RSI smoothing period. Default: 5
|
||||
factor (float): QQE Factor. Default: 4.236
|
||||
mamode (str): Smoothing MA type: "ema", "hma", "rma", "sma" or "wma".
|
||||
Default: "ema"
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'sma'
|
||||
drift (int): The difference period. Default: 1
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
|
||||
@@ -4,18 +4,19 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def roc(close, length=None, scalar=None, offset=None, **kwargs):
|
||||
def roc(close, length=None, scalar=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Rate of Change (ROC)"""
|
||||
# Validate Arguments
|
||||
length = int(length) if length and length > 0 else 10
|
||||
scalar = float(scalar) if scalar and scalar > 0 else 100
|
||||
close = verify_series(close, length)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import ROC
|
||||
roc = ROC(close, length)
|
||||
else:
|
||||
@@ -57,6 +58,9 @@ Calculation:
|
||||
Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 1
|
||||
scalar (float): How much to magnify. Default: 100
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -5,7 +5,7 @@ from pandas_ta.overlap import rma
|
||||
from pandas_ta.utils import get_drift, get_offset, verify_series, signals
|
||||
|
||||
|
||||
def rsi(close, length=None, scalar=None, drift=None, offset=None, **kwargs):
|
||||
def rsi(close, length=None, scalar=None, talib=None, drift=None, offset=None, **kwargs):
|
||||
"""Indicator: Relative Strength Index (RSI)"""
|
||||
# Validate arguments
|
||||
length = int(length) if length and length > 0 else 14
|
||||
@@ -13,11 +13,12 @@ def rsi(close, length=None, scalar=None, drift=None, offset=None, **kwargs):
|
||||
close = verify_series(close, length)
|
||||
drift = get_drift(drift)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import RSI
|
||||
rsi = RSI(close, length)
|
||||
else:
|
||||
@@ -99,6 +100,8 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 14
|
||||
scalar (float): How much to magnify. Default: 100
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
drift (int): The difference period. Default: 1
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pandas import DataFrame
|
||||
from pandas_ta.overlap import sma
|
||||
from pandas_ta.overlap import ma
|
||||
from pandas_ta.utils import get_offset, non_zero_range, verify_series
|
||||
|
||||
|
||||
def stoch(high, low, close, k=None, d=None, smooth_k=None, offset=None, **kwargs):
|
||||
def stoch(high, low, close, k=None, d=None, smooth_k=None, mamode=None, offset=None, **kwargs):
|
||||
"""Indicator: Stochastic Oscillator (STOCH)"""
|
||||
# Validate arguments
|
||||
k = k if k and k > 0 else 14
|
||||
@@ -15,6 +15,7 @@ def stoch(high, low, close, k=None, d=None, smooth_k=None, offset=None, **kwargs
|
||||
low = verify_series(low, _length)
|
||||
close = verify_series(close, _length)
|
||||
offset = get_offset(offset)
|
||||
mamode = mamode if isinstance(mamode, str) else "sma"
|
||||
|
||||
if high is None or low is None or close is None: return
|
||||
|
||||
@@ -25,8 +26,8 @@ def stoch(high, low, close, k=None, d=None, smooth_k=None, offset=None, **kwargs
|
||||
stoch = 100 * (close - lowest_low)
|
||||
stoch /= non_zero_range(highest_high, lowest_low)
|
||||
|
||||
stoch_k = sma(stoch, length=smooth_k)
|
||||
stoch_d = sma(stoch_k, length=d)
|
||||
stoch_k = ma(mamode, stoch.loc[stoch.first_valid_index():,], length=smooth_k)
|
||||
stoch_d = ma(mamode, stoch_k.loc[stoch_k.first_valid_index():,], length=d)
|
||||
|
||||
# Offset
|
||||
if offset != 0:
|
||||
@@ -53,7 +54,6 @@ def stoch(high, low, close, k=None, d=None, smooth_k=None, offset=None, **kwargs
|
||||
df = DataFrame(data)
|
||||
df.name = f"{_name}{_props}"
|
||||
df.category = stoch_k.category
|
||||
|
||||
return df
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ Args:
|
||||
k (int): The Fast %K period. Default: 14
|
||||
d (int): The Slow %K period. Default: 3
|
||||
smooth_k (int): The Slow %D period. Default: 3
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'sma'
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pandas import DataFrame
|
||||
from .rsi import rsi
|
||||
from pandas_ta.overlap import sma
|
||||
from pandas_ta.overlap import ma
|
||||
from pandas_ta.utils import get_offset, non_zero_range, verify_series
|
||||
|
||||
|
||||
def stochrsi(close, length=None, rsi_length=None, k=None, d=None, offset=None, **kwargs):
|
||||
def stochrsi(close, length=None, rsi_length=None, k=None, d=None, mamode=None, offset=None, **kwargs):
|
||||
"""Indicator: Stochastic RSI Oscillator (STOCHRSI)"""
|
||||
# Validate arguments
|
||||
length = length if length and length > 0 else 14
|
||||
@@ -14,6 +14,7 @@ def stochrsi(close, length=None, rsi_length=None, k=None, d=None, offset=None, *
|
||||
d = d if d and d > 0 else 3
|
||||
close = verify_series(close, max(length, rsi_length, k, d))
|
||||
offset = get_offset(offset)
|
||||
mamode = mamode if isinstance(mamode, str) else "sma"
|
||||
|
||||
if close is None: return
|
||||
|
||||
@@ -25,8 +26,8 @@ def stochrsi(close, length=None, rsi_length=None, k=None, d=None, offset=None, *
|
||||
stoch = 100 * (rsi_ - lowest_rsi)
|
||||
stoch /= non_zero_range(highest_rsi, lowest_rsi)
|
||||
|
||||
stochrsi_k = sma(stoch, length=k)
|
||||
stochrsi_d = sma(stochrsi_k, length=d)
|
||||
stochrsi_k = ma(mamode, stoch, length=k)
|
||||
stochrsi_d = ma(mamode, stochrsi_k, length=d)
|
||||
|
||||
# Offset
|
||||
if offset != 0:
|
||||
@@ -92,6 +93,7 @@ Args:
|
||||
rsi_length (int): RSI period. Default: 14
|
||||
k (int): The Fast %K period. Default: 3
|
||||
d (int): The Slow %K period. Default: 3
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'sma'
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -4,7 +4,7 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_drift, get_offset, verify_series
|
||||
|
||||
|
||||
def uo(high, low, close, fast=None, medium=None, slow=None, fast_w=None, medium_w=None, slow_w=None, drift=None, offset=None, **kwargs):
|
||||
def uo(high, low, close, fast=None, medium=None, slow=None, fast_w=None, medium_w=None, slow_w=None, talib=None, drift=None, offset=None, **kwargs):
|
||||
"""Indicator: Ultimate Oscillator (UO)"""
|
||||
# Validate arguments
|
||||
fast = int(fast) if fast and fast > 0 else 7
|
||||
@@ -19,11 +19,12 @@ def uo(high, low, close, fast=None, medium=None, slow=None, fast_w=None, medium_
|
||||
close = verify_series(close, _length)
|
||||
drift = get_drift(drift)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if high is None or low is None or close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import ULTOSC
|
||||
uo = ULTOSC(high, low, close, fast, medium, slow)
|
||||
else:
|
||||
@@ -101,6 +102,8 @@ Args:
|
||||
fast_w (float): The Fast %K period. Default: 4.0
|
||||
medium_w (float): The Slow %K period. Default: 2.0
|
||||
slow_w (float): The Slow %D period. Default: 1.0
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
drift (int): The difference period. Default: 1
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def willr(high, low, close, length=None, offset=None, **kwargs):
|
||||
def willr(high, low, close, length=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: William's Percent R (WILLR)"""
|
||||
# Validate arguments
|
||||
length = int(length) if length and length > 0 else 14
|
||||
@@ -13,11 +13,12 @@ def willr(high, low, close, length=None, offset=None, **kwargs):
|
||||
low = verify_series(low, _length)
|
||||
close = verify_series(close, _length)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if high is None or low is None or close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import WILLR
|
||||
willr = WILLR(high, low, close, length)
|
||||
else:
|
||||
@@ -65,6 +66,8 @@ Args:
|
||||
low (pd.Series): Series of 'low's
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 14
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -4,17 +4,18 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def dema(close, length=None, offset=None, **kwargs):
|
||||
def dema(close, length=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Double Exponential Moving Average (DEMA)"""
|
||||
# Validate Arguments
|
||||
length = int(length) if length and length > 0 else 10
|
||||
close = verify_series(close, length)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import DEMA
|
||||
dema = DEMA(close, length)
|
||||
else:
|
||||
@@ -60,6 +61,8 @@ Calculation:
|
||||
Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 10
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -4,7 +4,7 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def ema(close, length=None, offset=None, **kwargs):
|
||||
def ema(close, length=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Exponential Moving Average (EMA)"""
|
||||
# Validate Arguments
|
||||
length = int(length) if length and length > 0 else 10
|
||||
@@ -12,11 +12,12 @@ def ema(close, length=None, offset=None, **kwargs):
|
||||
sma = kwargs.pop("sma", True)
|
||||
close = verify_series(close, length)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import EMA
|
||||
ema = EMA(close, length)
|
||||
else:
|
||||
@@ -69,6 +70,8 @@ Calculation:
|
||||
Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 10
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -115,7 +115,7 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
high_length (int): It's period. Default: 13
|
||||
low_length (int): It's period. Default: 21
|
||||
mamode (str): Options: 'sma' or 'ema'. Default: 'sma'
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'sma'
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -3,16 +3,17 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def hlc3(high, low, close, offset=None, **kwargs):
|
||||
def hlc3(high, low, close, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: HLC3"""
|
||||
# Validate Arguments
|
||||
high = verify_series(high)
|
||||
low = verify_series(low)
|
||||
close = verify_series(close)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import TYPPRICE
|
||||
hlc3 = TYPPRICE(high, low, close)
|
||||
else:
|
||||
|
||||
@@ -3,18 +3,19 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def midpoint(close, length=None, offset=None, **kwargs):
|
||||
def midpoint(close, length=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Midpoint"""
|
||||
# Validate arguments
|
||||
length = int(length) if length and length > 0 else 2
|
||||
min_periods = int(kwargs["min_periods"]) if "min_periods" in kwargs and kwargs["min_periods"] is not None else length
|
||||
close = verify_series(close, max(length, min_periods))
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import MIDPOINT
|
||||
midpoint = MIDPOINT(close, length)
|
||||
else:
|
||||
|
||||
@@ -3,7 +3,7 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def midprice(high, low, length=None, offset=None, **kwargs):
|
||||
def midprice(high, low, length=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Midprice"""
|
||||
# Validate arguments
|
||||
length = int(length) if length and length > 0 else 2
|
||||
@@ -12,11 +12,12 @@ def midprice(high, low, length=None, offset=None, **kwargs):
|
||||
high = verify_series(high, _length)
|
||||
low = verify_series(low, _length)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if high is None or low is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import MIDPRICE
|
||||
midprice = MIDPRICE(high, low, length)
|
||||
else:
|
||||
|
||||
@@ -3,18 +3,19 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def sma(close, length=None, offset=None, **kwargs):
|
||||
def sma(close, length=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Simple Moving Average (SMA)"""
|
||||
# Validate Arguments
|
||||
length = int(length) if length and length > 0 else 10
|
||||
min_periods = int(kwargs["min_periods"]) if "min_periods" in kwargs and kwargs["min_periods"] is not None else length
|
||||
close = verify_series(close, max(length, min_periods))
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import SMA
|
||||
sma = SMA(close, length)
|
||||
else:
|
||||
@@ -54,6 +55,8 @@ Calculation:
|
||||
Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 10
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -4,18 +4,19 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def t3(close, length=None, a=None, offset=None, **kwargs):
|
||||
def t3(close, length=None, a=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: T3"""
|
||||
# Validate Arguments
|
||||
length = int(length) if length and length > 0 else 10
|
||||
a = float(a) if a and a > 0 and a < 1 else 0.7
|
||||
close = verify_series(close, length)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import T3
|
||||
t3 = T3(close, length, a)
|
||||
else:
|
||||
@@ -77,6 +78,8 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 10
|
||||
a (float): 0 < a < 1. Default: 0.7
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -4,17 +4,18 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def tema(close, length=None, offset=None, **kwargs):
|
||||
def tema(close, length=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Triple Exponential Moving Average (TEMA)"""
|
||||
# Validate Arguments
|
||||
length = int(length) if length and length > 0 else 10
|
||||
close = verify_series(close, length)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import TEMA
|
||||
tema = TEMA(close, length)
|
||||
else:
|
||||
@@ -60,6 +61,8 @@ Calculation:
|
||||
Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 10
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -4,17 +4,18 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def trima(close, length=None, offset=None, **kwargs):
|
||||
def trima(close, length=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Triangular Moving Average (TRIMA)"""
|
||||
# Validate Arguments
|
||||
length = int(length) if length and length > 0 else 10
|
||||
close = verify_series(close, length)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import TRIMA
|
||||
trima = TRIMA(close, length)
|
||||
else:
|
||||
@@ -61,6 +62,8 @@ Calculation:
|
||||
Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 10
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -3,16 +3,17 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def wcp(high, low, close, offset=None, **kwargs):
|
||||
def wcp(high, low, close, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Weighted Closing Price (WCP)"""
|
||||
# Validate Arguments
|
||||
high = verify_series(high)
|
||||
low = verify_series(low)
|
||||
close = verify_series(close)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import WCLPRICE
|
||||
wcp = WCLPRICE(high, low, close)
|
||||
else:
|
||||
@@ -51,6 +52,8 @@ Args:
|
||||
high (pd.Series): Series of 'high's
|
||||
low (pd.Series): Series of 'low's
|
||||
close (pd.Series): Series of 'close's
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -4,18 +4,19 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def wma(close, length=None, asc=None, offset=None, **kwargs):
|
||||
def wma(close, length=None, asc=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Weighted Moving Average (WMA)"""
|
||||
# Validate Arguments
|
||||
length = int(length) if length and length > 0 else 10
|
||||
asc = asc if asc else True
|
||||
close = verify_series(close, length)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import WMA
|
||||
wma = WMA(close, length)
|
||||
else:
|
||||
@@ -78,6 +79,8 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 10
|
||||
asc (bool): Recent values weigh more. Default: True
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -5,18 +5,19 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def stdev(close, length=None, ddof=None, offset=None, **kwargs):
|
||||
def stdev(close, length=None, ddof=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Standard Deviation"""
|
||||
# Validate Arguments
|
||||
length = int(length) if length and length > 0 else 30
|
||||
ddof = int(ddof) if ddof and ddof >= 0 and ddof < length else 1
|
||||
close = verify_series(close, length)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import STDDEV
|
||||
stdev = STDDEV(close, length)
|
||||
else:
|
||||
@@ -56,6 +57,8 @@ Args:
|
||||
ddof (int): Delta Degrees of Freedom.
|
||||
The divisor used in calculations is N - ddof,
|
||||
where N represents the number of elements. Default: 1
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -3,7 +3,7 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def variance(close, length=None, ddof=None, offset=None, **kwargs):
|
||||
def variance(close, length=None, ddof=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Variance"""
|
||||
# Validate Arguments
|
||||
length = int(length) if length and length > 1 else 30
|
||||
@@ -11,11 +11,12 @@ def variance(close, length=None, ddof=None, offset=None, **kwargs):
|
||||
min_periods = int(kwargs["min_periods"]) if "min_periods" in kwargs and kwargs["min_periods"] is not None else length
|
||||
close = verify_series(close, max(length, min_periods))
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import VAR
|
||||
variance = VAR(close, length)
|
||||
else:
|
||||
@@ -54,6 +55,8 @@ Args:
|
||||
ddof (int): Delta Degrees of Freedom.
|
||||
The divisor used in calculations is N - ddof,
|
||||
where N represents the number of elements. Default: 0
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -5,7 +5,7 @@ from pandas_ta.volatility import atr
|
||||
from pandas_ta.utils import get_drift, get_offset, verify_series, zero
|
||||
|
||||
|
||||
def adx(high, low, close, length=None, lensig=None, mamode=None, scalar=None, drift=None, offset=None, **kwargs):
|
||||
def adx(high, low, close, length=None, lensig=None, scalar=None, mamode=None, drift=None, offset=None, **kwargs):
|
||||
"""Indicator: ADX"""
|
||||
# Validate Arguments
|
||||
length = length if length and length > 0 else 14
|
||||
@@ -138,6 +138,7 @@ Args:
|
||||
length (int): It's period. Default: 14
|
||||
lensig (int): Signal Length. Like TradingView's default ADX. Default: length
|
||||
scalar (float): How much to magnify. Default: 100
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'rma'
|
||||
drift (int): The difference period. Default: 1
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from pandas_ta.overlap import ma
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def amat(close=None, fast=None, slow=None, mamode=None, lookback=None, offset=None, **kwargs):
|
||||
def amat(close=None, fast=None, slow=None, lookback=None, mamode=None, offset=None, **kwargs):
|
||||
"""Indicator: Archer Moving Averages Trends (AMAT)"""
|
||||
# Validate Arguments
|
||||
fast = int(fast) if fast and fast > 0 else 8
|
||||
|
||||
@@ -5,7 +5,7 @@ from pandas_ta.utils import get_offset, verify_series
|
||||
from pandas_ta.utils import recent_maximum_index, recent_minimum_index
|
||||
|
||||
|
||||
def aroon(high, low, length=None, scalar=None, offset=None, **kwargs):
|
||||
def aroon(high, low, length=None, scalar=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Aroon & Aroon Oscillator"""
|
||||
# Validate Arguments
|
||||
length = length if length and length > 0 else 14
|
||||
@@ -13,11 +13,12 @@ def aroon(high, low, length=None, scalar=None, offset=None, **kwargs):
|
||||
high = verify_series(high, length)
|
||||
low = verify_series(low, length)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if high is None or low is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import AROON, AROONOSC
|
||||
aroon_down, aroon_up = AROON(high, low, length)
|
||||
aroon_osc = AROONOSC(high, low, length)
|
||||
@@ -94,6 +95,8 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 14
|
||||
scalar (float): How much to magnify. Default: 100
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -4,7 +4,7 @@ from pandas_ta.volatility import atr
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def cksp(high, low, close, p=None, x=None, q=None, offset=None, tvmode=None, **kwargs):
|
||||
def cksp(high, low, close, p=None, x=None, q=None, tvmode=None, offset=None, **kwargs):
|
||||
"""Indicator: Chande Kroll Stop (CKSP)"""
|
||||
# Validate Arguments
|
||||
# TV defaults=(10,1,9), book defaults = (10,3,20)
|
||||
@@ -23,7 +23,7 @@ def cksp(high, low, close, p=None, x=None, q=None, offset=None, tvmode=None, **k
|
||||
mamode = "rma" if tvmode is True else "sma"
|
||||
|
||||
# Calculate Result
|
||||
atr_ = atr(high=high, low=low, close=close, length=p, mamode = mamode)
|
||||
atr_ = atr(high=high, low=low, close=close, length=p, mamode=mamode)
|
||||
|
||||
long_stop_ = high.rolling(p).max() - x * atr_
|
||||
long_stop = long_stop_.rolling(q).max()
|
||||
@@ -90,8 +90,8 @@ Args:
|
||||
p (int): ATR and first stop period. Default: 10 in both modes
|
||||
x (float): ATR scalar. Default: 1 in TV mode, 3 otherwise
|
||||
q (int): Second stop period. Default: 9 in TV mode, 20 otherwise
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
tvmode (bool): Trading View or book implementation mode. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
fillna (value, optional): pd.DataFrame.fillna(value)
|
||||
|
||||
@@ -63,7 +63,7 @@ Calculation:
|
||||
Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 1
|
||||
mamode (str): Option "exponential" ("exp"). Default: 'linear' or None
|
||||
mode (str): If 'exp' then "exponential" decay. Default: 'linear'
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -93,7 +93,7 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 10
|
||||
c (int): Multiplier. Default: 4
|
||||
mamode (str): Two options: None or 'ema'. Default: 'ema'
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'sma'
|
||||
drift (int): The difference period. Default: 1
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from pandas_ta.overlap import ma
|
||||
from pandas_ta.utils import get_drift, get_offset, verify_series
|
||||
|
||||
|
||||
def atr(high, low, close, length=None, mamode=None, drift=None, offset=None, **kwargs):
|
||||
def atr(high, low, close, length=None, mamode=None, talib=None, drift=None, offset=None, **kwargs):
|
||||
"""Indicator: Average True Range (ATR)"""
|
||||
# Validate arguments
|
||||
length = int(length) if length and length > 0 else 14
|
||||
@@ -15,11 +15,12 @@ def atr(high, low, close, length=None, mamode=None, drift=None, offset=None, **k
|
||||
close = verify_series(close, length)
|
||||
drift = get_drift(drift)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if high is None or low is None or close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import ATR
|
||||
atr = ATR(high, low, close, length)
|
||||
else:
|
||||
@@ -83,7 +84,9 @@ Args:
|
||||
low (pd.Series): Series of 'low's
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): It's period. Default: 14
|
||||
mamode (str): "sma", "ema", "wma" or "rma". Default: "rma"
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'rma'
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
drift (int): The difference period. Default: 1
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from pandas_ta.statistics import stdev
|
||||
from pandas_ta.utils import get_offset, non_zero_range, tal_ma, verify_series
|
||||
|
||||
|
||||
def bbands(close, length=None, std=None, mamode=None, ddof=0, offset=None, **kwargs):
|
||||
def bbands(close, length=None, std=None, ddof=0, mamode=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Bollinger Bands (BBANDS)"""
|
||||
# Validate arguments
|
||||
length = int(length) if length and length > 0 else 5
|
||||
@@ -15,11 +15,12 @@ def bbands(close, length=None, std=None, mamode=None, ddof=0, offset=None, **kwa
|
||||
ddof = int(ddof) if ddof >= 0 and ddof < length else 1
|
||||
close = verify_series(close, length)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import BBANDS
|
||||
upper, mid, lower = BBANDS(close, length, std, std, tal_ma(mamode))
|
||||
else:
|
||||
@@ -108,8 +109,10 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): The short period. Default: 5
|
||||
std (int): The long period. Default: 2
|
||||
mamode (str): Two options: "sma" or "ema". Default: "sma"
|
||||
ddof (int): Degrees of Freedom to use. Default: 0
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'sma'
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -100,7 +100,7 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): The short period. Default: 20
|
||||
scalar (float): A positive float to scale the bands. Default: 2
|
||||
mamode (str): Two options: "sma" or "ema". Default: "ema"
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'ema'
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -4,7 +4,7 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_drift, get_offset, verify_series
|
||||
|
||||
|
||||
def natr(high, low, close, length=None, mamode=None, scalar=None, drift=None, offset=None, **kwargs):
|
||||
def natr(high, low, close, length=None, scalar=None, mamode=None, talib=None, drift=None, offset=None, **kwargs):
|
||||
"""Indicator: Normalized Average True Range (NATR)"""
|
||||
# Validate arguments
|
||||
length = int(length) if length and length > 0 else 14
|
||||
@@ -15,11 +15,12 @@ def natr(high, low, close, length=None, mamode=None, scalar=None, drift=None, of
|
||||
close = verify_series(close, length)
|
||||
drift = get_drift(drift)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if high is None or low is None or close is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import NATR
|
||||
natr = NATR(high, low, close, length)
|
||||
else:
|
||||
@@ -63,6 +64,9 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): The short period. Default: 20
|
||||
scalar (float): How much to magnify. Default: 100
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'ema'
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -101,10 +101,10 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
length (int): The short period. Default: 14
|
||||
scalar (float): A positive float to scale the bands. Default: 100
|
||||
mamode (str): Options: 'sma' or 'ema'. Default: 'sma'
|
||||
refined (bool): Use 'refined' calculation which is the average of
|
||||
RVI(high) and RVI(low) instead of RVI(close). Default: False
|
||||
thirds (bool): Average of high, low and close. Default: False
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'ema'
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -112,8 +112,8 @@ Args:
|
||||
long(int): The buy factor
|
||||
short(float): The sell factor
|
||||
length (int): The period. Default: 20
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'ema'
|
||||
drift (int): The diff period. Default: 1
|
||||
mamode (str): Three options: "ema", "sma", or "hma". Default: "ema"
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -5,7 +5,7 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_drift, get_offset, non_zero_range, verify_series
|
||||
|
||||
|
||||
def true_range(high, low, close, drift=None, offset=None, **kwargs):
|
||||
def true_range(high, low, close, talib=None, drift=None, offset=None, **kwargs):
|
||||
"""Indicator: True Range"""
|
||||
# Validate arguments
|
||||
high = verify_series(high)
|
||||
@@ -13,9 +13,10 @@ def true_range(high, low, close, drift=None, offset=None, **kwargs):
|
||||
close = verify_series(close)
|
||||
drift = get_drift(drift)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import TRANGE
|
||||
true_range = TRANGE(high, low, close)
|
||||
else:
|
||||
@@ -63,6 +64,8 @@ Args:
|
||||
high (pd.Series): Series of 'high's
|
||||
low (pd.Series): Series of 'low's
|
||||
close (pd.Series): Series of 'close's
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
drift (int): The shift period. Default: 1
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, non_zero_range, verify_series
|
||||
|
||||
|
||||
def ad(high, low, close, volume, open_=None, offset=None, **kwargs):
|
||||
def ad(high, low, close, volume, open_=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Accumulation/Distribution (AD)"""
|
||||
# Validate Arguments
|
||||
high = verify_series(high)
|
||||
@@ -11,9 +11,10 @@ def ad(high, low, close, volume, open_=None, offset=None, **kwargs):
|
||||
close = verify_series(close)
|
||||
volume = verify_series(volume)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import AD
|
||||
ad = AD(high, low, close, volume)
|
||||
else:
|
||||
@@ -70,6 +71,8 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
volume (pd.Series): Series of 'volume's
|
||||
open (pd.Series): Series of 'open's
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -5,7 +5,7 @@ from pandas_ta.overlap import ema
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def adosc(high, low, close, volume, open_=None, fast=None, slow=None, offset=None, **kwargs):
|
||||
def adosc(high, low, close, volume, open_=None, fast=None, slow=None, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: Accumulation/Distribution Oscillator"""
|
||||
# Validate Arguments
|
||||
fast = int(fast) if fast and fast > 0 else 3
|
||||
@@ -17,11 +17,12 @@ def adosc(high, low, close, volume, open_=None, fast=None, slow=None, offset=Non
|
||||
volume = verify_series(volume, _length)
|
||||
offset = get_offset(offset)
|
||||
if "length" in kwargs: kwargs.pop("length")
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if high is None or low is None or close is None or volume is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import ADOSC
|
||||
adosc = ADOSC(high, low, close, volume, fast, slow)
|
||||
else:
|
||||
@@ -74,6 +75,8 @@ Args:
|
||||
volume (pd.Series): Series of 'volume's
|
||||
fast (int): The short period. Default: 12
|
||||
slow (int): The long period. Default: 26
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -6,7 +6,7 @@ from pandas_ta.trend import long_run, short_run
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def aobv(close, volume, fast=None, slow=None, mamode=None, max_lookback=None, min_lookback=None, offset=None, **kwargs):
|
||||
def aobv(close, volume, fast=None, slow=None, max_lookback=None, min_lookback=None, mamode=None, offset=None, **kwargs):
|
||||
"""Indicator: Archer On Balance Volume (AOBV)"""
|
||||
# Validate arguments
|
||||
fast = int(fast) if fast and fast > 0 else 4
|
||||
|
||||
@@ -3,7 +3,7 @@ from pandas_ta.overlap import ma
|
||||
from pandas_ta.utils import get_drift, get_offset, verify_series
|
||||
|
||||
|
||||
def efi(close, volume, length=None, drift=None, mamode=None, offset=None, **kwargs):
|
||||
def efi(close, volume, length=None, mamode=None, drift=None, offset=None, **kwargs):
|
||||
"""Indicator: Elder's Force Index (EFI)"""
|
||||
# Validate arguments
|
||||
length = int(length) if length and length > 0 else 13
|
||||
@@ -63,7 +63,7 @@ Args:
|
||||
volume (pd.Series): Series of 'volume's
|
||||
length (int): The short period. Default: 13
|
||||
drift (int): The diff period. Default: 1
|
||||
mamode (str): Two options: None or "sma". Default: None
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'ema'
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -82,7 +82,7 @@ Args:
|
||||
fast (int): The fast period. Default: 34
|
||||
long (int): The long period. Default: 55
|
||||
length_sig (int): The signal period. Default: 13
|
||||
mamode (str): "sma", "ema", "wma" or "rma". Default: "ema"
|
||||
mamode (str): See ```help(ta.ma)```. Default: 'ema'
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -5,7 +5,7 @@ from pandas_ta.overlap import hlc3
|
||||
from pandas_ta.utils import get_drift, get_offset, verify_series
|
||||
|
||||
|
||||
def mfi(high, low, close, volume, length=None, drift=None, offset=None, **kwargs):
|
||||
def mfi(high, low, close, volume, length=None, talib=None, drift=None, offset=None, **kwargs):
|
||||
"""Indicator: Money Flow Index (MFI)"""
|
||||
# Validate arguments
|
||||
length = int(length) if length and length > 0 else 14
|
||||
@@ -15,11 +15,12 @@ def mfi(high, low, close, volume, length=None, drift=None, offset=None, **kwargs
|
||||
volume = verify_series(volume, length)
|
||||
drift = get_drift(drift)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
if high is None or low is None or close is None or volume is None: return
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import MFI
|
||||
mfi = MFI(high, low, close, volume, length)
|
||||
else:
|
||||
@@ -84,6 +85,8 @@ Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
volume (pd.Series): Series of 'volume's
|
||||
length (int): The sum period. Default: 14
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
drift (int): The difference period. Default: 1
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
|
||||
@@ -3,15 +3,16 @@ from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, signed_series, verify_series
|
||||
|
||||
|
||||
def obv(close, volume, offset=None, **kwargs):
|
||||
def obv(close, volume, talib=None, offset=None, **kwargs):
|
||||
"""Indicator: On Balance Volume (OBV)"""
|
||||
# Validate arguments
|
||||
close = verify_series(close)
|
||||
volume = verify_series(volume)
|
||||
offset = get_offset(offset)
|
||||
mode_tal = bool(talib) if isinstance(talib, bool) else True
|
||||
|
||||
# Calculate Result
|
||||
if Imports["talib"]:
|
||||
if Imports["talib"] and mode_tal:
|
||||
from talib import OBV
|
||||
obv = OBV(close, volume)
|
||||
else:
|
||||
@@ -53,6 +54,8 @@ Calculation:
|
||||
Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
volume (pd.Series): Series of 'volume's
|
||||
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
|
||||
version. Default: True
|
||||
offset (int): How many periods to offset the result. Default: 0
|
||||
|
||||
Kwargs:
|
||||
|
||||
@@ -19,7 +19,7 @@ setup(
|
||||
"pandas_ta.volatility",
|
||||
"pandas_ta.volume"
|
||||
],
|
||||
version=".".join(("0", "3", "06b")),
|
||||
version=".".join(("0", "3", "07b")),
|
||||
description=long_description,
|
||||
long_description=long_description,
|
||||
author="Kevin Johnson",
|
||||
|
||||
@@ -58,7 +58,7 @@ class TestCandle(TestCase):
|
||||
try:
|
||||
expected = tal.CDLDOJI(self.open, self.high, self.low, self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
|
||||
@@ -65,60 +65,72 @@ class TestMomentum(TestCase):
|
||||
self.assertEqual(result.name, "AO_5_34")
|
||||
|
||||
def test_apo(self):
|
||||
result = pandas_ta.apo(self.close)
|
||||
result = pandas_ta.apo(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "APO_12_26")
|
||||
|
||||
try:
|
||||
expected = tal.APO(self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.apo(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "APO_12_26")
|
||||
|
||||
def test_bias(self):
|
||||
result = pandas_ta.bias(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "BIAS_SMA_26")
|
||||
|
||||
def test_bop(self):
|
||||
result = pandas_ta.bop(self.open, self.high, self.low, self.close)
|
||||
result = pandas_ta.bop(self.open, self.high, self.low, self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "BOP")
|
||||
|
||||
try:
|
||||
expected = tal.BOP(self.open, self.high, self.low, self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.bop(self.open, self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "BOP")
|
||||
|
||||
def test_brar(self):
|
||||
result = pandas_ta.brar(self.open, self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "BRAR_26")
|
||||
|
||||
def test_cci(self):
|
||||
result = pandas_ta.cci(self.high, self.low, self.close)
|
||||
result = pandas_ta.cci(self.high, self.low, self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "CCI_14_0.015")
|
||||
|
||||
try:
|
||||
expected = tal.CCI(self.high, self.low, self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.cci(self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "CCI_14_0.015")
|
||||
|
||||
def test_cfo(self):
|
||||
result = pandas_ta.cfo(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
@@ -137,19 +149,16 @@ class TestMomentum(TestCase):
|
||||
try:
|
||||
expected = tal.CMO(self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
def test_cmo_no_talib(self):
|
||||
result = pandas_ta.cmo(self.close, talib=False)
|
||||
|
||||
talib_result = tal.CMO(self.close)
|
||||
corr = pandas_ta.utils.df_error_analysis(result, talib_result, col=CORRELATION)
|
||||
self.assertLess(corr, CORRELATION_THRESHOLD)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "CMO_14")
|
||||
|
||||
def test_coppock(self):
|
||||
result = pandas_ta.coppock(self.close)
|
||||
@@ -167,7 +176,7 @@ class TestMomentum(TestCase):
|
||||
self.assertEqual(result.name, "ER_10")
|
||||
|
||||
def test_dm(self):
|
||||
result = pandas_ta.dm(self.high, self.low)
|
||||
result = pandas_ta.dm(self.high, self.low, talib=False)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "DM_14")
|
||||
|
||||
@@ -176,7 +185,7 @@ class TestMomentum(TestCase):
|
||||
expected_neg = tal.MINUS_DM(self.high, self.low)
|
||||
expecteddf = DataFrame({"DMP_14": expected_pos, "DMN_14": expected_neg})
|
||||
pdt.assert_frame_equal(result, expecteddf)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
dmp = pandas_ta.utils.df_error_analysis(result.iloc[:,0], expecteddf.iloc[:,0], col=CORRELATION)
|
||||
self.assertGreater(dmp, CORRELATION_THRESHOLD)
|
||||
@@ -189,6 +198,10 @@ class TestMomentum(TestCase):
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.dm(self.high, self.low)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "DM_14")
|
||||
|
||||
def test_eri(self):
|
||||
result = pandas_ta.eri(self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
@@ -223,7 +236,7 @@ class TestMomentum(TestCase):
|
||||
self.assertEqual(result.name, "KST_10_15_20_30_10_10_10_15_9")
|
||||
|
||||
def test_macd(self):
|
||||
result = pandas_ta.macd(self.close)
|
||||
result = pandas_ta.macd(self.close, talib=False)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "MACD_12_26_9")
|
||||
|
||||
@@ -231,7 +244,7 @@ class TestMomentum(TestCase):
|
||||
expected = tal.MACD(self.close)
|
||||
expecteddf = DataFrame({"MACD_12_26_9": expected[0], "MACDh_12_26_9": expected[2], "MACDs_12_26_9": expected[1]})
|
||||
pdt.assert_frame_equal(result, expecteddf)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
macd_corr = pandas_ta.utils.df_error_analysis(result.iloc[:, 0], expecteddf.iloc[:, 0], col=CORRELATION)
|
||||
self.assertGreater(macd_corr, CORRELATION_THRESHOLD)
|
||||
@@ -250,46 +263,58 @@ class TestMomentum(TestCase):
|
||||
except Exception as ex:
|
||||
error_analysis(result.iloc[:, 2], CORRELATION, ex, newline=False)
|
||||
|
||||
result = pandas_ta.macd(self.close)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "MACD_12_26_9")
|
||||
|
||||
def test_macdas(self):
|
||||
result = pandas_ta.macd(self.close, asmode=True)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "MACDAS_12_26_9")
|
||||
|
||||
def test_mom(self):
|
||||
result = pandas_ta.mom(self.close)
|
||||
result = pandas_ta.mom(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "MOM_10")
|
||||
|
||||
try:
|
||||
expected = tal.MOM(self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.mom(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "MOM_10")
|
||||
|
||||
def test_pgo(self):
|
||||
result = pandas_ta.pgo(self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "PGO_14")
|
||||
|
||||
def test_ppo(self):
|
||||
result = pandas_ta.ppo(self.close)
|
||||
result = pandas_ta.ppo(self.close, talib=False)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "PPO_12_26_9")
|
||||
|
||||
try:
|
||||
expected = tal.PPO(self.close)
|
||||
pdt.assert_series_equal(result["PPO_12_26_9"], expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result["PPO_12_26_9"], expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result["PPO_12_26_9"], CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.ppo(self.close)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "PPO_12_26_9")
|
||||
|
||||
def test_psl(self):
|
||||
result = pandas_ta.psl(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
@@ -306,35 +331,43 @@ class TestMomentum(TestCase):
|
||||
self.assertEqual(result.name, "QQE_14_5_4.236")
|
||||
|
||||
def test_roc(self):
|
||||
result = pandas_ta.roc(self.close)
|
||||
result = pandas_ta.roc(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "ROC_10")
|
||||
|
||||
try:
|
||||
expected = tal.ROC(self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.roc(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "ROC_10")
|
||||
|
||||
def test_rsi(self):
|
||||
result = pandas_ta.rsi(self.close)
|
||||
result = pandas_ta.rsi(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "RSI_14")
|
||||
|
||||
try:
|
||||
expected = tal.RSI(self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.rsi(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "RSI_14")
|
||||
|
||||
def test_rsx(self):
|
||||
result = pandas_ta.rsx(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
@@ -418,10 +451,10 @@ class TestMomentum(TestCase):
|
||||
self.assertEqual(result.name, "STOCH_14_3_3")
|
||||
|
||||
try:
|
||||
expected = tal.STOCH(self.high, self.low, self.close, 14, 3, 0, 3)
|
||||
expecteddf = DataFrame({"STOCHk_14_3_0_3": expected[0], "STOCHd_14_3_0_3": expected[1]})
|
||||
expected = tal.STOCH(self.high, self.low, self.close, 14, 3, 0, 3, 0)
|
||||
expecteddf = DataFrame({"STOCHk_14_3_0_3_0": expected[0], "STOCHd_14_3_0_3": expected[1]})
|
||||
pdt.assert_frame_equal(result, expecteddf)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
stochk_corr = pandas_ta.utils.df_error_analysis(result.iloc[:, 0], expecteddf.iloc[:, 0], col=CORRELATION)
|
||||
self.assertGreater(stochk_corr, CORRELATION_THRESHOLD)
|
||||
@@ -444,7 +477,7 @@ class TestMomentum(TestCase):
|
||||
expected = tal.STOCHRSI(self.close, 14, 14, 3, 0)
|
||||
expecteddf = DataFrame({"STOCHRSIk_14_14_0_3": expected[0], "STOCHRSId_14_14_3_0": expected[1]})
|
||||
pdt.assert_frame_equal(result, expecteddf)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
stochrsid_corr = pandas_ta.utils.df_error_analysis(result.iloc[:, 0], expecteddf.iloc[:, 1], col=CORRELATION)
|
||||
self.assertGreater(stochrsid_corr, CORRELATION_THRESHOLD)
|
||||
@@ -469,31 +502,39 @@ class TestMomentum(TestCase):
|
||||
self.assertEqual(result.name, "TSI_13_25")
|
||||
|
||||
def test_uo(self):
|
||||
result = pandas_ta.uo(self.high, self.low, self.close)
|
||||
result = pandas_ta.uo(self.high, self.low, self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "UO_7_14_28")
|
||||
|
||||
try:
|
||||
expected = tal.ULTOSC(self.high, self.low, self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.uo(self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "UO_7_14_28")
|
||||
|
||||
def test_willr(self):
|
||||
result = pandas_ta.willr(self.high, self.low, self.close)
|
||||
result = pandas_ta.willr(self.high, self.low, self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "WILLR_14")
|
||||
|
||||
try:
|
||||
expected = tal.WILLR(self.high, self.low, self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.willr(self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "WILLR_14")
|
||||
|
||||
+102
-29
@@ -40,20 +40,24 @@ class TestOverlap(TestCase):
|
||||
self.assertEqual(result.name, "ALMA_10_6.0_0.85")
|
||||
|
||||
def test_dema(self):
|
||||
result = pandas_ta.dema(self.close)
|
||||
result = pandas_ta.dema(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "DEMA_10")
|
||||
|
||||
try:
|
||||
expected = tal.DEMA(self.close, 10)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.dema(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "DEMA_10")
|
||||
|
||||
def test_ema(self):
|
||||
result = pandas_ta.ema(self.close, presma=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
@@ -62,13 +66,30 @@ class TestOverlap(TestCase):
|
||||
try:
|
||||
expected = tal.EMA(self.close, 10)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.ema(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "EMA_10")
|
||||
|
||||
try:
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.ema(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "EMA_10")
|
||||
|
||||
def test_fwma(self):
|
||||
result = pandas_ta.fwma(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
@@ -85,20 +106,24 @@ class TestOverlap(TestCase):
|
||||
self.assertEqual(result.name, "HL2")
|
||||
|
||||
def test_hlc3(self):
|
||||
result = pandas_ta.hlc3(self.high, self.low, self.close)
|
||||
result = pandas_ta.hlc3(self.high, self.low, self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "HLC3")
|
||||
|
||||
try:
|
||||
expected = tal.TYPPRICE(self.high, self.low, self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.hlc3(self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "HLC3")
|
||||
|
||||
def test_hma(self):
|
||||
result = pandas_ta.hma(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
@@ -122,70 +147,86 @@ class TestOverlap(TestCase):
|
||||
self.assertEqual(span.name, "ICHISPAN_9_26")
|
||||
|
||||
def test_linreg(self):
|
||||
result = pandas_ta.linreg(self.close)
|
||||
result = pandas_ta.linreg(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "LR_14")
|
||||
|
||||
try:
|
||||
expected = tal.LINEARREG(self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.linreg(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "LR_14")
|
||||
|
||||
def test_linreg_angle(self):
|
||||
result = pandas_ta.linreg(self.close, angle=True)
|
||||
result = pandas_ta.linreg(self.close, angle=True, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "LRa_14")
|
||||
|
||||
try:
|
||||
expected = tal.LINEARREG_ANGLE(self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.linreg(self.close, angle=True)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "LRa_14")
|
||||
|
||||
def test_linreg_intercept(self):
|
||||
result = pandas_ta.linreg(self.close, intercept=True)
|
||||
result = pandas_ta.linreg(self.close, intercept=True, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "LRb_14")
|
||||
|
||||
try:
|
||||
expected = tal.LINEARREG_INTERCEPT(self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.linreg(self.close, intercept=True)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "LRb_14")
|
||||
|
||||
def test_linreg_r(self):
|
||||
result = pandas_ta.linreg(self.close, r=True)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "LRr_14")
|
||||
|
||||
def test_linreg_slope(self):
|
||||
result = pandas_ta.linreg(self.close, slope=True)
|
||||
result = pandas_ta.linreg(self.close, slope=True, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "LRm_14")
|
||||
|
||||
try:
|
||||
expected = tal.LINEARREG_SLOPE(self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.linreg(self.close, slope=True)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "LRm_14")
|
||||
|
||||
def test_ma(self):
|
||||
result = pandas_ta.ma()
|
||||
self.assertIsInstance(result, list)
|
||||
@@ -205,35 +246,43 @@ class TestOverlap(TestCase):
|
||||
self.assertEqual(result.name, "MCGD_10")
|
||||
|
||||
def test_midpoint(self):
|
||||
result = pandas_ta.midpoint(self.close)
|
||||
result = pandas_ta.midpoint(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "MIDPOINT_2")
|
||||
|
||||
try:
|
||||
expected = tal.MIDPOINT(self.close, 2)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.midpoint(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "MIDPOINT_2")
|
||||
|
||||
def test_midprice(self):
|
||||
result = pandas_ta.midprice(self.high, self.low)
|
||||
result = pandas_ta.midprice(self.high, self.low, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "MIDPRICE_2")
|
||||
|
||||
try:
|
||||
expected = tal.MIDPRICE(self.high, self.low, 2)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.midprice(self.high, self.low)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "MIDPRICE_2")
|
||||
|
||||
def test_ohlc4(self):
|
||||
result = pandas_ta.ohlc4(self.open, self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
@@ -255,20 +304,24 @@ class TestOverlap(TestCase):
|
||||
self.assertEqual(result.name, "SINWMA_14")
|
||||
|
||||
def test_sma(self):
|
||||
result = pandas_ta.sma(self.close)
|
||||
result = pandas_ta.sma(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "SMA_10")
|
||||
|
||||
try:
|
||||
expected = tal.SMA(self.close, 10)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.sma(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "SMA_10")
|
||||
|
||||
def test_ssf(self):
|
||||
result = pandas_ta.ssf(self.close, poles=2)
|
||||
self.assertIsInstance(result, Series)
|
||||
@@ -289,50 +342,62 @@ class TestOverlap(TestCase):
|
||||
self.assertEqual(result.name, "SUPERT_7_3.0")
|
||||
|
||||
def test_t3(self):
|
||||
result = pandas_ta.t3(self.close)
|
||||
result = pandas_ta.t3(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "T3_10_0.7")
|
||||
|
||||
try:
|
||||
expected = tal.T3(self.close, 10)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.t3(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "T3_10_0.7")
|
||||
|
||||
def test_tema(self):
|
||||
result = pandas_ta.tema(self.close)
|
||||
result = pandas_ta.tema(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "TEMA_10")
|
||||
|
||||
try:
|
||||
expected = tal.TEMA(self.close, 10)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.tema(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "TEMA_10")
|
||||
|
||||
def test_trima(self):
|
||||
result = pandas_ta.trima(self.close)
|
||||
result = pandas_ta.trima(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "TRIMA_10")
|
||||
|
||||
try:
|
||||
expected = tal.TRIMA(self.close, 10)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.trima(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "TRIMA_10")
|
||||
|
||||
def test_vidya(self):
|
||||
result = pandas_ta.vidya(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
@@ -349,35 +414,43 @@ class TestOverlap(TestCase):
|
||||
self.assertEqual(result.name, "VWMA_10")
|
||||
|
||||
def test_wcp(self):
|
||||
result = pandas_ta.wcp(self.high, self.low, self.close)
|
||||
result = pandas_ta.wcp(self.high, self.low, self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "WCP")
|
||||
|
||||
try:
|
||||
expected = tal.WCLPRICE(self.high, self.low, self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.wcp(self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "WCP")
|
||||
|
||||
def test_wma(self):
|
||||
result = pandas_ta.wma(self.close)
|
||||
result = pandas_ta.wma(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "WMA_10")
|
||||
|
||||
try:
|
||||
expected = tal.WMA(self.close, 10)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.wma(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "WMA_10")
|
||||
|
||||
def test_zlma(self):
|
||||
result = pandas_ta.zlma(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
|
||||
@@ -65,20 +65,24 @@ class TestStatistics(TestCase):
|
||||
self.assertEqual(result.name, "SKEW_30")
|
||||
|
||||
def test_stdev(self):
|
||||
result = pandas_ta.stdev(self.close)
|
||||
result = pandas_ta.stdev(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "STDEV_30")
|
||||
|
||||
try:
|
||||
expected = tal.STDDEV(self.close, 30)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.stdev(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "STDEV_30")
|
||||
|
||||
def test_tos_sdtevall(self):
|
||||
result = pandas_ta.tos_stdevall(self.close)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
@@ -96,20 +100,24 @@ class TestStatistics(TestCase):
|
||||
self.assertEqual(len(result.columns), 5)
|
||||
|
||||
def test_variance(self):
|
||||
result = pandas_ta.variance(self.close)
|
||||
result = pandas_ta.variance(self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "VAR_30")
|
||||
|
||||
try:
|
||||
expected = tal.VAR(self.close, 30)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.variance(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "VAR_30")
|
||||
|
||||
def test_zscore(self):
|
||||
result = pandas_ta.zscore(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
|
||||
@@ -35,27 +35,31 @@ class TestTrend(TestCase):
|
||||
|
||||
|
||||
def test_adx(self):
|
||||
result = pandas_ta.adx(self.high, self.low, self.close)
|
||||
result = pandas_ta.adx(self.high, self.low, self.close, talib=False)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "ADX_14")
|
||||
|
||||
try:
|
||||
expected = tal.ADX(self.high, self.low, self.close)
|
||||
pdt.assert_series_equal(result.iloc[:, 0], expected)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result.iloc[:, 0], expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.adx(self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "ADX_14")
|
||||
|
||||
def test_amat(self):
|
||||
result = pandas_ta.amat(self.close)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "AMATe_8_21_2")
|
||||
|
||||
def test_aroon(self):
|
||||
result = pandas_ta.aroon(self.high, self.low)
|
||||
result = pandas_ta.aroon(self.high, self.low, talib=False)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "AROON_14")
|
||||
|
||||
@@ -63,7 +67,7 @@ class TestTrend(TestCase):
|
||||
expected = tal.AROON(self.high, self.low)
|
||||
expecteddf = DataFrame({"AROOND_14": expected[0], "AROONU_14": expected[1]})
|
||||
pdt.assert_frame_equal(result, expecteddf)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
aroond_corr = pandas_ta.utils.df_error_analysis(result.iloc[:, 0], expecteddf.iloc[:, 0], col=CORRELATION)
|
||||
self.assertGreater(aroond_corr, CORRELATION_THRESHOLD)
|
||||
@@ -76,13 +80,19 @@ class TestTrend(TestCase):
|
||||
except Exception as ex:
|
||||
error_analysis(result.iloc[:, 1], CORRELATION, ex, newline=False)
|
||||
|
||||
result = pandas_ta.aroon(self.high, self.low)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "AROON_14")
|
||||
|
||||
def test_aroon_osc(self):
|
||||
result = pandas_ta.aroon(self.high, self.low)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "AROON_14")
|
||||
|
||||
try:
|
||||
expected = tal.AROONOSC(self.high, self.low)
|
||||
pdt.assert_series_equal(result.iloc[:, 2], expected)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
aroond_corr = pandas_ta.utils.df_error_analysis(result.iloc[:,2], expected,col=CORRELATION)
|
||||
self.assertGreater(aroond_corr, CORRELATION_THRESHOLD)
|
||||
@@ -158,7 +168,7 @@ class TestTrend(TestCase):
|
||||
try:
|
||||
expected = tal.SAR(self.high, self.low)
|
||||
pdt.assert_series_equal(psar, expected)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
psar_corr = pandas_ta.utils.df_error_analysis(psar, expected, col=CORRELATION)
|
||||
self.assertGreater(psar_corr, CORRELATION_THRESHOLD)
|
||||
|
||||
@@ -45,26 +45,26 @@ class TestVolatility(TestCase):
|
||||
self.assertEqual(result.name, "ACCBANDS_20")
|
||||
|
||||
def test_atr(self):
|
||||
result = pandas_ta.atr(self.high, self.low, self.close)
|
||||
result = pandas_ta.atr(self.high, self.low, self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "ATRr_14")
|
||||
|
||||
try:
|
||||
expected = tal.ATR(self.high, self.low, self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
def test_bbands(self):
|
||||
result = pandas_ta.bbands(self.close, ddof=0)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "BBANDS_5_2.0")
|
||||
result = pandas_ta.atr(self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "ATRr_14")
|
||||
|
||||
result = pandas_ta.bbands(self.close, ddof=1)
|
||||
def test_bbands(self):
|
||||
result = pandas_ta.bbands(self.close, talib=False)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "BBANDS_5_2.0")
|
||||
|
||||
@@ -72,7 +72,7 @@ class TestVolatility(TestCase):
|
||||
expected = tal.BBANDS(self.close)
|
||||
expecteddf = DataFrame({"BBU_5_2.0": expected[0], "BBM_5_2.0": expected[1], "BBL_5_2.0": expected[2]})
|
||||
pdt.assert_frame_equal(result, expecteddf)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
bbl_corr = pandas_ta.utils.df_error_analysis(result.iloc[:, 0], expecteddf.iloc[:,0], col=CORRELATION)
|
||||
self.assertGreater(bbl_corr, CORRELATION_THRESHOLD)
|
||||
@@ -91,6 +91,14 @@ class TestVolatility(TestCase):
|
||||
except Exception as ex:
|
||||
error_analysis(result.iloc[:, 2], CORRELATION, ex, newline=False)
|
||||
|
||||
result = pandas_ta.bbands(self.close, ddof=0)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "BBANDS_5_2.0")
|
||||
|
||||
result = pandas_ta.bbands(self.close, ddof=1)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
self.assertEqual(result.name, "BBANDS_5_2.0")
|
||||
|
||||
def test_donchian(self):
|
||||
result = pandas_ta.donchian(self.high, self.low)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
@@ -115,20 +123,24 @@ class TestVolatility(TestCase):
|
||||
self.assertEqual(result.name, "MASSI_9_25")
|
||||
|
||||
def test_natr(self):
|
||||
result = pandas_ta.natr(self.high, self.low, self.close)
|
||||
result = pandas_ta.natr(self.high, self.low, self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "NATR_14")
|
||||
|
||||
try:
|
||||
expected = tal.NATR(self.high, self.low, self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.natr(self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "NATR_14")
|
||||
|
||||
def test_pdist(self):
|
||||
result = pandas_ta.pdist(self.open, self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
@@ -153,20 +165,24 @@ class TestVolatility(TestCase):
|
||||
self.assertEqual(result.name, "THERMO_20_2_0.5")
|
||||
|
||||
def test_true_range(self):
|
||||
result = pandas_ta.true_range(self.high, self.low, self.close)
|
||||
result = pandas_ta.true_range(self.high, self.low, self.close, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "TRUERANGE_1")
|
||||
|
||||
try:
|
||||
expected = tal.TRANGE(self.high, self.low, self.close)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.true_range(self.high, self.low, self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "TRUERANGE_1")
|
||||
|
||||
def test_ui(self):
|
||||
result = pandas_ta.ui(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
|
||||
@@ -35,40 +35,48 @@ class TestVolume(TestCase):
|
||||
|
||||
|
||||
def test_ad(self):
|
||||
result = pandas_ta.ad(self.high, self.low, self.close, self.volume_)
|
||||
result = pandas_ta.ad(self.high, self.low, self.close, self.volume_, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "AD")
|
||||
|
||||
try:
|
||||
expected = tal.AD(self.high, self.low, self.close, self.volume_)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.ad(self.high, self.low, self.close, self.volume_)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "AD")
|
||||
|
||||
def test_ad_open(self):
|
||||
result = pandas_ta.ad(self.high, self.low, self.close, self.volume_, self.open)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "ADo")
|
||||
|
||||
def test_adosc(self):
|
||||
result = pandas_ta.adosc(self.high, self.low, self.close, self.volume_)
|
||||
result = pandas_ta.adosc(self.high, self.low, self.close, self.volume_, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "ADOSC_3_10")
|
||||
|
||||
try:
|
||||
expected = tal.ADOSC(self.high, self.low, self.close, self.volume_)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.adosc(self.high, self.low, self.close, self.volume_)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "ADOSC_3_10")
|
||||
|
||||
def test_aobv(self):
|
||||
result = pandas_ta.aobv(self.close, self.volume_)
|
||||
self.assertIsInstance(result, DataFrame)
|
||||
@@ -95,40 +103,48 @@ class TestVolume(TestCase):
|
||||
self.assertEqual(result.name, "KVO_34_55_13")
|
||||
|
||||
def test_mfi(self):
|
||||
result = pandas_ta.mfi(self.high, self.low, self.close, self.volume_)
|
||||
result = pandas_ta.mfi(self.high, self.low, self.close, self.volume_, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "MFI_14")
|
||||
|
||||
try:
|
||||
expected = tal.MFI(self.high, self.low, self.close, self.volume_)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.mfi(self.high, self.low, self.close, self.volume_)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "MFI_14")
|
||||
|
||||
def test_nvi(self):
|
||||
result = pandas_ta.nvi(self.close, self.volume_)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "NVI_1")
|
||||
|
||||
def test_obv(self):
|
||||
result = pandas_ta.obv(self.close, self.volume_)
|
||||
result = pandas_ta.obv(self.close, self.volume_, talib=False)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "OBV")
|
||||
|
||||
try:
|
||||
expected = tal.OBV(self.close, self.volume_)
|
||||
pdt.assert_series_equal(result, expected, check_names=False)
|
||||
except AssertionError as ae:
|
||||
except AssertionError:
|
||||
try:
|
||||
corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
|
||||
self.assertGreater(corr, CORRELATION_THRESHOLD)
|
||||
except Exception as ex:
|
||||
error_analysis(result, CORRELATION, ex)
|
||||
|
||||
result = pandas_ta.obv(self.close, self.volume_)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "OBV")
|
||||
|
||||
def test_pvi(self):
|
||||
result = pandas_ta.pvi(self.close, self.volume_)
|
||||
self.assertIsInstance(result, Series)
|
||||
|
||||
Reference in New Issue
Block a user