Merge pull request #2678 from hroff-1902/dataprovider-history-split-refresh
Dataprovider history: split refresh part
This commit is contained in:
@@ -21,6 +21,7 @@ from freqtrade.data.history import (_download_pair_history,
|
||||
pair_trades_filename,
|
||||
refresh_backtest_ohlcv_data,
|
||||
refresh_backtest_trades_data,
|
||||
refresh_data,
|
||||
trim_dataframe, trim_tickerlist,
|
||||
validate_backtest_data)
|
||||
from freqtrade.exchange import timeframe_to_minutes
|
||||
@@ -129,16 +130,17 @@ def test_load_data_with_new_pair_1min(ticker_history_list, mocker, caplog,
|
||||
)
|
||||
|
||||
# download a new pair if refresh_pairs is set
|
||||
load_pair_history(datadir=testdatadir, timeframe='1m',
|
||||
refresh_pairs=True, exchange=exchange, pair='MEME/BTC')
|
||||
refresh_data(datadir=testdatadir, timeframe='1m', pairs=['MEME/BTC'],
|
||||
exchange=exchange)
|
||||
load_pair_history(datadir=testdatadir, timeframe='1m', pair='MEME/BTC')
|
||||
assert file.is_file()
|
||||
assert log_has_re(
|
||||
'Download history data for pair: "MEME/BTC", timeframe: 1m '
|
||||
'and store in .*', caplog
|
||||
)
|
||||
with pytest.raises(OperationalException, match=r'Exchange needs to be initialized when.*'):
|
||||
load_pair_history(datadir=testdatadir, timeframe='1m',
|
||||
refresh_pairs=True, exchange=None, pair='MEME/BTC')
|
||||
refresh_data(datadir=testdatadir, timeframe='1m', pairs=['MEME/BTC'],
|
||||
exchange=None)
|
||||
_clean_test_file(file)
|
||||
|
||||
|
||||
@@ -372,12 +374,24 @@ def test_load_partial_missing(testdatadir, caplog) -> None:
|
||||
|
||||
|
||||
def test_init(default_conf, mocker) -> None:
|
||||
exchange = get_patched_exchange(mocker, default_conf)
|
||||
assert {} == load_data(
|
||||
datadir='',
|
||||
exchange=exchange,
|
||||
pairs=[],
|
||||
refresh_pairs=True,
|
||||
timeframe=default_conf['ticker_interval']
|
||||
)
|
||||
|
||||
|
||||
def test_init_with_refresh(default_conf, mocker) -> None:
|
||||
exchange = get_patched_exchange(mocker, default_conf)
|
||||
refresh_data(
|
||||
datadir='',
|
||||
pairs=[],
|
||||
timeframe=default_conf['ticker_interval'],
|
||||
exchange=exchange
|
||||
)
|
||||
assert {} == load_data(
|
||||
datadir='',
|
||||
pairs=[],
|
||||
timeframe=default_conf['ticker_interval']
|
||||
)
|
||||
|
||||
|
@@ -255,8 +255,8 @@ def test_edge_heartbeat_calculate(mocker, edge_conf):
|
||||
assert edge.calculate() is False
|
||||
|
||||
|
||||
def mocked_load_data(datadir, pairs=[], timeframe='0m', refresh_pairs=False,
|
||||
timerange=None, exchange=None, *args, **kwargs):
|
||||
def mocked_load_data(datadir, pairs=[], timeframe='0m',
|
||||
timerange=None, *args, **kwargs):
|
||||
hz = 0.1
|
||||
base = 0.001
|
||||
|
||||
@@ -290,6 +290,7 @@ def mocked_load_data(datadir, pairs=[], timeframe='0m', refresh_pairs=False,
|
||||
def test_edge_process_downloaded_data(mocker, edge_conf):
|
||||
freqtrade = get_patched_freqtradebot(mocker, edge_conf)
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_fee', MagicMock(return_value=0.001))
|
||||
mocker.patch('freqtrade.data.history.refresh_data', MagicMock())
|
||||
mocker.patch('freqtrade.data.history.load_data', mocked_load_data)
|
||||
edge = Edge(edge_conf, freqtrade.exchange, freqtrade.strategy)
|
||||
|
||||
@@ -301,6 +302,7 @@ def test_edge_process_downloaded_data(mocker, edge_conf):
|
||||
def test_edge_process_no_data(mocker, edge_conf, caplog):
|
||||
freqtrade = get_patched_freqtradebot(mocker, edge_conf)
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_fee', MagicMock(return_value=0.001))
|
||||
mocker.patch('freqtrade.data.history.refresh_data', MagicMock())
|
||||
mocker.patch('freqtrade.data.history.load_data', MagicMock(return_value={}))
|
||||
edge = Edge(edge_conf, freqtrade.exchange, freqtrade.strategy)
|
||||
|
||||
@@ -313,6 +315,7 @@ def test_edge_process_no_data(mocker, edge_conf, caplog):
|
||||
def test_edge_process_no_trades(mocker, edge_conf, caplog):
|
||||
freqtrade = get_patched_freqtradebot(mocker, edge_conf)
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_fee', MagicMock(return_value=0.001))
|
||||
mocker.patch('freqtrade.data.history.refresh_data', MagicMock())
|
||||
mocker.patch('freqtrade.data.history.load_data', mocked_load_data)
|
||||
# Return empty
|
||||
mocker.patch('freqtrade.edge.Edge._find_trades_for_stoploss_range', MagicMock(return_value=[]))
|
||||
|
@@ -116,8 +116,8 @@ def simple_backtest(config, contour, num_results, mocker, testdatadir) -> None:
|
||||
assert len(results) == num_results
|
||||
|
||||
|
||||
def mocked_load_data(datadir, pairs=[], timeframe='0m', refresh_pairs=False,
|
||||
timerange=None, exchange=None, live=False, *args, **kwargs):
|
||||
def mocked_load_data(datadir, pairs=[], timeframe='0m',
|
||||
timerange=None, *args, **kwargs):
|
||||
tickerdata = history.load_tickerdata_file(datadir, 'UNITTEST/BTC', '1m', timerange=timerange)
|
||||
pairdata = {'UNITTEST/BTC': parse_ticker_dataframe(tickerdata, '1m', pair="UNITTEST/BTC",
|
||||
fill_missing=True)}
|
||||
|
Reference in New Issue
Block a user