Add test for backtesting dataframe cache

This commit is contained in:
Matthias 2021-07-31 08:40:57 +02:00
parent ab3c753415
commit 6abd352c0f

View File

@ -739,6 +739,9 @@ def test_backtest_alternate_buy_sell(default_conf, fee, mocker, testdatadir):
# 100 buys signals # 100 buys signals
results = result['results'] results = result['results']
assert len(results) == 100 assert len(results) == 100
# Cached data should be 200 (no change since required_startup is 0)
assert len(backtesting.dataprovider.get_analyzed_dataframe('UNITTEST/BTC', '1m')[0]) == 200
# One trade was force-closed at the end # One trade was force-closed at the end
assert len(results.loc[results['is_open']]) == 0 assert len(results.loc[results['is_open']]) == 0
@ -794,6 +797,10 @@ def test_backtest_multi_pair(default_conf, fee, mocker, tres, pair, testdatadir)
# make sure we don't have trades with more than configured max_open_trades # make sure we don't have trades with more than configured max_open_trades
assert len(evaluate_result_multi(results['results'], '5m', 3)) == 0 assert len(evaluate_result_multi(results['results'], '5m', 3)) == 0
# Cached data correctly removed amounts
removed_candles = len(data[pair]) - 1 - backtesting.strategy.startup_candle_count
assert len(backtesting.dataprovider.get_analyzed_dataframe(pair, '5m')[0]) == removed_candles
backtest_conf = { backtest_conf = {
'processed': processed, 'processed': processed,
'start_date': min_date, 'start_date': min_date,