feat: add "current funding fee" endpoint

part of #12206
This commit is contained in:
Matthias
2025-09-06 10:06:59 +02:00
parent 816ca2ea15
commit 95ad756909
3 changed files with 45 additions and 2 deletions

View File

@@ -73,6 +73,7 @@ from freqtrade.exchange.exchange_types import (
CcxtOrder,
CcxtPosition,
FtHas,
FundingRate,
OHLCVResponse,
OrderBook,
Ticker,
@@ -2001,6 +2002,28 @@ class Exchange:
except ccxt.BaseError as e:
raise OperationalException(e) from e
@retrier
def fetch_funding_rate(self, pair: str) -> FundingRate:
"""
Get current Funding rate from exchange.
On Futures markets, this is the interest rate for holding a position.
Won't work for non-futures markets
"""
try:
return self._api.fetch_funding_rate(pair)
except ccxt.NotSupported as e:
raise OperationalException(
f"Exchange {self._api.name} does not support fetching funding rate. Message: {e}"
) from e
except ccxt.DDoSProtection as e:
raise DDosProtection(e) from e
except (ccxt.OperationFailed, ccxt.ExchangeError) as e:
raise TemporaryError(
f"Could not get funding rate due to {e.__class__.__name__}. Message: {e}"
) from e
except ccxt.BaseError as e:
raise OperationalException(e) from e
@staticmethod
def get_next_limit_in_list(
limit: int,