Revert unnecessary formatting changes
This commit is contained in:
parent
c20157e64f
commit
cb4efa6d56
@ -105,6 +105,8 @@ class DataProvider:
|
|||||||
"""
|
"""
|
||||||
Return pair candle (OHLCV) data, either live or cached historical -- depending
|
Return pair candle (OHLCV) data, either live or cached historical -- depending
|
||||||
on the runmode.
|
on the runmode.
|
||||||
|
Only combinations in the pairlist or which have been specified as informative pairs
|
||||||
|
will be available.
|
||||||
:param pair: pair to get the data for
|
:param pair: pair to get the data for
|
||||||
:param timeframe: timeframe to get data for
|
:param timeframe: timeframe to get data for
|
||||||
:return: Dataframe for this pair
|
:return: Dataframe for this pair
|
||||||
@ -120,23 +122,17 @@ class DataProvider:
|
|||||||
logger.warning(f"No data found for ({pair}, {timeframe}, {candle_type}).")
|
logger.warning(f"No data found for ({pair}, {timeframe}, {candle_type}).")
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_analyzed_dataframe(
|
def get_analyzed_dataframe(self, pair: str, timeframe: str) -> Tuple[DataFrame, datetime]:
|
||||||
self,
|
|
||||||
pair: str,
|
|
||||||
timeframe: str,
|
|
||||||
candle_type: str = ''
|
|
||||||
) -> Tuple[DataFrame, datetime]:
|
|
||||||
"""
|
"""
|
||||||
Retrieve the analyzed dataframe. Returns the full dataframe in trade mode (live / dry),
|
Retrieve the analyzed dataframe. Returns the full dataframe in trade mode (live / dry),
|
||||||
and the last 1000 candles (up to the time evaluated at this moment) in all other modes.
|
and the last 1000 candles (up to the time evaluated at this moment) in all other modes.
|
||||||
:param pair: pair to get the data for
|
:param pair: pair to get the data for
|
||||||
:param timeframe: timeframe to get data for
|
:param timeframe: timeframe to get data for
|
||||||
:param candle_type: '', mark, index, premiumIndex, or funding_rate
|
|
||||||
:return: Tuple of (Analyzed Dataframe, lastrefreshed) for the requested pair / timeframe
|
:return: Tuple of (Analyzed Dataframe, lastrefreshed) for the requested pair / timeframe
|
||||||
combination.
|
combination.
|
||||||
Returns empty dataframe and Epoch 0 (1970-01-01) if no dataframe was cached.
|
Returns empty dataframe and Epoch 0 (1970-01-01) if no dataframe was cached.
|
||||||
"""
|
"""
|
||||||
pair_key = (pair, timeframe, candle_type)
|
pair_key = (pair, timeframe, '')
|
||||||
if pair_key in self.__cached_pairs:
|
if pair_key in self.__cached_pairs:
|
||||||
if self.runmode in (RunMode.DRY_RUN, RunMode.LIVE):
|
if self.runmode in (RunMode.DRY_RUN, RunMode.LIVE):
|
||||||
df, date = self.__cached_pairs[pair_key]
|
df, date = self.__cached_pairs[pair_key]
|
||||||
|
@ -37,12 +37,7 @@ class HDF5DataHandler(IDataHandler):
|
|||||||
if match and len(match.groups()) > 1]
|
if match and len(match.groups()) > 1]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def ohlcv_get_pairs(
|
def ohlcv_get_pairs(cls, datadir: Path, timeframe: str, candle_type: str = '') -> List[str]:
|
||||||
cls,
|
|
||||||
datadir: Path,
|
|
||||||
timeframe: str,
|
|
||||||
candle_type: str = ''
|
|
||||||
) -> List[str]:
|
|
||||||
"""
|
"""
|
||||||
Returns a list of all pairs with ohlcv data available in this datadir
|
Returns a list of all pairs with ohlcv data available in this datadir
|
||||||
for the specified timeframe
|
for the specified timeframe
|
||||||
@ -88,8 +83,7 @@ class HDF5DataHandler(IDataHandler):
|
|||||||
ds.close()
|
ds.close()
|
||||||
|
|
||||||
def _ohlcv_load(self, pair: str, timeframe: str,
|
def _ohlcv_load(self, pair: str, timeframe: str,
|
||||||
timerange: Optional[TimeRange] = None,
|
timerange: Optional[TimeRange] = None, candle_type: str = '') -> pd.DataFrame:
|
||||||
candle_type: str = '') -> pd.DataFrame:
|
|
||||||
"""
|
"""
|
||||||
Internal method used to load data for one pair from disk.
|
Internal method used to load data for one pair from disk.
|
||||||
Implements the loading and conversion to a Pandas dataframe.
|
Implements the loading and conversion to a Pandas dataframe.
|
||||||
|
@ -38,12 +38,7 @@ class IDataHandler(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractclassmethod
|
@abstractclassmethod
|
||||||
def ohlcv_get_pairs(
|
def ohlcv_get_pairs(cls, datadir: Path, timeframe: str, candle_type: str = '') -> List[str]:
|
||||||
cls,
|
|
||||||
datadir: Path,
|
|
||||||
timeframe: str,
|
|
||||||
candle_type: str = ''
|
|
||||||
) -> List[str]:
|
|
||||||
"""
|
"""
|
||||||
Returns a list of all pairs with ohlcv data available in this datadir
|
Returns a list of all pairs with ohlcv data available in this datadir
|
||||||
for the specified timeframe
|
for the specified timeframe
|
||||||
@ -217,12 +212,7 @@ 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(
|
if self._check_empty_df(pairdf, pair, timeframe, warn_no_data):
|
||||||
pairdf,
|
|
||||||
pair,
|
|
||||||
timeframe,
|
|
||||||
warn_no_data
|
|
||||||
):
|
|
||||||
return pairdf
|
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.
|
||||||
@ -234,13 +224,7 @@ class IDataHandler(ABC):
|
|||||||
self._check_empty_df(pairdf, pair, timeframe, warn_no_data)
|
self._check_empty_df(pairdf, pair, timeframe, warn_no_data)
|
||||||
return pairdf
|
return pairdf
|
||||||
|
|
||||||
def _check_empty_df(
|
def _check_empty_df(self, pairdf: DataFrame, pair: str, timeframe: str, warn_no_data: bool):
|
||||||
self,
|
|
||||||
pairdf: DataFrame,
|
|
||||||
pair: str,
|
|
||||||
timeframe: str,
|
|
||||||
warn_no_data: bool
|
|
||||||
):
|
|
||||||
"""
|
"""
|
||||||
Warn on empty dataframe
|
Warn on empty dataframe
|
||||||
"""
|
"""
|
||||||
@ -253,12 +237,7 @@ class IDataHandler(ABC):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _validate_pairdata(
|
def _validate_pairdata(self, pair, pairdata: DataFrame, timerange: TimeRange):
|
||||||
self,
|
|
||||||
pair,
|
|
||||||
pairdata: DataFrame,
|
|
||||||
timerange: TimeRange
|
|
||||||
):
|
|
||||||
"""
|
"""
|
||||||
Validates pairdata for missing data at start end end and logs warnings.
|
Validates pairdata for missing data at start end end and logs warnings.
|
||||||
:param pairdata: Dataframe to validate
|
:param pairdata: Dataframe to validate
|
||||||
|
@ -37,12 +37,7 @@ class JsonDataHandler(IDataHandler):
|
|||||||
if match and len(match.groups()) > 1]
|
if match and len(match.groups()) > 1]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def ohlcv_get_pairs(
|
def ohlcv_get_pairs(cls, datadir: Path, timeframe: str, candle_type: str = '') -> List[str]:
|
||||||
cls,
|
|
||||||
datadir: Path,
|
|
||||||
timeframe: str,
|
|
||||||
candle_type: str = ''
|
|
||||||
) -> List[str]:
|
|
||||||
"""
|
"""
|
||||||
Returns a list of all pairs with ohlcv data available in this datadir
|
Returns a list of all pairs with ohlcv data available in this datadir
|
||||||
for the specified timeframe
|
for the specified timeframe
|
||||||
@ -78,12 +73,7 @@ class JsonDataHandler(IDataHandler):
|
|||||||
:param candle_type: '', mark, index, premiumIndex, or funding_rate
|
:param candle_type: '', mark, index, premiumIndex, or funding_rate
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
filename = self._pair_data_filename(
|
filename = self._pair_data_filename(self._datadir, pair, timeframe, candle_type)
|
||||||
self._datadir,
|
|
||||||
pair,
|
|
||||||
timeframe,
|
|
||||||
candle_type
|
|
||||||
)
|
|
||||||
_data = data.copy()
|
_data = data.copy()
|
||||||
# Convert date to int
|
# Convert date to int
|
||||||
_data['date'] = _data['date'].view(np.int64) // 1000 // 1000
|
_data['date'] = _data['date'].view(np.int64) // 1000 // 1000
|
||||||
|
Loading…
Reference in New Issue
Block a user