gateio, ftx and binance all use same funding fee formula
This commit is contained in:
parent
92a5d7583d
commit
268069abea
@ -231,8 +231,8 @@ class Binance(Exchange):
|
|||||||
self,
|
self,
|
||||||
pair: str,
|
pair: str,
|
||||||
contract_size: float,
|
contract_size: float,
|
||||||
mark_price: float,
|
funding_rate: float,
|
||||||
funding_rate: Optional[float],
|
mark_price: Optional[float],
|
||||||
) -> float:
|
) -> float:
|
||||||
"""
|
"""
|
||||||
Calculates a single funding fee
|
Calculates a single funding fee
|
||||||
@ -245,9 +245,6 @@ class Binance(Exchange):
|
|||||||
if mark_price is None:
|
if mark_price is None:
|
||||||
raise OperationalException("Mark price cannot be None for Binance._get_funding_fee")
|
raise OperationalException("Mark price cannot be None for Binance._get_funding_fee")
|
||||||
nominal_value = mark_price * contract_size
|
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
|
return nominal_value * funding_rate
|
||||||
|
|
||||||
async def _async_get_historic_ohlcv(
|
async def _async_get_historic_ohlcv(
|
||||||
|
@ -1694,17 +1694,19 @@ class Exchange:
|
|||||||
self,
|
self,
|
||||||
pair: str,
|
pair: str,
|
||||||
contract_size: float,
|
contract_size: float,
|
||||||
|
funding_rate: float,
|
||||||
mark_price: float,
|
mark_price: float,
|
||||||
funding_rate: Optional[float]
|
|
||||||
) -> float:
|
) -> float:
|
||||||
"""
|
"""
|
||||||
Calculates a single funding fee
|
Calculates a single funding fee
|
||||||
:param contract_size: The amount/quanity
|
:param contract_size: The amount/quanity
|
||||||
:param mark_price: The price of the asset that the contract is based off of
|
:param mark_price: The price of the asset that the contract is based off of
|
||||||
:param funding_rate: the interest rate and the premium
|
:param funding_rate: the interest rate and the premium
|
||||||
|
- interest rate:
|
||||||
- premium: varies by price difference between the perpetual contract and mark price
|
- 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):
|
def fill_leverage_brackets(self):
|
||||||
"""
|
"""
|
||||||
|
@ -186,23 +186,4 @@ class Ftx(Exchange):
|
|||||||
return 20.0
|
return 20.0
|
||||||
|
|
||||||
def _get_funding_rate(self, pair: str, when: datetime) -> Optional[float]:
|
def _get_funding_rate(self, pair: str, when: datetime) -> Optional[float]:
|
||||||
"""FTX doesn't use this"""
|
raise OperationalException(f'_get_mark_price has not been implemented on {self.name}')
|
||||||
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
|
|
||||||
|
Loading…
Reference in New Issue
Block a user