From cc0c466cab9ff088a618f48b7efdf93c8932bea0 Mon Sep 17 00:00:00 2001 From: Anthony Tsang Date: Thu, 21 Oct 2021 15:58:59 +0900 Subject: [PATCH] Fix required length for stoch and stochrsi --- pandas_ta/momentum/stoch.py | 2 +- pandas_ta/momentum/stochrsi.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas_ta/momentum/stoch.py b/pandas_ta/momentum/stoch.py index 823c332..b21c514 100644 --- a/pandas_ta/momentum/stoch.py +++ b/pandas_ta/momentum/stoch.py @@ -10,7 +10,7 @@ def stoch(high, low, close, k=None, d=None, smooth_k=None, mamode=None, offset=N k = k if k and k > 0 else 14 d = d if d and d > 0 else 3 smooth_k = smooth_k if smooth_k and smooth_k > 0 else 3 - _length = max(k, d, smooth_k) + _length = k + d + smooth_k high = verify_series(high, _length) low = verify_series(low, _length) close = verify_series(close, _length) diff --git a/pandas_ta/momentum/stochrsi.py b/pandas_ta/momentum/stochrsi.py index 0841484..9bd7538 100644 --- a/pandas_ta/momentum/stochrsi.py +++ b/pandas_ta/momentum/stochrsi.py @@ -12,7 +12,7 @@ def stochrsi(close, length=None, rsi_length=None, k=None, d=None, mamode=None, o rsi_length = rsi_length if rsi_length and rsi_length > 0 else 14 k = k if k and k > 0 else 3 d = d if d and d > 0 else 3 - close = verify_series(close, max(length, rsi_length, k, d)) + close = verify_series(close, length + rsi_length + k + d) offset = get_offset(offset) mamode = mamode if isinstance(mamode, str) else "sma"