From 4640acdc014f5fb72955ca0e186602c8d50c56f2 Mon Sep 17 00:00:00 2001 From: Saleh Mir Date: Wed, 12 Jun 2024 23:39:34 +0330 Subject: [PATCH] refactor: rename waddah_attr_explosion to waddah_attar_explosion --- jesse/indicators/__init__.py | 2 +- jesse/indicators/stiffness.py | 8 ++++---- jesse/indicators/waddah_attr_explosion.py | 18 +++++++----------- tests/test_indicators.py | 2 +- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/jesse/indicators/__init__.py b/jesse/indicators/__init__.py index 8d94a5f10..6b211802a 100644 --- a/jesse/indicators/__init__.py +++ b/jesse/indicators/__init__.py @@ -175,5 +175,5 @@ from .wt import wt from .zlema import zlema from .zscore import zscore -from .waddah_attr_explosion import waddah_attr_explosion +from .waddah_attr_explosion import waddah_attar_explosion from .stiffness import stiffness diff --git a/jesse/indicators/stiffness.py b/jesse/indicators/stiffness.py index b8e21f6e6..ff0522920 100644 --- a/jesse/indicators/stiffness.py +++ b/jesse/indicators/stiffness.py @@ -8,10 +8,10 @@ from jesse.helpers import get_candle_source, slice_candles -StiffnessTuple = namedtuple('StiffnessTuple', ['stiffness', 'threshold']) +Stiffness = namedtuple('Stiffness', ['stiffness', 'threshold']) -def stiffness(candles: np.ndarray, ma_length: int = 100, stiff_length: int = 60, stiff_smooth: int = 3, threshold: int = 90, source_type: str = "close") -> StiffnessTuple: +def stiffness(candles: np.ndarray, ma_length: int = 100, stiff_length: int = 60, stiff_smooth: int = 3, threshold: int = 90, source_type: str = "close") -> Stiffness: """ @author daviddtech credits: https://www.tradingview.com/script/MOw6mUQl-Stiffness-Indicator-DaviddTech @@ -25,7 +25,7 @@ def stiffness(candles: np.ndarray, ma_length: int = 100, stiff_length: int = 60, :param threshold: int - default: 90 :param source_type: str - default: "close" - :return: StiffnessTuple(stiffness, threshold) + :return: Stiffness(stiffness, threshold) """ if len(candles.shape) == 1: source = candles @@ -38,7 +38,7 @@ def stiffness(candles: np.ndarray, ma_length: int = 100, stiff_length: int = 60, sum_above_stiffness = _count_price_exceed_series(source, bound_stiffness, stiff_length) stiffness = ema(np.array(sum_above_stiffness) * 100 / stiff_length, period=stiff_smooth) - return StiffnessTuple(stiffness, threshold) + return Stiffness(stiffness, threshold) def _count_price_exceed_series(close_prices, art_series, length): diff --git a/jesse/indicators/waddah_attr_explosion.py b/jesse/indicators/waddah_attr_explosion.py index 8b4a42ca8..b9a8bdedc 100644 --- a/jesse/indicators/waddah_attr_explosion.py +++ b/jesse/indicators/waddah_attr_explosion.py @@ -1,23 +1,21 @@ from collections import namedtuple - from .macd import macd from .sma import sma from .stddev import stddev - import numpy as np -import jesse.helpers as jh from jesse.helpers import get_candle_source, slice_candles -WaddahATTRExplosionTuple = namedtuple('WaddahATTRExplosionTuple', [ - 'explosion_line', 'trend_power', 'trend_direction']) +WaddahAttarExplosionTuple = namedtuple( + 'WaddahAttarExplosionTuple', ['explosion_line', 'trend_power', 'trend_direction'] +) -def waddah_attr_explosion(candles: np.ndarray, sensitivity: int = 150, fast_length: int = 20, slow_length: int = 40, channel_length: int = 20, mult: float = 2.0, source_type: str = "close") -> WaddahATTRExplosionTuple: +def waddah_attar_explosion(candles: np.ndarray, sensitivity: int = 150, fast_length: int = 20, slow_length: int = 40, channel_length: int = 20, mult: float = 2.0, source_type: str = "close") -> WaddahAttarExplosionTuple: """ @author LazyBear credits: https://www.tradingview.com/v/iu3kKWDI/ - WADDAH_ATTR_EXPLOSION - Waddah ATTR Explosion + WADDAH_ATTAR_EXPLOSION - Waddah Attar Explosion :param candles: np.ndarray :param sensitivity: int - default: 150 @@ -26,11 +24,9 @@ def waddah_attr_explosion(candles: np.ndarray, sensitivity: int = 150, fast_leng :param channel_length: int - default: 20 :param mult: float - default: 2.0 :param source_type: str - default: "close" - :param sequential: bool - default: False - :return: WaddahATTRExplosionTuple(explosion_line, trend_power, trend_direction) + :return: WaddahAttarExplosionTuple(explosion_line, trend_power, trend_direction) """ - jh.dump(candles) if len(candles.shape) == 1: source = candles else: @@ -42,7 +38,7 @@ def waddah_attr_explosion(candles: np.ndarray, sensitivity: int = 150, fast_leng trend = 1 if t1 >= 0 else -1 e1 = _calc_bb_upper(source, channel_length, mult) - _calc_bb_lower(source, channel_length, mult) - return WaddahATTRExplosionTuple(e1, t1, trend) + return WaddahAttarExplosionTuple(e1, t1, trend) def _calc_bb_upper(source, length, mult): diff --git a/tests/test_indicators.py b/tests/test_indicators.py index c9b47045d..050a1ce3c 100644 --- a/tests/test_indicators.py +++ b/tests/test_indicators.py @@ -2338,7 +2338,7 @@ def test_zscore(): def test_waddah_attr_explosion(): candles = np.array(test_candles_19) - single = ta.waddah_attr_explosion(candles) + single = ta.waddah_attar_explosion(candles) assert round(single[0]) == 135 assert round(single[1]) == -827