Skip to content

Commit

Permalink
refactor: rename waddah_attr_explosion to waddah_attar_explosion
Browse files Browse the repository at this point in the history
  • Loading branch information
saleh-mir committed Jun 12, 2024
1 parent 1e868c2 commit 4640acd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion jesse/indicators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions jesse/indicators/stiffness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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):
Expand Down
18 changes: 7 additions & 11 deletions jesse/indicators/waddah_attr_explosion.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4640acd

Please sign in to comment.