From 2509ce030dfae0f9c993828f1f9ba210b6e86945 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste LE STANG Date: Sat, 13 Jan 2018 08:32:44 +0100 Subject: [PATCH] Refreshing pair of only selected ticker_interval --- freqtrade/optimize/__init__.py | 11 +++++------ freqtrade/tests/optimize/test_optimize.py | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/freqtrade/optimize/__init__.py b/freqtrade/optimize/__init__.py index 2a252a9f6..3a22e6a5a 100644 --- a/freqtrade/optimize/__init__.py +++ b/freqtrade/optimize/__init__.py @@ -48,7 +48,7 @@ def load_data(datadir: str, ticker_interval: int, pairs: Optional[List[str]] = N # If the user force the refresh of pairs if refresh_pairs: logger.info('Download data for all pairs and store them in %s', datadir) - download_pairs(datadir, _pairs) + download_pairs(datadir, _pairs, ticker_interval) for pair in _pairs: pairdata = load_tickerdata_file(datadir, pair, ticker_interval) @@ -73,16 +73,15 @@ def make_testdata_path(datadir: str) -> str: '..', 'tests', 'testdata')) -def download_pairs(datadir, pairs: List[str]) -> bool: - """For each pairs passed in parameters, download 1 and 5 ticker intervals""" +def download_pairs(datadir, pairs: List[str], ticker_interval: int) -> bool: + """For each pairs passed in parameters, download the ticker intervals""" for pair in pairs: try: - for interval in [1, 5, 30, 60, 1440]: - download_backtesting_testdata(datadir, pair=pair, interval=interval) + download_backtesting_testdata(datadir, pair=pair, interval=ticker_interval) except BaseException: logger.info('Failed to download the pair: "{pair}", Interval: {interval} min'.format( pair=pair, - interval=interval, + interval=ticker_interval, )) return False return True diff --git a/freqtrade/tests/optimize/test_optimize.py b/freqtrade/tests/optimize/test_optimize.py index b051a7ae9..650a0e1a4 100644 --- a/freqtrade/tests/optimize/test_optimize.py +++ b/freqtrade/tests/optimize/test_optimize.py @@ -130,17 +130,26 @@ def test_download_pairs(default_conf, ticker_history, mocker): _backup_file(file2_1) _backup_file(file2_5) - assert download_pairs(None, pairs=['BTC-MEME', 'BTC-CFI']) is True + assert download_pairs(None, pairs=['BTC-MEME', 'BTC-CFI'], ticker_interval=1) is True assert os.path.isfile(file1_1) is True - assert os.path.isfile(file1_5) is True + assert os.path.isfile(file1_5) is False assert os.path.isfile(file2_1) is True + assert os.path.isfile(file2_5) is False + + # clean files freshly downloaded + _clean_test_file(file1_1) + _clean_test_file(file2_1) + + + assert download_pairs(None, pairs=['BTC-MEME', 'BTC-CFI'], ticker_interval=5) is True + assert os.path.isfile(file1_1) is False + assert os.path.isfile(file1_5) is True + assert os.path.isfile(file2_1) is False assert os.path.isfile(file2_5) is True # clean files freshly downloaded - _clean_test_file(file1_1) _clean_test_file(file1_5) - _clean_test_file(file2_1) _clean_test_file(file2_5) @@ -156,7 +165,7 @@ def test_download_pairs_exception(default_conf, ticker_history, mocker, caplog): _backup_file(file1_1) _backup_file(file1_5) - download_pairs(None, pairs=['BTC-MEME']) + download_pairs(None, pairs=['BTC-MEME'], ticker_interval=1) # clean files freshly downloaded _clean_test_file(file1_1) _clean_test_file(file1_5)