예제 #1
0
def test_load_data_with_new_pair_1min(ohlcv_history_list, mocker, caplog,
                                      default_conf, testdatadir) -> None:
    """
    Test load_pair_history() with 1 min timeframe
    """
    mocker.patch('freqtrade.exchange.Exchange.get_historic_ohlcv',
                 return_value=ohlcv_history_list)
    exchange = get_patched_exchange(mocker, default_conf)
    file = testdatadir / 'MEME_BTC-1m.json'

    _backup_file(file)
    # do not download a new pair if refresh_pairs isn't set
    load_pair_history(datadir=testdatadir, timeframe='1m', pair='MEME/BTC')
    assert not file.is_file()
    assert log_has(
        'No history data for pair: "MEME/BTC", timeframe: 1m. '
        'Use `freqtrade download-data` to download the data', caplog)

    # download a new pair if refresh_pairs is set
    refresh_data(datadir=testdatadir,
                 timeframe='1m',
                 pairs=['MEME/BTC'],
                 exchange=exchange)
    load_pair_history(datadir=testdatadir, timeframe='1m', pair='MEME/BTC')
    assert file.is_file()
    assert log_has_re(
        'Download history data for pair: "MEME/BTC", timeframe: 1m '
        'and store in .*', caplog)
    _clean_test_file(file)
예제 #2
0
def test_init_with_refresh(default_conf, mocker) -> None:
    exchange = get_patched_exchange(mocker, default_conf)
    refresh_data(datadir=Path(''),
                 pairs=[],
                 timeframe=default_conf['timeframe'],
                 exchange=exchange)
    assert {} == load_data(datadir=Path(''),
                           pairs=[],
                           timeframe=default_conf['timeframe'])
예제 #3
0
def test_load_data_with_new_pair_1min(ohlcv_history_list, mocker, caplog,
                                      default_conf, tmpdir,
                                      candle_type) -> None:
    """
    Test load_pair_history() with 1 min timeframe
    """
    tmpdir1 = Path(tmpdir)
    mocker.patch('freqtrade.exchange.Exchange.get_historic_ohlcv',
                 return_value=ohlcv_history_list)
    exchange = get_patched_exchange(mocker, default_conf)
    file = tmpdir1 / 'MEME_BTC-1m.json'

    # do not download a new pair if refresh_pairs isn't set
    load_pair_history(datadir=tmpdir1,
                      timeframe='1m',
                      pair='MEME/BTC',
                      candle_type=candle_type)
    assert not file.is_file()
    assert log_has(
        f"No history for MEME/BTC, {candle_type}, 1m found. "
        "Use `freqtrade download-data` to download the data", caplog)

    # download a new pair if refresh_pairs is set
    refresh_data(datadir=tmpdir1,
                 timeframe='1m',
                 pairs=['MEME/BTC'],
                 exchange=exchange,
                 candle_type=CandleType.SPOT)
    load_pair_history(datadir=tmpdir1,
                      timeframe='1m',
                      pair='MEME/BTC',
                      candle_type=candle_type)
    assert file.is_file()
    assert log_has_re(
        r'Download history data for pair: "MEME/BTC" \(0/1\), timeframe: 1m, '
        r'candle type: spot and store in .*', caplog)