Merge pull request #3045 from orehunt/jsondatahandler-ohlc-respect-timerange

check again for emptiness after trimming dataframe
This commit is contained in:
hroff-1902 2020-03-12 22:46:31 +03:00 committed by GitHub
commit c6bb32d419
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -147,12 +147,7 @@ class IDataHandler(ABC):
pairdf = self._ohlcv_load(pair, timeframe, pairdf = self._ohlcv_load(pair, timeframe,
timerange=timerange_startup) timerange=timerange_startup)
if pairdf.empty: if self._check_empty_df(pairdf, pair, timeframe, warn_no_data):
if warn_no_data:
logger.warning(
f'No history data for pair: "{pair}", timeframe: {timeframe}. '
'Use `freqtrade download-data` to download the data'
)
return pairdf return pairdf
else: else:
enddate = pairdf.iloc[-1]['date'] enddate = pairdf.iloc[-1]['date']
@ -160,13 +155,30 @@ class IDataHandler(ABC):
if timerange_startup: if timerange_startup:
self._validate_pairdata(pair, pairdf, timerange_startup) self._validate_pairdata(pair, pairdf, timerange_startup)
pairdf = trim_dataframe(pairdf, timerange_startup) pairdf = trim_dataframe(pairdf, timerange_startup)
if self._check_empty_df(pairdf, pair, timeframe, warn_no_data):
return pairdf
# incomplete candles should only be dropped if we didn't trim the end beforehand. # incomplete candles should only be dropped if we didn't trim the end beforehand.
return clean_ohlcv_dataframe(pairdf, timeframe, pairdf = clean_ohlcv_dataframe(pairdf, timeframe,
pair=pair, pair=pair,
fill_missing=fill_missing, fill_missing=fill_missing,
drop_incomplete=(drop_incomplete and drop_incomplete=(drop_incomplete and
enddate == pairdf.iloc[-1]['date'])) enddate == pairdf.iloc[-1]['date']))
self._check_empty_df(pairdf, pair, timeframe, warn_no_data)
return pairdf
def _check_empty_df(self, pairdf: DataFrame, pair: str, timeframe: str, warn_no_data: bool):
"""
Warn on empty dataframe
"""
if pairdf.empty:
if warn_no_data:
logger.warning(
f'No history data for pair: "{pair}", timeframe: {timeframe}. '
'Use `freqtrade download-data` to download the data'
)
return True
return False
def _validate_pairdata(self, pair, pairdata: DataFrame, timerange: TimeRange): def _validate_pairdata(self, pair, pairdata: DataFrame, timerange: TimeRange):
""" """