mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-13 19:31:15 +00:00
test: add test for funding rate exchange fix
This commit is contained in:
@@ -2837,6 +2837,29 @@ def test_refresh_ohlcv_with_cache(mocker, default_conf, time_machine) -> None:
|
||||
assert ohlcv_mock.call_args_list[0][0][0] == pairs
|
||||
|
||||
|
||||
def test_refresh_latest_ohlcv_funding_rate(mocker, default_conf_usdt, caplog) -> None:
|
||||
ohlcv = generate_test_data_raw("1h", 24, "2025-01-02 12:00:00+00:00")
|
||||
funding_data = [{"timestamp": x[0], "fundingRate": x[1]} for x in ohlcv]
|
||||
|
||||
caplog.set_level(logging.DEBUG)
|
||||
exchange = get_patched_exchange(mocker, default_conf_usdt)
|
||||
exchange._api_async.fetch_ohlcv = get_mock_coro(ohlcv)
|
||||
exchange._api_async.fetch_funding_rate_history = get_mock_coro(funding_data)
|
||||
|
||||
pairs = [
|
||||
("IOTA/USDT:USDT", "8h", CandleType.FUNDING_RATE),
|
||||
("XRP/USDT:USDT", "1h", CandleType.FUNDING_RATE),
|
||||
]
|
||||
# empty dicts
|
||||
assert not exchange._klines
|
||||
res = exchange.refresh_latest_ohlcv(pairs, cache=False)
|
||||
|
||||
assert len(res) == len(pairs)
|
||||
assert log_has_re(r"Wrong funding rate timeframe 8h for pair IOTA/USDT:USDT", caplog)
|
||||
assert not log_has_re(r"Wrong funding rate timeframe 8h for pair XRP/USDT:USDT", caplog)
|
||||
assert exchange._api_async.fetch_ohlcv.call_count == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize("exchange_name", EXCHANGES)
|
||||
async def test__async_get_candle_history(default_conf, mocker, caplog, exchange_name):
|
||||
ohlcv = [
|
||||
|
||||
Reference in New Issue
Block a user