Ejemplo n.º 1
0
def test_download_pair_history(ohlcv_history_list, mocker, default_conf,
                               testdatadir) -> None:
    mocker.patch('freqtrade.exchange.Exchange.get_historic_ohlcv',
                 return_value=ohlcv_history_list)
    exchange = get_patched_exchange(mocker, default_conf)
    file1_1 = testdatadir / 'MEME_BTC-1m.json'
    file1_5 = testdatadir / 'MEME_BTC-5m.json'
    file2_1 = testdatadir / 'CFI_BTC-1m.json'
    file2_5 = testdatadir / 'CFI_BTC-5m.json'

    _backup_file(file1_1)
    _backup_file(file1_5)
    _backup_file(file2_1)
    _backup_file(file2_5)

    assert not file1_1.is_file()
    assert not file2_1.is_file()

    assert _download_pair_history(datadir=testdatadir,
                                  exchange=exchange,
                                  pair='MEME/BTC',
                                  timeframe='1m')
    assert _download_pair_history(datadir=testdatadir,
                                  exchange=exchange,
                                  pair='CFI/BTC',
                                  timeframe='1m')
    assert not exchange._pairs_last_refresh_time
    assert file1_1.is_file()
    assert file2_1.is_file()

    # clean files freshly downloaded
    _clean_test_file(file1_1)
    _clean_test_file(file2_1)

    assert not file1_5.is_file()
    assert not file2_5.is_file()

    assert _download_pair_history(datadir=testdatadir,
                                  exchange=exchange,
                                  pair='MEME/BTC',
                                  timeframe='5m')
    assert _download_pair_history(datadir=testdatadir,
                                  exchange=exchange,
                                  pair='CFI/BTC',
                                  timeframe='5m')
    assert not exchange._pairs_last_refresh_time
    assert file1_5.is_file()
    assert file2_5.is_file()

    # clean files freshly downloaded
    _clean_test_file(file1_5)
    _clean_test_file(file2_5)
Ejemplo n.º 2
0
def test_download_pair_history2(mocker, default_conf, testdatadir) -> None:
    tick = [
        [1509836520000, 0.00162008, 0.00162008, 0.00162008, 0.00162008, 108.14853839],
        [1509836580000, 0.00161, 0.00161, 0.00161, 0.00161, 82.390199]
    ]
    json_dump_mock = mocker.patch(
        'freqtrade.data.history.jsondatahandler.JsonDataHandler.ohlcv_store',
        return_value=None)
    mocker.patch('freqtrade.exchange.Exchange.get_historic_ohlcv', return_value=tick)
    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='3m')
    assert json_dump_mock.call_count == 2
Ejemplo n.º 3
0
def test_download_pair_history(ohlcv_history_list, mocker, default_conf,
                               tmpdir, candle_type, subdir, file_tail) -> None:
    mocker.patch('freqtrade.exchange.Exchange.get_historic_ohlcv',
                 return_value=ohlcv_history_list)
    exchange = get_patched_exchange(mocker, default_conf)
    tmpdir1 = Path(tmpdir)
    file1_1 = tmpdir1 / f'{subdir}MEME_BTC-1m{file_tail}.json'
    file1_5 = tmpdir1 / f'{subdir}MEME_BTC-5m{file_tail}.json'
    file2_1 = tmpdir1 / f'{subdir}CFI_BTC-1m{file_tail}.json'
    file2_5 = tmpdir1 / f'{subdir}CFI_BTC-5m{file_tail}.json'

    assert not file1_1.is_file()
    assert not file2_1.is_file()

    assert _download_pair_history(datadir=tmpdir1,
                                  exchange=exchange,
                                  pair='MEME/BTC',
                                  timeframe='1m',
                                  candle_type=candle_type)
    assert _download_pair_history(datadir=tmpdir1,
                                  exchange=exchange,
                                  pair='CFI/BTC',
                                  timeframe='1m',
                                  candle_type=candle_type)
    assert not exchange._pairs_last_refresh_time
    assert file1_1.is_file()
    assert file2_1.is_file()

    # clean files freshly downloaded
    _clean_test_file(file1_1)
    _clean_test_file(file2_1)

    assert not file1_5.is_file()
    assert not file2_5.is_file()

    assert _download_pair_history(datadir=tmpdir1,
                                  exchange=exchange,
                                  pair='MEME/BTC',
                                  timeframe='5m',
                                  candle_type=candle_type)
    assert _download_pair_history(datadir=tmpdir1,
                                  exchange=exchange,
                                  pair='CFI/BTC',
                                  timeframe='5m',
                                  candle_type=candle_type)
    assert not exchange._pairs_last_refresh_time
    assert file1_5.is_file()
    assert file2_5.is_file()
Ejemplo n.º 4
0
def test_download_backtesting_data_exception(mocker, caplog, default_conf,
                                             tmpdir) -> None:
    mocker.patch('freqtrade.exchange.Exchange.get_historic_ohlcv',
                 side_effect=Exception('File Error'))
    tmpdir1 = Path(tmpdir)
    exchange = get_patched_exchange(mocker, default_conf)

    assert not _download_pair_history(
        datadir=tmpdir1, exchange=exchange, pair='MEME/BTC', timeframe='1m')
    assert log_has(
        'Failed to download history data for pair: "MEME/BTC", timeframe: 1m.',
        caplog)
Ejemplo n.º 5
0
def test_download_backtesting_data_exception(ohlcv_history, mocker, caplog,
                                             default_conf, testdatadir) -> None:
    mocker.patch('freqtrade.exchange.Exchange.get_historic_ohlcv',
                 side_effect=Exception('File Error'))

    exchange = get_patched_exchange(mocker, default_conf)

    file1_1 = testdatadir / 'MEME_BTC-1m.json'
    file1_5 = testdatadir / 'MEME_BTC-5m.json'
    _backup_file(file1_1)
    _backup_file(file1_5)

    assert not _download_pair_history(datadir=testdatadir, exchange=exchange,
                                      pair='MEME/BTC',
                                      timeframe='1m')
    # clean files freshly downloaded
    _clean_test_file(file1_1)
    _clean_test_file(file1_5)
    assert log_has('Failed to download history data for pair: "MEME/BTC", timeframe: 1m.', caplog)