Rename download_backtest_testdata to download_pair_history

This commit is contained in:
Matthias 2018-12-16 10:33:08 +01:00
parent 50938d410a
commit eb7034c7a7
3 changed files with 35 additions and 35 deletions

View File

@ -115,11 +115,11 @@ def load_pair_history(pair: str,
"calling load_data with refresh_pairs=True") "calling load_data with refresh_pairs=True")
logger.info('Download data for all pairs and store them in %s', datadir) logger.info('Download data for all pairs and store them in %s', datadir)
download_backtesting_testdata(datadir=datadir, download_pair_history(datadir=datadir,
exchange=exchange, exchange=exchange,
pair=pair, pair=pair,
tick_interval=ticker_interval, tick_interval=ticker_interval,
timerange=timerange) timerange=timerange)
if pairdata: if pairdata:
if timerange.starttype == 'date' and pairdata[0][0] > timerange.startts * 1000: if timerange.starttype == 'date' and pairdata[0][0] > timerange.startts * 1000:
@ -202,11 +202,11 @@ def load_cached_data_for_updating(filename: Path, tick_interval: str,
return (data, since_ms) return (data, since_ms)
def download_backtesting_testdata(datadir: Optional[Path], def download_pair_history(datadir: Optional[Path],
exchange: Exchange, exchange: Exchange,
pair: str, pair: str,
tick_interval: str = '5m', tick_interval: str = '5m',
timerange: Optional[TimeRange] = None) -> bool: timerange: Optional[TimeRange] = None) -> bool:
""" """
Download the latest ticker intervals from the exchange for the pair passed in parameters Download the latest ticker intervals from the exchange for the pair passed in parameters
The data is downloaded starting from the last correct ticker interval data that The data is downloaded starting from the last correct ticker interval data that

View File

@ -13,7 +13,7 @@ import pytest
from freqtrade import OperationalException from freqtrade import OperationalException
from freqtrade.arguments import TimeRange from freqtrade.arguments import TimeRange
from freqtrade.data import history from freqtrade.data import history
from freqtrade.data.history import (download_backtesting_testdata, from freqtrade.data.history import (download_pair_history,
load_cached_data_for_updating, load_cached_data_for_updating,
load_tickerdata_file, load_tickerdata_file,
make_testdata_path, make_testdata_path,
@ -224,7 +224,7 @@ def test_load_cached_data_for_updating(mocker) -> None:
assert start_ts is None assert start_ts is None
def test_download_backtesting_testdata(ticker_history_list, mocker, default_conf) -> None: def test_download_pair_history(ticker_history_list, mocker, default_conf) -> None:
mocker.patch('freqtrade.exchange.Exchange.get_history', return_value=ticker_history_list) mocker.patch('freqtrade.exchange.Exchange.get_history', return_value=ticker_history_list)
exchange = get_patched_exchange(mocker, default_conf) exchange = get_patched_exchange(mocker, default_conf)
file1_1 = os.path.join(os.path.dirname(__file__), '..', 'testdata', 'MEME_BTC-1m.json') file1_1 = os.path.join(os.path.dirname(__file__), '..', 'testdata', 'MEME_BTC-1m.json')
@ -240,12 +240,12 @@ def test_download_backtesting_testdata(ticker_history_list, mocker, default_conf
assert os.path.isfile(file1_1) is False assert os.path.isfile(file1_1) is False
assert os.path.isfile(file2_1) is False assert os.path.isfile(file2_1) is False
assert download_backtesting_testdata(datadir=None, exchange=exchange, assert download_pair_history(datadir=None, exchange=exchange,
pair='MEME/BTC', pair='MEME/BTC',
tick_interval='1m') tick_interval='1m')
assert download_backtesting_testdata(datadir=None, exchange=exchange, assert download_pair_history(datadir=None, exchange=exchange,
pair='CFI/BTC', pair='CFI/BTC',
tick_interval='1m') tick_interval='1m')
assert not exchange._pairs_last_refresh_time assert not exchange._pairs_last_refresh_time
assert os.path.isfile(file1_1) is True assert os.path.isfile(file1_1) is True
assert os.path.isfile(file2_1) is True assert os.path.isfile(file2_1) is True
@ -257,12 +257,12 @@ def test_download_backtesting_testdata(ticker_history_list, mocker, default_conf
assert os.path.isfile(file1_5) is False assert os.path.isfile(file1_5) is False
assert os.path.isfile(file2_5) is False assert os.path.isfile(file2_5) is False
assert download_backtesting_testdata(datadir=None, exchange=exchange, assert download_pair_history(datadir=None, exchange=exchange,
pair='MEME/BTC', pair='MEME/BTC',
tick_interval='5m') tick_interval='5m')
assert download_backtesting_testdata(datadir=None, exchange=exchange, assert download_pair_history(datadir=None, exchange=exchange,
pair='CFI/BTC', pair='CFI/BTC',
tick_interval='5m') tick_interval='5m')
assert not exchange._pairs_last_refresh_time assert not exchange._pairs_last_refresh_time
assert os.path.isfile(file1_5) is True assert os.path.isfile(file1_5) is True
assert os.path.isfile(file2_5) is True assert os.path.isfile(file2_5) is True
@ -272,7 +272,7 @@ def test_download_backtesting_testdata(ticker_history_list, mocker, default_conf
_clean_test_file(file2_5) _clean_test_file(file2_5)
def test_download_backtesting_testdata2(mocker, default_conf) -> None: def test_download_pair_history2(mocker, default_conf) -> None:
tick = [ tick = [
[1509836520000, 0.00162008, 0.00162008, 0.00162008, 0.00162008, 108.14853839], [1509836520000, 0.00162008, 0.00162008, 0.00162008, 0.00162008, 108.14853839],
[1509836580000, 0.00161, 0.00161, 0.00161, 0.00161, 82.390199] [1509836580000, 0.00161, 0.00161, 0.00161, 0.00161, 82.390199]
@ -280,8 +280,8 @@ def test_download_backtesting_testdata2(mocker, default_conf) -> None:
json_dump_mock = mocker.patch('freqtrade.misc.file_dump_json', return_value=None) json_dump_mock = mocker.patch('freqtrade.misc.file_dump_json', return_value=None)
mocker.patch('freqtrade.exchange.Exchange.get_history', return_value=tick) mocker.patch('freqtrade.exchange.Exchange.get_history', return_value=tick)
exchange = get_patched_exchange(mocker, default_conf) exchange = get_patched_exchange(mocker, default_conf)
download_backtesting_testdata(None, exchange, pair="UNITTEST/BTC", tick_interval='1m') download_pair_history(None, exchange, pair="UNITTEST/BTC", tick_interval='1m')
download_backtesting_testdata(None, exchange, pair="UNITTEST/BTC", tick_interval='3m') download_pair_history(None, exchange, pair="UNITTEST/BTC", tick_interval='3m')
assert json_dump_mock.call_count == 2 assert json_dump_mock.call_count == 2
@ -296,9 +296,9 @@ def test_download_backtesting_data_exception(ticker_history, mocker, caplog, def
_backup_file(file1_1) _backup_file(file1_1)
_backup_file(file1_5) _backup_file(file1_5)
assert not download_backtesting_testdata(datadir=None, exchange=exchange, assert not download_pair_history(datadir=None, exchange=exchange,
pair='MEME/BTC', pair='MEME/BTC',
tick_interval='1m') tick_interval='1m')
# clean files freshly downloaded # clean files freshly downloaded
_clean_test_file(file1_1) _clean_test_file(file1_1)
_clean_test_file(file1_5) _clean_test_file(file1_5)

View File

@ -9,7 +9,7 @@ import arrow
from freqtrade import arguments from freqtrade import arguments
from freqtrade.arguments import TimeRange from freqtrade.arguments import TimeRange
from freqtrade.exchange import Exchange from freqtrade.exchange import Exchange
from freqtrade.data.history import download_backtesting_testdata from freqtrade.data.history import download_pair_history
from freqtrade.configuration import set_loggers from freqtrade.configuration import set_loggers
import logging import logging
@ -82,10 +82,10 @@ for pair in PAIRS:
dl_file.unlink() dl_file.unlink()
print(f'downloading pair {pair}, interval {tick_interval}') print(f'downloading pair {pair}, interval {tick_interval}')
download_backtesting_testdata(datadir=dl_path, exchange=exchange, download_pair_history(datadir=dl_path, exchange=exchange,
pair=pair, pair=pair,
tick_interval=tick_interval, tick_interval=tick_interval,
timerange=timerange) timerange=timerange)
if pairs_not_available: if pairs_not_available: