mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Only return ohlcv if available (Live and dry modes)
This commit is contained in:
parent
9edb88051d
commit
2b029b2a86
|
@ -46,7 +46,10 @@ class DataProvider(object):
|
|||
Use false only for RO operations (where the dataframe is not modified)
|
||||
"""
|
||||
# TODO: Should not be stored in exchange but in this class
|
||||
return self._exchange.klines(pair, copy)
|
||||
if self.runmode in (RunMode.DRY_RUN, RunMode.LIVE):
|
||||
return self._exchange.klines(pair, copy)
|
||||
else:
|
||||
return None
|
||||
|
||||
def historic_ohlcv(self, pair: str, ticker_interval: str) -> DataFrame:
|
||||
"""
|
||||
|
@ -77,6 +80,6 @@ class DataProvider(object):
|
|||
def runmode(self) -> RunMode:
|
||||
"""
|
||||
Get runmode of the bot
|
||||
can be "live", "dry-run", "backtest", "edgecli", "hyperopt".
|
||||
can be "live", "dry-run", "backtest", "edgecli", "hyperopt" or "other".
|
||||
"""
|
||||
return RunMode(self._config.get('runmode', RunMode.OTHER))
|
||||
|
|
|
@ -3,21 +3,33 @@ from unittest.mock import MagicMock
|
|||
from pandas import DataFrame
|
||||
|
||||
from freqtrade.data.dataprovider import DataProvider
|
||||
from freqtrade.state import RunMode
|
||||
from freqtrade.tests.conftest import get_patched_exchange
|
||||
|
||||
|
||||
def test_ohlcv(mocker, default_conf, ticker_history):
|
||||
|
||||
default_conf['runmode'] = RunMode.DRY_RUN
|
||||
exchange = get_patched_exchange(mocker, default_conf)
|
||||
exchange._klines['XRP/BTC'] = ticker_history
|
||||
exchange._klines['UNITTEST/BTC'] = ticker_history
|
||||
dp = DataProvider(default_conf, exchange)
|
||||
assert dp.runmode == RunMode.DRY_RUN
|
||||
assert ticker_history.equals(dp.ohlcv('UNITTEST/BTC'))
|
||||
assert isinstance(dp.ohlcv('UNITTEST/BTC'), DataFrame)
|
||||
assert dp.ohlcv('UNITTEST/BTC') is not ticker_history
|
||||
assert dp.ohlcv('UNITTEST/BTC', copy=False) is ticker_history
|
||||
assert dp.ohlcv('NONESENSE/AAA') is None
|
||||
|
||||
default_conf['runmode'] = RunMode.LIVE
|
||||
dp = DataProvider(default_conf, exchange)
|
||||
assert dp.runmode == RunMode.LIVE
|
||||
assert isinstance(dp.ohlcv('UNITTEST/BTC'), DataFrame)
|
||||
|
||||
default_conf['runmode'] = RunMode.BACKTEST
|
||||
dp = DataProvider(default_conf, exchange)
|
||||
assert dp.runmode == RunMode.BACKTEST
|
||||
assert dp.ohlcv('UNITTEST/BTC') is None
|
||||
|
||||
|
||||
def test_historic_ohlcv(mocker, default_conf, ticker_history):
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user