diff --git a/freqtrade/vendor/qtpylib/indicators.py b/freqtrade/vendor/qtpylib/indicators.py index ee1f14e1f..c4b955626 100644 --- a/freqtrade/vendor/qtpylib/indicators.py +++ b/freqtrade/vendor/qtpylib/indicators.py @@ -248,45 +248,34 @@ def crossed_below(series1, series2): def rolling_std(series, window=200, min_periods=None): min_periods = window if min_periods is None else min_periods - try: - if min_periods == window: - return numpy_rolling_std(series, window, True) - else: - try: - return series.rolling(window=window, min_periods=min_periods).std() - except BaseException: - return pd.Series(series).rolling(window=window, min_periods=min_periods).std() - except BaseException: - return pd.rolling_std(series, window=window, min_periods=min_periods) - + if min_periods == window and len(series) > window: + return numpy_rolling_std(series, window, True) + else: + try: + return series.rolling(window=window, min_periods=min_periods).std() + except BaseException: + return pd.Series(series).rolling(window=window, min_periods=min_periods).std() # --------------------------------------------- def rolling_mean(series, window=200, min_periods=None): min_periods = window if min_periods is None else min_periods - try: - if min_periods == window: - return numpy_rolling_mean(series, window, True) - else: - try: - return series.rolling(window=window, min_periods=min_periods).mean() - except BaseException: - return pd.Series(series).rolling(window=window, min_periods=min_periods).mean() - except BaseException: - return pd.rolling_mean(series, window=window, min_periods=min_periods) - + if min_periods == window and len(series) > window: + return numpy_rolling_mean(series, window, True) + else: + try: + return series.rolling(window=window, min_periods=min_periods).mean() + except BaseException: + return pd.Series(series).rolling(window=window, min_periods=min_periods).mean() # --------------------------------------------- def rolling_min(series, window=14, min_periods=None): min_periods = window if min_periods is None else min_periods try: - try: - return series.rolling(window=window, min_periods=min_periods).min() - except BaseException: - return pd.Series(series).rolling(window=window, min_periods=min_periods).min() + return series.rolling(window=window, min_periods=min_periods).min() except BaseException: - return pd.rolling_min(series, window=window, min_periods=min_periods) + return pd.Series(series).rolling(window=window, min_periods=min_periods).min() # --------------------------------------------- @@ -294,12 +283,9 @@ def rolling_min(series, window=14, min_periods=None): def rolling_max(series, window=14, min_periods=None): min_periods = window if min_periods is None else min_periods try: - try: - return series.rolling(window=window, min_periods=min_periods).min() - except BaseException: - return pd.Series(series).rolling(window=window, min_periods=min_periods).min() + return series.rolling(window=window, min_periods=min_periods).min() except BaseException: - return pd.rolling_min(series, window=window, min_periods=min_periods) + return pd.Series(series).rolling(window=window, min_periods=min_periods).min() # ---------------------------------------------