Rename download_*_history as non-public
This commit is contained in:
		| @@ -155,11 +155,11 @@ def load_pair_history(pair: str, | |||||||
|  |  | ||||||
|     # The user forced the refresh of pairs |     # The user forced the refresh of pairs | ||||||
|     if refresh_pairs: |     if refresh_pairs: | ||||||
|         download_pair_history(datadir=datadir, |         _download_pair_history(datadir=datadir, | ||||||
|                               exchange=exchange, |                                exchange=exchange, | ||||||
|                               pair=pair, |                                pair=pair, | ||||||
|                               timeframe=timeframe, |                                timeframe=timeframe, | ||||||
|                               timerange=timerange) |                                timerange=timerange) | ||||||
|  |  | ||||||
|     pairdata = load_tickerdata_file(datadir, pair, timeframe, timerange=timerange_startup) |     pairdata = load_tickerdata_file(datadir, pair, timeframe, timerange=timerange_startup) | ||||||
|  |  | ||||||
| @@ -277,11 +277,11 @@ def _load_cached_data_for_updating(datadir: Path, pair: str, timeframe: str, | |||||||
|     return (data, since_ms) |     return (data, since_ms) | ||||||
|  |  | ||||||
|  |  | ||||||
| def download_pair_history(datadir: Path, | def _download_pair_history(datadir: Path, | ||||||
|                           exchange: Optional[Exchange], |                            exchange: Optional[Exchange], | ||||||
|                           pair: str, |                            pair: str, | ||||||
|                           timeframe: str = '5m', |                            timeframe: str = '5m', | ||||||
|                           timerange: Optional[TimeRange] = None) -> bool: |                            timerange: Optional[TimeRange] = None) -> bool: | ||||||
|     """ |     """ | ||||||
|     Download latest candles from the exchange for the pair and timeframe passed in parameters |     Download latest candles from the exchange for the pair and timeframe passed in parameters | ||||||
|     The data is downloaded starting from the last correct data that |     The data is downloaded starting from the last correct data that | ||||||
| @@ -356,16 +356,16 @@ def refresh_backtest_ohlcv_data(exchange: Exchange, pairs: List[str], timeframes | |||||||
|                 dl_file.unlink() |                 dl_file.unlink() | ||||||
|  |  | ||||||
|             logger.info(f'Downloading pair {pair}, interval {timeframe}.') |             logger.info(f'Downloading pair {pair}, interval {timeframe}.') | ||||||
|             download_pair_history(datadir=datadir, exchange=exchange, |             _download_pair_history(datadir=datadir, exchange=exchange, | ||||||
|                                   pair=pair, timeframe=str(timeframe), |                                    pair=pair, timeframe=str(timeframe), | ||||||
|                                   timerange=timerange) |                                    timerange=timerange) | ||||||
|     return pairs_not_available |     return pairs_not_available | ||||||
|  |  | ||||||
|  |  | ||||||
| def download_trades_history(datadir: Path, | def _download_trades_history(datadir: Path, | ||||||
|                             exchange: Exchange, |                              exchange: Exchange, | ||||||
|                             pair: str, |                              pair: str, | ||||||
|                             timerange: Optional[TimeRange] = None) -> bool: |                              timerange: Optional[TimeRange] = None) -> bool: | ||||||
|     """ |     """ | ||||||
|     Download trade history from the exchange. |     Download trade history from the exchange. | ||||||
|     Appends to previously downloaded trades data. |     Appends to previously downloaded trades data. | ||||||
| @@ -425,9 +425,9 @@ def refresh_backtest_trades_data(exchange: Exchange, pairs: List[str], datadir: | |||||||
|             dl_file.unlink() |             dl_file.unlink() | ||||||
|  |  | ||||||
|         logger.info(f'Downloading trades for pair {pair}.') |         logger.info(f'Downloading trades for pair {pair}.') | ||||||
|         download_trades_history(datadir=datadir, exchange=exchange, |         _download_trades_history(datadir=datadir, exchange=exchange, | ||||||
|                                 pair=pair, |                                  pair=pair, | ||||||
|                                 timerange=timerange) |                                  timerange=timerange) | ||||||
|     return pairs_not_available |     return pairs_not_available | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -14,9 +14,9 @@ from freqtrade import OperationalException | |||||||
| from freqtrade.configuration import TimeRange | from freqtrade.configuration import TimeRange | ||||||
| from freqtrade.data import history | from freqtrade.data import history | ||||||
| from freqtrade.data.history import (_load_cached_data_for_updating, | from freqtrade.data.history import (_load_cached_data_for_updating, | ||||||
|  |                                     _download_pair_history, | ||||||
|  |                                     _download_trades_history, | ||||||
|                                     convert_trades_to_ohlcv, |                                     convert_trades_to_ohlcv, | ||||||
|                                     download_pair_history, |  | ||||||
|                                     download_trades_history, |  | ||||||
|                                     load_tickerdata_file, pair_data_filename, |                                     load_tickerdata_file, pair_data_filename, | ||||||
|                                     pair_trades_filename, |                                     pair_trades_filename, | ||||||
|                                     refresh_backtest_ohlcv_data, |                                     refresh_backtest_ohlcv_data, | ||||||
| @@ -267,12 +267,12 @@ def test_download_pair_history(ticker_history_list, mocker, default_conf, testda | |||||||
|     assert not file1_1.is_file() |     assert not file1_1.is_file() | ||||||
|     assert not file2_1.is_file() |     assert not file2_1.is_file() | ||||||
|  |  | ||||||
|     assert download_pair_history(datadir=testdatadir, exchange=exchange, |     assert _download_pair_history(datadir=testdatadir, exchange=exchange, | ||||||
|                                  pair='MEME/BTC', |                                   pair='MEME/BTC', | ||||||
|                                  timeframe='1m') |                                   timeframe='1m') | ||||||
|     assert download_pair_history(datadir=testdatadir, exchange=exchange, |     assert _download_pair_history(datadir=testdatadir, exchange=exchange, | ||||||
|                                  pair='CFI/BTC', |                                   pair='CFI/BTC', | ||||||
|                                  timeframe='1m') |                                   timeframe='1m') | ||||||
|     assert not exchange._pairs_last_refresh_time |     assert not exchange._pairs_last_refresh_time | ||||||
|     assert file1_1.is_file() |     assert file1_1.is_file() | ||||||
|     assert file2_1.is_file() |     assert file2_1.is_file() | ||||||
| @@ -284,12 +284,12 @@ def test_download_pair_history(ticker_history_list, mocker, default_conf, testda | |||||||
|     assert not file1_5.is_file() |     assert not file1_5.is_file() | ||||||
|     assert not file2_5.is_file() |     assert not file2_5.is_file() | ||||||
|  |  | ||||||
|     assert download_pair_history(datadir=testdatadir, exchange=exchange, |     assert _download_pair_history(datadir=testdatadir, exchange=exchange, | ||||||
|                                  pair='MEME/BTC', |                                   pair='MEME/BTC', | ||||||
|                                  timeframe='5m') |                                   timeframe='5m') | ||||||
|     assert download_pair_history(datadir=testdatadir, exchange=exchange, |     assert _download_pair_history(datadir=testdatadir, exchange=exchange, | ||||||
|                                  pair='CFI/BTC', |                                   pair='CFI/BTC', | ||||||
|                                  timeframe='5m') |                                   timeframe='5m') | ||||||
|     assert not exchange._pairs_last_refresh_time |     assert not exchange._pairs_last_refresh_time | ||||||
|     assert file1_5.is_file() |     assert file1_5.is_file() | ||||||
|     assert file2_5.is_file() |     assert file2_5.is_file() | ||||||
| @@ -307,8 +307,8 @@ def test_download_pair_history2(mocker, default_conf, testdatadir) -> 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_historic_ohlcv', return_value=tick) |     mocker.patch('freqtrade.exchange.Exchange.get_historic_ohlcv', return_value=tick) | ||||||
|     exchange = get_patched_exchange(mocker, default_conf) |     exchange = get_patched_exchange(mocker, default_conf) | ||||||
|     download_pair_history(testdatadir, exchange, pair="UNITTEST/BTC", timeframe='1m') |     _download_pair_history(testdatadir, exchange, pair="UNITTEST/BTC", timeframe='1m') | ||||||
|     download_pair_history(testdatadir, exchange, pair="UNITTEST/BTC", timeframe='3m') |     _download_pair_history(testdatadir, exchange, pair="UNITTEST/BTC", timeframe='3m') | ||||||
|     assert json_dump_mock.call_count == 2 |     assert json_dump_mock.call_count == 2 | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -324,9 +324,9 @@ def test_download_backtesting_data_exception(ticker_history, mocker, caplog, | |||||||
|     _backup_file(file1_1) |     _backup_file(file1_1) | ||||||
|     _backup_file(file1_5) |     _backup_file(file1_5) | ||||||
|  |  | ||||||
|     assert not download_pair_history(datadir=testdatadir, exchange=exchange, |     assert not _download_pair_history(datadir=testdatadir, exchange=exchange, | ||||||
|                                      pair='MEME/BTC', |                                       pair='MEME/BTC', | ||||||
|                                      timeframe='1m') |                                       timeframe='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) | ||||||
| @@ -570,7 +570,7 @@ def test_validate_backtest_data(default_conf, mocker, caplog, testdatadir) -> No | |||||||
|  |  | ||||||
|  |  | ||||||
| def test_refresh_backtest_ohlcv_data(mocker, default_conf, markets, caplog, testdatadir): | def test_refresh_backtest_ohlcv_data(mocker, default_conf, markets, caplog, testdatadir): | ||||||
|     dl_mock = mocker.patch('freqtrade.data.history.download_pair_history', MagicMock()) |     dl_mock = mocker.patch('freqtrade.data.history._download_pair_history', MagicMock()) | ||||||
|     mocker.patch( |     mocker.patch( | ||||||
|         'freqtrade.exchange.Exchange.markets', PropertyMock(return_value=markets) |         'freqtrade.exchange.Exchange.markets', PropertyMock(return_value=markets) | ||||||
|     ) |     ) | ||||||
| @@ -591,7 +591,7 @@ def test_refresh_backtest_ohlcv_data(mocker, default_conf, markets, caplog, test | |||||||
|  |  | ||||||
|  |  | ||||||
| def test_download_data_no_markets(mocker, default_conf, caplog, testdatadir): | def test_download_data_no_markets(mocker, default_conf, caplog, testdatadir): | ||||||
|     dl_mock = mocker.patch('freqtrade.data.history.download_pair_history', MagicMock()) |     dl_mock = mocker.patch('freqtrade.data.history._download_pair_history', MagicMock()) | ||||||
|  |  | ||||||
|     ex = get_patched_exchange(mocker, default_conf) |     ex = get_patched_exchange(mocker, default_conf) | ||||||
|     mocker.patch( |     mocker.patch( | ||||||
| @@ -611,7 +611,7 @@ def test_download_data_no_markets(mocker, default_conf, caplog, testdatadir): | |||||||
|  |  | ||||||
|  |  | ||||||
| def test_refresh_backtest_trades_data(mocker, default_conf, markets, caplog, testdatadir): | def test_refresh_backtest_trades_data(mocker, default_conf, markets, caplog, testdatadir): | ||||||
|     dl_mock = mocker.patch('freqtrade.data.history.download_trades_history', MagicMock()) |     dl_mock = mocker.patch('freqtrade.data.history._download_trades_history', MagicMock()) | ||||||
|     mocker.patch( |     mocker.patch( | ||||||
|         'freqtrade.exchange.Exchange.markets', PropertyMock(return_value=markets) |         'freqtrade.exchange.Exchange.markets', PropertyMock(return_value=markets) | ||||||
|     ) |     ) | ||||||
| @@ -646,8 +646,8 @@ def test_download_trades_history(trades_history, mocker, default_conf, testdatad | |||||||
|  |  | ||||||
|     assert not file1.is_file() |     assert not file1.is_file() | ||||||
|  |  | ||||||
|     assert download_trades_history(datadir=testdatadir, exchange=exchange, |     assert _download_trades_history(datadir=testdatadir, exchange=exchange, | ||||||
|                                    pair='ETH/BTC') |                                     pair='ETH/BTC') | ||||||
|     assert log_has("New Amount of trades: 5", caplog) |     assert log_has("New Amount of trades: 5", caplog) | ||||||
|     assert file1.is_file() |     assert file1.is_file() | ||||||
|  |  | ||||||
| @@ -657,8 +657,8 @@ def test_download_trades_history(trades_history, mocker, default_conf, testdatad | |||||||
|     mocker.patch('freqtrade.exchange.Exchange.get_historic_trades', |     mocker.patch('freqtrade.exchange.Exchange.get_historic_trades', | ||||||
|                  MagicMock(side_effect=ValueError)) |                  MagicMock(side_effect=ValueError)) | ||||||
|  |  | ||||||
|     assert not download_trades_history(datadir=testdatadir, exchange=exchange, |     assert not _download_trades_history(datadir=testdatadir, exchange=exchange, | ||||||
|                                        pair='ETH/BTC') |                                         pair='ETH/BTC') | ||||||
|     assert log_has_re('Failed to download historic trades for pair: "ETH/BTC".*', caplog) |     assert log_has_re('Failed to download historic trades for pair: "ETH/BTC".*', caplog) | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user