diff --git a/tests/optimize/test_backtesting.py b/tests/optimize/test_backtesting.py index 290e08455..140cc3394 100644 --- a/tests/optimize/test_backtesting.py +++ b/tests/optimize/test_backtesting.py @@ -788,13 +788,14 @@ def test_backtest_one(default_conf, fee, mocker, testdatadir) -> None: assert len(t['orders']) == 2 ln = data_pair.loc[data_pair["date"] == t["open_date"]] # Check open trade rate alignes to open rate - assert ln is not None + assert not ln.empty assert round(ln.iloc[0]["open"], 6) == round(t["open_rate"], 6) # check close trade rate alignes to close rate or is between high and low - ln = data_pair.loc[data_pair["date"] == t["close_date"]] - assert (round(ln.iloc[0]["open"], 6) == round(t["close_rate"], 6) or - round(ln.iloc[0]["low"], 6) < round( - t["close_rate"], 6) < round(ln.iloc[0]["high"], 6)) + ln1 = data_pair.loc[data_pair["date"] == t["close_date"]] + assert not ln1.empty + assert (round(ln1.iloc[0]["open"], 6) == round(t["close_rate"], 6) or + round(ln1.iloc[0]["low"], 6) < round( + t["close_rate"], 6) < round(ln1.iloc[0]["high"], 6)) def test_backtest_timedout_entry_orders(default_conf, fee, mocker, testdatadir) -> None: