Skip to content

Commit

Permalink
X5: handle error in Stochastic calculation if not enough 1d data.
Browse files Browse the repository at this point in the history
  • Loading branch information
iterativv committed Nov 26, 2024
1 parent 104ae77 commit c1e7992
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions NostalgiaForInfinityX5.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class NostalgiaForInfinityX5(IStrategy):
INTERFACE_VERSION = 3

def version(self) -> str:
return "v15.1.241"
return "v15.1.242"

stoploss = -0.99

Expand Down Expand Up @@ -2119,9 +2119,13 @@ def informative_1d_indicators(self, metadata: dict, info_timeframe) -> DataFrame
informative_1d["AROONU_14"] = aroon_14["AROONU_14"] if isinstance(aroon_14, pd.DataFrame) else np.nan
informative_1d["AROOND_14"] = aroon_14["AROOND_14"] if isinstance(aroon_14, pd.DataFrame) else np.nan
# Stochastic
stochrsi = pta.stoch(informative_1d["high"], informative_1d["low"], informative_1d["close"])
informative_1d["STOCHk_14_3_3"] = stochrsi["STOCHk_14_3_3"] if isinstance(stochrsi, pd.DataFrame) else np.nan
informative_1d["STOCHd_14_3_3"] = stochrsi["STOCHd_14_3_3"] if isinstance(stochrsi, pd.DataFrame) else np.nan
try:
stochrsi = pta.stoch(informative_1d["high"], informative_1d["low"], informative_1d["close"])
informative_1d["STOCHk_14_3_3"] = stochrsi["STOCHk_14_3_3"] if isinstance(stochrsi, pd.DataFrame) else np.nan
informative_1d["STOCHd_14_3_3"] = stochrsi["STOCHd_14_3_3"] if isinstance(stochrsi, pd.DataFrame) else np.nan
except AttributeError:
informative_1d["STOCHk_14_3_3"] = np.nan
informative_1d["STOCHd_14_3_3"] = np.nan
# Stochastic RSI
stochrsi = pta.stochrsi(informative_1d["close"])
informative_1d["STOCHRSIk_14_14_3_3"] = (
Expand Down

0 comments on commit c1e7992

Please sign in to comment.