This commit is contained in:
ran 2017-10-31 21:57:58 +02:00 committed by gcarq
parent 2b74982a1d
commit 61f92b7460

View File

@ -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()
# ---------------------------------------------