mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-14 12:13:57 +00:00
reduce duplicated code
This commit is contained in:
parent
b383654378
commit
630cdcb99f
|
@ -169,11 +169,7 @@ class FreqaiDataDrawer:
|
|||
|
||||
if exists:
|
||||
try:
|
||||
for file_path in self.historic_predictions_folder.glob("*.parquet"):
|
||||
key = file_path.stem
|
||||
key.replace("_", "/")
|
||||
self.historic_predictions[key] = pd.read_parquet(file_path)
|
||||
|
||||
self.load_historic_predictions_from_folder()
|
||||
logger.info(
|
||||
f"Found existing historic predictions at {self.full_path}, but beware "
|
||||
"that statistics may be inaccurate if the bot has been offline for "
|
||||
|
@ -182,10 +178,7 @@ class FreqaiDataDrawer:
|
|||
except EOFError:
|
||||
logger.warning(
|
||||
'Historical prediction files were corrupted. Trying to load backup files.')
|
||||
for file_path in self.historic_predictions_folder.glob("*.parquet"):
|
||||
key = file_path.stem
|
||||
key.replace("_", "/")
|
||||
self.historic_predictions[key] = pd.read_parquet(file_path)
|
||||
self.load_historic_predictions_from_folder()
|
||||
logger.warning('FreqAI successfully loaded the backup '
|
||||
'historical predictions files.')
|
||||
|
||||
|
@ -205,6 +198,18 @@ class FreqaiDataDrawer:
|
|||
|
||||
return exists
|
||||
|
||||
def load_historic_predictions_from_folder(self):
|
||||
"""
|
||||
Try to build the historic_predictions dictionary from parquet
|
||||
files in the historic_predictions_folder
|
||||
"""
|
||||
for file_path in self.historic_predictions_folder.glob("*.parquet"):
|
||||
key = file_path.stem
|
||||
key.replace("_", "/")
|
||||
self.historic_predictions[key] = pd.read_parquet(file_path)
|
||||
|
||||
return
|
||||
|
||||
def save_historic_predictions_to_disk(self):
|
||||
"""
|
||||
Save historic predictions pickle to disk
|
||||
|
|
Loading…
Reference in New Issue
Block a user