accept open-ended timeranges from user

This commit is contained in:
robcaulk 2022-05-17 19:50:06 +02:00
parent d1d451c27e
commit db66b82f6f

View File

@ -312,6 +312,9 @@ class FreqaiDataKitchen:
full_timerange = TimeRange.parse_timerange(tr)
config_timerange = TimeRange.parse_timerange(self.config["timerange"])
if config_timerange.stopts == 0:
config_timerange.stopts = int(datetime.datetime.now(
tz=datetime.timezone.utc).timestamp())
timerange_train = copy.deepcopy(full_timerange)
timerange_backtest = copy.deepcopy(full_timerange)
@ -589,6 +592,10 @@ class FreqaiDataKitchen:
def create_fulltimerange(self, backtest_tr: str, backtest_period: int) -> str:
backtest_timerange = TimeRange.parse_timerange(backtest_tr)
if backtest_timerange.stopts == 0:
backtest_timerange.stopts = int(datetime.datetime.now(
tz=datetime.timezone.utc).timestamp())
backtest_timerange.startts = backtest_timerange.startts - backtest_period * SECONDS_IN_DAY
start = datetime.datetime.utcfromtimestamp(backtest_timerange.startts)
stop = datetime.datetime.utcfromtimestamp(backtest_timerange.stopts)