Always return dataframe
This commit is contained in:
parent
2b029b2a86
commit
646e98da55
@ -247,7 +247,7 @@ All methods return `None` in case of failure (do not raise an exception).
|
|||||||
#### Possible options for DataProvider
|
#### Possible options for DataProvider
|
||||||
|
|
||||||
- `available_pairs` - Property containing cached pairs
|
- `available_pairs` - Property containing cached pairs
|
||||||
- `ohlcv(pair, ticker_interval)` - Currently cached ticker data for all pairs in the whitelist
|
- `ohlcv(pair, ticker_interval)` - Currently cached ticker data for all pairs in the whitelist, returns DataFrame or empty DataFrame
|
||||||
- `historic_ohlcv(pair, ticker_interval)` - Data stored on disk
|
- `historic_ohlcv(pair, ticker_interval)` - Data stored on disk
|
||||||
- `runmode` - Property containing the current runmode.
|
- `runmode` - Property containing the current runmode.
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class DataProvider(object):
|
|||||||
"""
|
"""
|
||||||
return list(self._exchange._klines.keys())
|
return list(self._exchange._klines.keys())
|
||||||
|
|
||||||
def ohlcv(self, pair: str, copy: bool = True) -> List[str]:
|
def ohlcv(self, pair: str, copy: bool = True) -> DataFrame:
|
||||||
"""
|
"""
|
||||||
get ohlcv data for the given pair as DataFrame
|
get ohlcv data for the given pair as DataFrame
|
||||||
Please check `available_pairs` to verify which pairs are currently cached.
|
Please check `available_pairs` to verify which pairs are currently cached.
|
||||||
@ -49,7 +49,7 @@ class DataProvider(object):
|
|||||||
if self.runmode in (RunMode.DRY_RUN, RunMode.LIVE):
|
if self.runmode in (RunMode.DRY_RUN, RunMode.LIVE):
|
||||||
return self._exchange.klines(pair, copy)
|
return self._exchange.klines(pair, copy)
|
||||||
else:
|
else:
|
||||||
return None
|
return DataFrame()
|
||||||
|
|
||||||
def historic_ohlcv(self, pair: str, ticker_interval: str) -> DataFrame:
|
def historic_ohlcv(self, pair: str, ticker_interval: str) -> DataFrame:
|
||||||
"""
|
"""
|
||||||
|
@ -162,7 +162,7 @@ class Exchange(object):
|
|||||||
if pair in self._klines:
|
if pair in self._klines:
|
||||||
return self._klines[pair].copy() if copy else self._klines[pair]
|
return self._klines[pair].copy() if copy else self._klines[pair]
|
||||||
else:
|
else:
|
||||||
return None
|
return DataFrame()
|
||||||
|
|
||||||
def set_sandbox(self, api, exchange_config: dict, name: str):
|
def set_sandbox(self, api, exchange_config: dict, name: str):
|
||||||
if exchange_config.get('sandbox'):
|
if exchange_config.get('sandbox'):
|
||||||
|
@ -18,7 +18,8 @@ def test_ohlcv(mocker, default_conf, ticker_history):
|
|||||||
assert isinstance(dp.ohlcv('UNITTEST/BTC'), DataFrame)
|
assert isinstance(dp.ohlcv('UNITTEST/BTC'), DataFrame)
|
||||||
assert dp.ohlcv('UNITTEST/BTC') is not ticker_history
|
assert dp.ohlcv('UNITTEST/BTC') is not ticker_history
|
||||||
assert dp.ohlcv('UNITTEST/BTC', copy=False) is ticker_history
|
assert dp.ohlcv('UNITTEST/BTC', copy=False) is ticker_history
|
||||||
assert dp.ohlcv('NONESENSE/AAA') is None
|
assert not dp.ohlcv('UNITTEST/BTC').empty
|
||||||
|
assert dp.ohlcv('NONESENSE/AAA').empty
|
||||||
|
|
||||||
default_conf['runmode'] = RunMode.LIVE
|
default_conf['runmode'] = RunMode.LIVE
|
||||||
dp = DataProvider(default_conf, exchange)
|
dp = DataProvider(default_conf, exchange)
|
||||||
@ -28,7 +29,7 @@ def test_ohlcv(mocker, default_conf, ticker_history):
|
|||||||
default_conf['runmode'] = RunMode.BACKTEST
|
default_conf['runmode'] = RunMode.BACKTEST
|
||||||
dp = DataProvider(default_conf, exchange)
|
dp = DataProvider(default_conf, exchange)
|
||||||
assert dp.runmode == RunMode.BACKTEST
|
assert dp.runmode == RunMode.BACKTEST
|
||||||
assert dp.ohlcv('UNITTEST/BTC') is None
|
assert dp.ohlcv('UNITTEST/BTC').empty
|
||||||
|
|
||||||
|
|
||||||
def test_historic_ohlcv(mocker, default_conf, ticker_history):
|
def test_historic_ohlcv(mocker, default_conf, ticker_history):
|
||||||
|
Loading…
Reference in New Issue
Block a user