another attempt at fixing datalength bug
This commit is contained in:
parent
b08c0888bb
commit
f653ace24b
@ -39,6 +39,10 @@ class FreqaiDataKitchen:
|
|||||||
self.do_predict = np.array([])
|
self.do_predict = np.array([])
|
||||||
self.target_mean = np.array([])
|
self.target_mean = np.array([])
|
||||||
self.target_std = np.array([])
|
self.target_std = np.array([])
|
||||||
|
self.full_predictions = np.array([])
|
||||||
|
self.full_do_predict = np.array([])
|
||||||
|
self.full_target_mean = np.array([])
|
||||||
|
self.full_target_std = np.array([])
|
||||||
self.model_path = Path()
|
self.model_path = Path()
|
||||||
self.model_filename = ""
|
self.model_filename = ""
|
||||||
|
|
||||||
@ -313,12 +317,11 @@ class FreqaiDataKitchen:
|
|||||||
|
|
||||||
timerange_backtest.startts = timerange_train.stopts
|
timerange_backtest.startts = timerange_train.stopts
|
||||||
|
|
||||||
|
timerange_backtest.stopts = timerange_backtest.startts + bt_period
|
||||||
|
|
||||||
if timerange_backtest.stopts > config_timerange.stopts:
|
if timerange_backtest.stopts > config_timerange.stopts:
|
||||||
timerange_backtest.stopts = config_timerange.stopts
|
timerange_backtest.stopts = config_timerange.stopts
|
||||||
|
|
||||||
else:
|
|
||||||
timerange_backtest.stopts = timerange_backtest.startts + bt_period
|
|
||||||
|
|
||||||
start = datetime.datetime.utcfromtimestamp(timerange_backtest.startts)
|
start = datetime.datetime.utcfromtimestamp(timerange_backtest.startts)
|
||||||
stop = datetime.datetime.utcfromtimestamp(timerange_backtest.stopts)
|
stop = datetime.datetime.utcfromtimestamp(timerange_backtest.stopts)
|
||||||
tr_backtesting_list.append(start.strftime("%Y%m%d") + "-" + stop.strftime("%Y%m%d"))
|
tr_backtesting_list.append(start.strftime("%Y%m%d") + "-" + stop.strftime("%Y%m%d"))
|
||||||
@ -328,7 +331,7 @@ class FreqaiDataKitchen:
|
|||||||
if timerange_backtest.stopts == config_timerange.stopts:
|
if timerange_backtest.stopts == config_timerange.stopts:
|
||||||
break
|
break
|
||||||
|
|
||||||
# print(tr_training_list, tr_backtesting_list)
|
print(tr_training_list, tr_backtesting_list)
|
||||||
return tr_training_list, tr_backtesting_list
|
return tr_training_list, tr_backtesting_list
|
||||||
|
|
||||||
def slice_dataframe(self, tr: str, df: DataFrame) -> DataFrame:
|
def slice_dataframe(self, tr: str, df: DataFrame) -> DataFrame:
|
||||||
@ -536,10 +539,10 @@ class FreqaiDataKitchen:
|
|||||||
ones = np.ones(len_dataframe)
|
ones = np.ones(len_dataframe)
|
||||||
s_mean, s_std = ones * self.data["s_mean"], ones * self.data["s_std"]
|
s_mean, s_std = ones * self.data["s_mean"], ones * self.data["s_std"]
|
||||||
|
|
||||||
self.predictions = np.append(self.predictions, predictions)
|
self.full_predictions = np.append(self.full_predictions, predictions)
|
||||||
self.do_predict = np.append(self.do_predict, do_predict)
|
self.full_do_predict = np.append(self.full_do_predict, do_predict)
|
||||||
self.target_mean = np.append(self.target_mean, s_mean)
|
self.full_target_mean = np.append(self.full_target_mean, s_mean)
|
||||||
self.target_std = np.append(self.target_std, s_std)
|
self.full_target_std = np.append(self.full_target_std, s_std)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -549,11 +552,11 @@ class FreqaiDataKitchen:
|
|||||||
when it goes back to the strategy. These rows are not included in the backtest.
|
when it goes back to the strategy. These rows are not included in the backtest.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
filler = np.zeros(len_dataframe - len(self.predictions)) # startup_candle_count
|
filler = np.zeros(len_dataframe - len(self.full_predictions)) # startup_candle_count
|
||||||
self.predictions = np.append(filler, self.predictions)
|
self.full_predictions = np.append(filler, self.full_predictions)
|
||||||
self.do_predict = np.append(filler, self.do_predict)
|
self.full_do_predict = np.append(filler, self.full_do_predict)
|
||||||
self.target_mean = np.append(filler, self.target_mean)
|
self.full_target_mean = np.append(filler, self.full_target_mean)
|
||||||
self.target_std = np.append(filler, self.target_std)
|
self.full_target_std = np.append(filler, self.full_target_std)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -84,10 +84,13 @@ class IFreqaiModel(ABC):
|
|||||||
preds, do_preds = self.predict(dataframe_backtest)
|
preds, do_preds = self.predict(dataframe_backtest)
|
||||||
|
|
||||||
self.dh.append_predictions(preds, do_preds, len(dataframe_backtest))
|
self.dh.append_predictions(preds, do_preds, len(dataframe_backtest))
|
||||||
|
print('predictions', len(self.dh.full_predictions),
|
||||||
|
'do_predict', len(self.dh.full_do_predict))
|
||||||
|
|
||||||
self.dh.fill_predictions(len(dataframe))
|
self.dh.fill_predictions(len(dataframe))
|
||||||
|
|
||||||
return self.dh.predictions, self.dh.do_predict, self.dh.target_mean, self.dh.target_std
|
return (self.dh.full_predictions, self.dh.full_do_predict,
|
||||||
|
self.dh.full_target_mean, self.dh.full_target_std)
|
||||||
|
|
||||||
def make_labels(self, dataframe: DataFrame) -> DataFrame:
|
def make_labels(self, dataframe: DataFrame) -> DataFrame:
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user