From 429f846ad1aa0ac1b29476d79c8033254d1bb918 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 15 Dec 2018 20:14:13 +0100 Subject: [PATCH] Switch load_data to kwargs --- freqtrade/edge/__init__.py | 2 +- freqtrade/optimize/backtesting.py | 2 +- freqtrade/tests/data/test_history.py | 16 ++++++++-------- freqtrade/tests/optimize/test_backtesting.py | 8 ++++---- freqtrade/tests/optimize/test_optimize.py | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/freqtrade/edge/__init__.py b/freqtrade/edge/__init__.py index 72e234773..8ccfc90de 100644 --- a/freqtrade/edge/__init__.py +++ b/freqtrade/edge/__init__.py @@ -100,7 +100,7 @@ class Edge(): logger.info('Using local backtesting data (using whitelist in given config) ...') data = history.load_data( - Path(self.config['datadir']) if self.config.get('datadir') else None, + datadir=Path(self.config['datadir']) if self.config.get('datadir') else None, pairs=pairs, ticker_interval=self.ticker_interval, refresh_pairs=self._refresh_pairs, diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 4447df966..cc05c5de8 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -370,7 +370,7 @@ class Backtesting(object): timerange = Arguments.parse_timerange(None if self.config.get( 'timerange') is None else str(self.config.get('timerange'))) data = history.load_data( - Path(self.config['datadir']) if self.config.get('datadir') else None, + datadir=Path(self.config['datadir']) if self.config.get('datadir') else None, pairs=pairs, ticker_interval=self.ticker_interval, refresh_pairs=self.config.get('refresh_pairs', False), diff --git a/freqtrade/tests/data/test_history.py b/freqtrade/tests/data/test_history.py index 5d279a529..a40021fba 100644 --- a/freqtrade/tests/data/test_history.py +++ b/freqtrade/tests/data/test_history.py @@ -58,7 +58,7 @@ def test_load_data_30min_ticker(ticker_history, mocker, caplog, default_conf) -> mocker.patch('freqtrade.exchange.Exchange.get_history', return_value=ticker_history) file = os.path.join(os.path.dirname(__file__), '..', 'testdata', 'UNITTEST_BTC-30m.json') _backup_file(file, copy_file=True) - ld = history.load_data(None, pairs=['UNITTEST/BTC'], ticker_interval='30m') + ld = history.load_data(datadir=None, pairs=['UNITTEST/BTC'], ticker_interval='30m') assert isinstance(ld, dict) assert os.path.isfile(file) is True assert not log_has('Download the pair: "UNITTEST/BTC", Interval: 30m', caplog.record_tuples) @@ -70,7 +70,7 @@ def test_load_data_5min_ticker(ticker_history, mocker, caplog, default_conf) -> file = os.path.join(os.path.dirname(__file__), '..', 'testdata', 'UNITTEST_BTC-5m.json') _backup_file(file, copy_file=True) - history.load_data(None, pairs=['UNITTEST/BTC'], ticker_interval='5m') + history.load_data(datadir=None, pairs=['UNITTEST/BTC'], ticker_interval='5m') assert os.path.isfile(file) is True assert not log_has('Download the pair: "UNITTEST/BTC", Interval: 5m', caplog.record_tuples) _clean_test_file(file) @@ -80,7 +80,7 @@ def test_load_data_1min_ticker(ticker_history, mocker, caplog) -> None: mocker.patch('freqtrade.exchange.Exchange.get_history', return_value=ticker_history) file = os.path.join(os.path.dirname(__file__), '..', 'testdata', 'UNITTEST_BTC-1m.json') _backup_file(file, copy_file=True) - history.load_data(None, ticker_interval='1m', pairs=['UNITTEST/BTC']) + history.load_data(datadir=None, ticker_interval='1m', pairs=['UNITTEST/BTC']) assert os.path.isfile(file) is True assert not log_has('Download the pair: "UNITTEST/BTC", Interval: 1m', caplog.record_tuples) _clean_test_file(file) @@ -96,7 +96,7 @@ def test_load_data_with_new_pair_1min(ticker_history_list, mocker, caplog, defau _backup_file(file) # do not download a new pair if refresh_pairs isn't set - history.load_data(None, + history.load_data(datadir=None, ticker_interval='1m', refresh_pairs=False, pairs=['MEME/BTC']) @@ -106,7 +106,7 @@ def test_load_data_with_new_pair_1min(ticker_history_list, mocker, caplog, defau caplog.record_tuples) # download a new pair if refresh_pairs is set - history.load_data(None, + history.load_data(datadir=None, ticker_interval='1m', refresh_pairs=True, exchange=exchange, @@ -347,8 +347,8 @@ def test_load_partial_missing(caplog) -> None: caplog.clear() start = arrow.get('2018-01-10T00:00:00') end = arrow.get('2018-02-20T00:00:00') - tickerdata = history.load_data(None, '5m', ['UNITTEST/BTC'], - refresh_pairs=False, + tickerdata = history.load_data(datadir=None, ticker_interval='5m', + pairs=['UNITTEST/BTC'], refresh_pairs=False, timerange=TimeRange('date', 'date', start.timestamp, end.timestamp)) # timedifference in 5 minutes @@ -364,7 +364,7 @@ def test_load_partial_missing(caplog) -> None: def test_init(default_conf, mocker) -> None: exchange = get_patched_exchange(mocker, default_conf) assert {} == history.load_data( - '', + datadir='', exchange=exchange, pairs=[], refresh_pairs=True, diff --git a/freqtrade/tests/optimize/test_backtesting.py b/freqtrade/tests/optimize/test_backtesting.py index f30d6b224..8f7c80523 100644 --- a/freqtrade/tests/optimize/test_backtesting.py +++ b/freqtrade/tests/optimize/test_backtesting.py @@ -117,7 +117,7 @@ def _load_pair_as_ticks(pair, tickfreq): # FIX: fixturize this? def _make_backtest_conf(mocker, conf=None, pair='UNITTEST/BTC', record=None): - data = history.load_data(None, ticker_interval='1m', pairs=[pair]) + data = history.load_data(datadir=None, ticker_interval='1m', pairs=[pair]) data = trim_dictlist(data, -201) patch_exchange(mocker) backtesting = Backtesting(conf) @@ -505,7 +505,7 @@ def test_backtest(default_conf, fee, mocker) -> None: backtesting = Backtesting(default_conf) pair = 'UNITTEST/BTC' timerange = TimeRange(None, 'line', 0, -201) - data = history.load_data(None, ticker_interval='5m', pairs=['UNITTEST/BTC'], + data = history.load_data(datadir=None, ticker_interval='5m', pairs=['UNITTEST/BTC'], timerange=timerange) data_processed = backtesting.strategy.tickerdata_to_dataframe(data) min_date, max_date = get_timeframe(data_processed) @@ -559,7 +559,7 @@ def test_backtest_1min_ticker_interval(default_conf, fee, mocker) -> None: # Run a backtesting for an exiting 1min ticker_interval timerange = TimeRange(None, 'line', 0, -200) - data = history.load_data(None, ticker_interval='1m', pairs=['UNITTEST/BTC'], + data = history.load_data(datadir=None, ticker_interval='1m', pairs=['UNITTEST/BTC'], timerange=timerange) processed = backtesting.strategy.tickerdata_to_dataframe(data) min_date, max_date = get_timeframe(processed) @@ -683,7 +683,7 @@ def test_backtest_multi_pair(default_conf, fee, mocker): mocker.patch('freqtrade.exchange.Exchange.get_fee', fee) patch_exchange(mocker) pairs = ['ADA/BTC', 'DASH/BTC', 'ETH/BTC', 'LTC/BTC', 'NXT/BTC'] - data = history.load_data(None, ticker_interval='5m', pairs=pairs) + data = history.load_data(datadir=None, ticker_interval='5m', pairs=pairs) data = trim_dictlist(data, -500) # We need to enable sell-signal - otherwise it sells on ROI!! default_conf['experimental'] = {"use_sell_signal": True} diff --git a/freqtrade/tests/optimize/test_optimize.py b/freqtrade/tests/optimize/test_optimize.py index 2019c9fde..02d0e9c36 100644 --- a/freqtrade/tests/optimize/test_optimize.py +++ b/freqtrade/tests/optimize/test_optimize.py @@ -12,7 +12,7 @@ def test_get_timeframe(default_conf, mocker) -> None: data = strategy.tickerdata_to_dataframe( history.load_data( - None, + datadir=None, ticker_interval='1m', pairs=['UNITTEST/BTC'] ) @@ -28,7 +28,7 @@ def test_validate_backtest_data_warn(default_conf, mocker, caplog) -> None: data = strategy.tickerdata_to_dataframe( history.load_data( - None, + datadir=None, ticker_interval='1m', pairs=['UNITTEST/BTC'] ) @@ -50,7 +50,7 @@ def test_validate_backtest_data(default_conf, mocker, caplog) -> None: timerange = TimeRange('index', 'index', 200, 250) data = strategy.tickerdata_to_dataframe( history.load_data( - None, + datadir=None, ticker_interval='5m', pairs=['UNITTEST/BTC'], timerange=timerange