add self-retraining functionality for live/dry

This commit is contained in:
robcaulk
2022-05-09 15:25:00 +02:00
parent 178c2014b0
commit 22bd5556ed
7 changed files with 218 additions and 44 deletions

View File

@@ -124,7 +124,7 @@ class ExamplePredictionModel(IFreqaiModel):
data (NaNs) or felt uncertain about data (PCA and DI index)
"""
logger.info("--------------------Starting prediction--------------------")
# logger.info("--------------------Starting prediction--------------------")
original_feature_list = self.dh.build_feature_list(self.config)
filtered_dataframe, _ = self.dh.filter_features(
@@ -151,8 +151,8 @@ class ExamplePredictionModel(IFreqaiModel):
predictions = self.model.predict(self.dh.data_dictionary["prediction_features"])
# compute the non-standardized predictions
predictions = predictions * self.dh.data["labels_std"] + self.dh.data["labels_mean"]
self.dh.predictions = predictions * self.dh.data["labels_std"] + self.dh.data["labels_mean"]
logger.info("--------------------Finished prediction--------------------")
# logger.info("--------------------Finished prediction--------------------")
return (predictions, self.dh.do_predict)
return (self.dh.predictions, self.dh.do_predict)

View File

@@ -44,13 +44,16 @@ class FreqaiExampleStrategy(IStrategy):
stoploss = -0.05
use_sell_signal = True
startup_candle_count: int = 1000
startup_candle_count: int = 300
def informative_pairs(self):
pairs = self.freqai_info["corr_pairlist"]
pairs = self.config["freqai"]["corr_pairlist"]
informative_pairs = []
for tf in self.timeframes:
informative_pairs.append([(pair, tf) for pair in pairs])
for tf in self.config["freqai"]["timeframes"]:
# informative_pairs.append((self.pair, tf))
# informative_pairs.append([(pair, tf) for pair in pairs])
for pair in pairs:
informative_pairs.append((pair, tf))
return informative_pairs
def populate_any_indicators(self, pair, df, tf, informative=None, coin=""):
@@ -129,6 +132,7 @@ class FreqaiExampleStrategy(IStrategy):
# the configuration file parameters are stored here
self.freqai_info = self.config["freqai"]
self.pair = metadata['pair']
# the model is instantiated here
self.model = CustomModel(self.config)
@@ -138,12 +142,13 @@ class FreqaiExampleStrategy(IStrategy):
# the following loops are necessary for building the features
# indicated by the user in the configuration file.
for tf in self.freqai_info["timeframes"]:
dataframe = self.populate_any_indicators(metadata["pair"], dataframe.copy(), tf)
for i in self.freqai_info["corr_pairlist"]:
# dataframe = self.populate_any_indicators(metadata["pair"], dataframe.copy(), tf)
for pair in self.freqai_info["corr_pairlist"]:
dataframe = self.populate_any_indicators(
i, dataframe.copy(), tf, coin=i.split("/")[0] + "-"
pair, dataframe.copy(), tf, coin=pair.split("/")[0] + "-"
)
print('dataframe_built')
# the model will return 4 values, its prediction, an indication of whether or not the
# prediction should be accepted, the target mean/std values from the labels used during
# each training period.
@@ -152,7 +157,7 @@ class FreqaiExampleStrategy(IStrategy):
dataframe["do_predict"],
dataframe["target_mean"],
dataframe["target_std"],
) = self.model.bridge.start(dataframe, metadata)
) = self.model.bridge.start(dataframe, metadata, self)
dataframe["target_roi"] = dataframe["target_mean"] + dataframe["target_std"] * 0.5
dataframe["sell_roi"] = dataframe["target_mean"] - dataframe["target_std"] * 1.5