Fix saving/loading historic predictions
This commit is contained in:
parent
8ce6b18318
commit
fea63fba12
@ -1,13 +1,13 @@
|
|||||||
import collections
|
import collections
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import pickle
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, Tuple
|
from typing import Any, Dict, Tuple
|
||||||
|
|
||||||
# import pickle as pk
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
@ -78,8 +78,8 @@ class FreqaiDataDrawer:
|
|||||||
"""
|
"""
|
||||||
exists = Path(self.full_path / str("historic_predictions.json")).resolve().exists()
|
exists = Path(self.full_path / str("historic_predictions.json")).resolve().exists()
|
||||||
if exists:
|
if exists:
|
||||||
with open(self.full_path / str("historic_predictions.json"), "r") as fp:
|
with open(self.full_path / str("historic_predictions.pkl"), "rb") as fp:
|
||||||
self.pair_dict = json.load(fp)
|
self.historic_predictions = pickle.load(fp)
|
||||||
logger.info(f"Found existing historic predictions at {self.full_path}, but beware of "
|
logger.info(f"Found existing historic predictions at {self.full_path}, but beware of "
|
||||||
"that statistics may be inaccurate if the bot has been offline for "
|
"that statistics may be inaccurate if the bot has been offline for "
|
||||||
"an extended period of time.")
|
"an extended period of time.")
|
||||||
@ -97,15 +97,15 @@ class FreqaiDataDrawer:
|
|||||||
"""
|
"""
|
||||||
Save data drawer full of all pair model metadata in present model folder.
|
Save data drawer full of all pair model metadata in present model folder.
|
||||||
"""
|
"""
|
||||||
with open(self.full_path / str("pair_dictionary.json"), "w") as fp:
|
with open(self.full_path / str("historic_predictions.pkl"), "wb") as fp:
|
||||||
json.dump(self.pair_dict, fp, default=self.np_encoder)
|
pickle.dump(self.historic_predictions, fp, protocol=pickle.HIGHEST_PROTOCOL)
|
||||||
|
|
||||||
def save_historic_predictions_to_disk(self):
|
def save_historic_predictions_to_disk(self):
|
||||||
"""
|
"""
|
||||||
Save data drawer full of all pair model metadata in present model folder.
|
Save data drawer full of all pair model metadata in present model folder.
|
||||||
"""
|
"""
|
||||||
with open(self.full_path / str("historic_predictions.json"), "w") as fp:
|
with open(self.full_path / str("pair_dictionary.json"), "w") as fp:
|
||||||
json.dump(self.historic_predictions, fp, default=self.np_encoder)
|
json.dump(self.pair_dict, fp, default=self.np_encoder)
|
||||||
|
|
||||||
def save_follower_dict_to_disk(self):
|
def save_follower_dict_to_disk(self):
|
||||||
"""
|
"""
|
||||||
|
@ -71,7 +71,8 @@ class BaseRegressionModel(IFreqaiModel):
|
|||||||
data_dictionary['train_features'], model, dk, pair)
|
data_dictionary['train_features'], model, dk, pair)
|
||||||
elif self.freqai_info.get('fit_live_predictions_candles', 0):
|
elif self.freqai_info.get('fit_live_predictions_candles', 0):
|
||||||
dk.fit_live_predictions()
|
dk.fit_live_predictions()
|
||||||
self.dd.save_historic_predictions_to_disk()
|
|
||||||
|
self.dd.save_historic_predictions_to_disk()
|
||||||
|
|
||||||
logger.info(f"--------------------done training {pair}--------------------")
|
logger.info(f"--------------------done training {pair}--------------------")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user