@@ -6319,3 +6319,39 @@ def test_exchange_features(default_conf, mocker):
|
|||||||
assert exchange.features("futures", "fetchOHLCV", "limit", 500) == 997
|
assert exchange.features("futures", "fetchOHLCV", "limit", 500) == 997
|
||||||
# Fall back to default
|
# Fall back to default
|
||||||
assert exchange.features("futures", "fetchOHLCV_else", "limit", 601) == 601
|
assert exchange.features("futures", "fetchOHLCV_else", "limit", 601) == 601
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("exchange_name", EXCHANGES)
|
||||||
|
def test_fetch_funding_rate(default_conf, mocker, exchange_name):
|
||||||
|
api_mock = MagicMock()
|
||||||
|
funding_rate = {
|
||||||
|
"symbol": "ETH/BTC",
|
||||||
|
"fundingRate": 5.652e-05,
|
||||||
|
"fundingTimestamp": 1757174400000,
|
||||||
|
"fundingDatetime": "2025-09-06T16:00:00.000Z",
|
||||||
|
}
|
||||||
|
api_mock.fetch_funding_rate = MagicMock(return_value=funding_rate)
|
||||||
|
api_mock.markets = {"ETH/BTC": {"active": True}}
|
||||||
|
exchange = get_patched_exchange(mocker, default_conf, api_mock, exchange=exchange_name)
|
||||||
|
# retrieve original funding rate
|
||||||
|
funding_rate = exchange.fetch_funding_rate(pair="ETH/BTC")
|
||||||
|
assert funding_rate["fundingRate"] == funding_rate["fundingRate"]
|
||||||
|
assert funding_rate["fundingTimestamp"] == funding_rate["fundingTimestamp"]
|
||||||
|
assert funding_rate["fundingDatetime"] == funding_rate["fundingDatetime"]
|
||||||
|
|
||||||
|
ccxt_exceptionhandlers(
|
||||||
|
mocker,
|
||||||
|
default_conf,
|
||||||
|
api_mock,
|
||||||
|
exchange_name,
|
||||||
|
"fetch_funding_rate",
|
||||||
|
"fetch_funding_rate",
|
||||||
|
pair="ETH/BTC",
|
||||||
|
)
|
||||||
|
|
||||||
|
api_mock.fetch_funding_rate = MagicMock(return_value={})
|
||||||
|
exchange = get_patched_exchange(mocker, default_conf, api_mock, exchange=exchange_name)
|
||||||
|
exchange.fetch_funding_rate(pair="ETH/BTC")
|
||||||
|
|
||||||
|
with pytest.raises(DependencyException, match=r"Pair XRP/ETH not available"):
|
||||||
|
exchange.fetch_funding_rate(pair="XRP/ETH")
|
||||||
|
|||||||
Reference in New Issue
Block a user