Update backtesting test

Had bad behavior before, and didn't properly test what it was supposed to
This commit is contained in:
Matthias 2022-11-05 17:02:18 +01:00
parent 6e09d552ac
commit 25b8d34fe2

View File

@ -788,13 +788,14 @@ def test_backtest_one(default_conf, fee, mocker, testdatadir) -> None:
assert len(t['orders']) == 2 assert len(t['orders']) == 2
ln = data_pair.loc[data_pair["date"] == t["open_date"]] ln = data_pair.loc[data_pair["date"] == t["open_date"]]
# Check open trade rate alignes to open rate # 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) 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 # check close trade rate alignes to close rate or is between high and low
ln = data_pair.loc[data_pair["date"] == t["close_date"]] ln1 = data_pair.loc[data_pair["date"] == t["close_date"]]
assert (round(ln.iloc[0]["open"], 6) == round(t["close_rate"], 6) or assert not ln1.empty
round(ln.iloc[0]["low"], 6) < round( assert (round(ln1.iloc[0]["open"], 6) == round(t["close_rate"], 6) or
t["close_rate"], 6) < round(ln.iloc[0]["high"], 6)) 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: def test_backtest_timedout_entry_orders(default_conf, fee, mocker, testdatadir) -> None: