Add method "to_datetime" to TimeRange.

This commit is contained in:
Kuy Krawczeniuk 2021-03-25 16:28:21 -07:00
parent f7eba77e36
commit b00f5f1b0e
2 changed files with 9 additions and 1 deletions

View File

@ -4,6 +4,7 @@ This module contains the argument manager class
import logging import logging
import re import re
from typing import Optional from typing import Optional
from datetime import datetime, timezone
import arrow import arrow
@ -33,6 +34,10 @@ class TimeRange:
return (self.starttype == other.starttype and self.stoptype == other.stoptype return (self.starttype == other.starttype and self.stoptype == other.stoptype
and self.startts == other.startts and self.stopts == other.stopts) and self.startts == other.startts and self.stopts == other.stopts)
def to_datetime(self) -> (datetime, datetime):
return datetime.fromtimestamp(self.startts, timezone.utc), \
datetime.fromtimestamp(self.stopts, timezone.utc)
def subtract_start(self, seconds: int) -> None: def subtract_start(self, seconds: int) -> None:
""" """
Subtracts <seconds> from startts if startts is set. Subtracts <seconds> from startts if startts is set.

View File

@ -287,9 +287,12 @@ def refresh_backtest_ohlcv_data(exchange: Exchange, pairs: List[str], timeframes
f'Deleting existing data for pair {pair}, interval {timeframe}.') f'Deleting existing data for pair {pair}, interval {timeframe}.')
logger.info(f'Downloading pair {pair}, interval {timeframe}.') logger.info(f'Downloading pair {pair}, interval {timeframe}.')
# What happens when until should be None?
since, until = timerange.to_datetime()
_download_pair_history(datadir=datadir, exchange=exchange, _download_pair_history(datadir=datadir, exchange=exchange,
pair=pair, timeframe=str(timeframe), pair=pair, timeframe=str(timeframe),
timerange=timerange, data_handler=data_handler) since=since, until=until,
data_handler=data_handler)
return pairs_not_available return pairs_not_available