diff --git a/freqtrade/exchange/binance.py b/freqtrade/exchange/binance.py index b9de58911..fbdfcdb67 100644 --- a/freqtrade/exchange/binance.py +++ b/freqtrade/exchange/binance.py @@ -231,8 +231,8 @@ class Binance(Exchange): self, pair: str, contract_size: float, - mark_price: float, - funding_rate: Optional[float], + funding_rate: float, + mark_price: Optional[float], ) -> float: """ Calculates a single funding fee @@ -245,9 +245,6 @@ class Binance(Exchange): if mark_price is None: raise OperationalException("Mark price cannot be None for Binance._get_funding_fee") nominal_value = mark_price * contract_size - if funding_rate is None: - raise OperationalException( - "Funding rate should never be none on Binance._get_funding_fee") return nominal_value * funding_rate async def _async_get_historic_ohlcv( diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 2d6dc0030..101f32a19 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -1694,17 +1694,19 @@ class Exchange: self, pair: str, contract_size: float, + funding_rate: float, mark_price: float, - funding_rate: Optional[float] ) -> float: """ Calculates a single funding fee :param contract_size: The amount/quanity :param mark_price: The price of the asset that the contract is based off of :param funding_rate: the interest rate and the premium + - interest rate: - premium: varies by price difference between the perpetual contract and mark price """ - raise OperationalException(f"Funding fee has not been implemented for {self.name}") + nominal_value = mark_price * contract_size + return nominal_value * funding_rate def fill_leverage_brackets(self): """ diff --git a/freqtrade/exchange/ftx.py b/freqtrade/exchange/ftx.py index dcbe848b7..21650c5a6 100644 --- a/freqtrade/exchange/ftx.py +++ b/freqtrade/exchange/ftx.py @@ -186,23 +186,4 @@ class Ftx(Exchange): return 20.0 def _get_funding_rate(self, pair: str, when: datetime) -> Optional[float]: - """FTX doesn't use this""" - return None - - def _get_funding_fee( - self, - pair: str, - contract_size: float, - mark_price: float, - premium_index: Optional[float], - # index_price: float, - # interest_rate: float) - ) -> float: - """ - Calculates a single funding fee - Always paid in USD on FTX # TODO: How do we account for this - : param contract_size: The amount/quanity - : param mark_price: The price of the asset that the contract is based off of - : param funding_rate: Must be None on ftx - """ - return (contract_size * mark_price) / 24 + raise OperationalException(f'_get_mark_price has not been implemented on {self.name}')