fix bug with database url during backtesting. comment out example trade db analysis.

This commit is contained in:
robcaulk 2022-08-03 16:17:57 +02:00
parent 95d3009a95
commit eae82d0222
2 changed files with 9 additions and 8 deletions

View File

@ -85,9 +85,10 @@ class FreqaiDataKitchen:
config["freqai"]["backtest_period_days"], config["freqai"]["backtest_period_days"],
) )
db_url = self.config.get('db_url', None) if self.live:
self.database_path = '' if db_url == 'sqlite://' else str(db_url).split('///')[1] db_url = self.config.get('db_url', 'sqlite://')
self.trade_database_df: DataFrame = pd.DataFrame() self.database_path = '' if db_url == 'sqlite://' else str(db_url).split('///')[1]
self.trade_database_df: DataFrame = pd.DataFrame()
self.data['extra_returns_per_train'] = self.freqai_config.get('extra_returns_per_train', {}) self.data['extra_returns_per_train'] = self.freqai_config.get('extra_returns_per_train', {})

View File

@ -615,11 +615,11 @@ class IFreqaiModel(ABC):
they will format themselves into the dataframe as an additional column in the user they will format themselves into the dataframe as an additional column in the user
strategy. User has access to the current trade database in dk.trade_database_df. strategy. User has access to the current trade database in dk.trade_database_df.
""" """
if dk.trade_database_df.empty: # if dk.trade_database_df.empty:
logger.warning(f'No trades found for {pair} to analyze DB') # logger.warning(f'No trades found for {pair} to analyze DB')
return # return
total_profit = dk.trade_database_df['close_profit_abs'].sum() # total_profit = dk.trade_database_df['close_profit_abs'].sum()
dk.data['extra_returns_per_train']['total_profit'] = total_profit # dk.data['extra_returns_per_train']['total_profit'] = total_profit
return return