Make sure use_db is set as early as possible.

This commit is contained in:
Matthias 2023-09-23 18:20:19 +02:00
parent 589b9858f4
commit 966247baaf

View File

@ -116,6 +116,7 @@ class Backtesting:
raise OperationalException("Timeframe needs to be set in either " raise OperationalException("Timeframe needs to be set in either "
"configuration or as cli argument `--timeframe 5m`") "configuration or as cli argument `--timeframe 5m`")
self.timeframe = str(self.config.get('timeframe')) self.timeframe = str(self.config.get('timeframe'))
self.disable_database_use()
self.timeframe_min = timeframe_to_minutes(self.timeframe) self.timeframe_min = timeframe_to_minutes(self.timeframe)
self.init_backtest_detail() self.init_backtest_detail()
self.pairlists = PairListManager(self.exchange, self.config, self.dataprovider) self.pairlists = PairListManager(self.exchange, self.config, self.dataprovider)
@ -318,13 +319,16 @@ class Backtesting:
else: else:
self.futures_data = {} self.futures_data = {}
def disable_database_use(self):
PairLocks.use_db = False
PairLocks.timeframe = self.timeframe
Trade.use_db = False
def prepare_backtest(self, enable_protections): def prepare_backtest(self, enable_protections):
""" """
Backtesting setup method - called once for every call to "backtest()". Backtesting setup method - called once for every call to "backtest()".
""" """
PairLocks.use_db = False self.disable_database_use()
PairLocks.timeframe = self.config['timeframe']
Trade.use_db = False
PairLocks.reset_locks() PairLocks.reset_locks()
Trade.reset_trades() Trade.reset_trades()
self.rejected_trades = 0 self.rejected_trades = 0