Further update test a bit

This commit is contained in:
Matthias 2023-09-29 07:09:48 +02:00
parent 20ea679b2b
commit 92d7f27983
2 changed files with 12 additions and 11 deletions

View File

@ -179,11 +179,10 @@ def test_recursive_biased_strategy(recursive_conf, mocker, caplog, scenario) ->
if scenario == "bias2": if scenario == "bias2":
assert log_has_re("=> found lookahead in indicator rsi", caplog) assert log_has_re("=> found lookahead in indicator rsi", caplog)
else: diff_pct = abs(float(instance.dict_recursive['rsi'][100].replace("%", "")))
diff_pct = abs(float(instance.dict_recursive['rsi'][100].replace("%", ""))) # check non-biased strategy
# check non-biased strategy if scenario == "no_bias":
if scenario == "no_bias": assert diff_pct < 0.01
assert diff_pct < 0.01 # check biased strategy
# check biased strategy elif scenario in ("bias1", "bias2"):
elif scenario == "bias1": assert diff_pct >= 0.01
assert diff_pct >= 0.01

View File

@ -28,10 +28,12 @@ class strategy_test_v3_recursive_issue(IStrategy):
# bias is introduced here # bias is introduced here
if self.scenario.value == 'no_bias': if self.scenario.value == 'no_bias':
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14) dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
elif self.scenario.value == 'bias1':
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=50)
else: else:
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=50).shift(-1) dataframe['rsi'] = ta.RSI(dataframe, timeperiod=50)
if self.scenario.value == 'bias2':
# Has both bias1 and bias2
dataframe['rsi_lookahead'] = ta.RSI(dataframe, timeperiod=50).shift(-1)
return dataframe return dataframe