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":
assert log_has_re("=> found lookahead in indicator rsi", caplog)
else:
diff_pct = abs(float(instance.dict_recursive['rsi'][100].replace("%", "")))
# check non-biased strategy
if scenario == "no_bias":
assert diff_pct < 0.01
# check biased strategy
elif scenario == "bias1":
elif scenario in ("bias1", "bias2"):
assert diff_pct >= 0.01

View File

@ -28,10 +28,12 @@ class strategy_test_v3_recursive_issue(IStrategy):
# bias is introduced here
if self.scenario.value == 'no_bias':
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
elif self.scenario.value == 'bias1':
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=50)
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