Changed funding fee implementation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
""" Binance exchange subclass """
|
||||
import logging
|
||||
from typing import Dict, Optional
|
||||
from typing import Dict
|
||||
|
||||
import ccxt
|
||||
|
||||
@@ -89,17 +89,3 @@ class Binance(Exchange):
|
||||
f'Could not place sell order due to {e.__class__.__name__}. Message: {e}') from e
|
||||
except ccxt.BaseError as e:
|
||||
raise OperationalException(e) from e
|
||||
|
||||
# https://www.binance.com/en/support/faq/360033525031
|
||||
def get_funding_fee(
|
||||
self,
|
||||
contract_size: float,
|
||||
mark_price: float,
|
||||
rate: Optional[float],
|
||||
# index_price: float,
|
||||
# interest_rate: float
|
||||
):
|
||||
assert isinstance(rate, float)
|
||||
nominal_value = mark_price * contract_size
|
||||
adjustment = nominal_value * rate
|
||||
return adjustment
|
||||
|
@@ -1516,19 +1516,22 @@ class Exchange:
|
||||
self._async_get_trade_history(pair=pair, since=since,
|
||||
until=until, from_id=from_id))
|
||||
|
||||
def fetch_funding_rates(self):
|
||||
return self._api.fetch_funding_rates()
|
||||
|
||||
# https://www.binance.com/en/support/faq/360033525031
|
||||
def get_funding_fee(
|
||||
self,
|
||||
contract_size: float,
|
||||
mark_price: float,
|
||||
rate: Optional[float],
|
||||
# index_price: float,
|
||||
# interest_rate: float
|
||||
):
|
||||
raise OperationalException(f"{self.name} has not implemented get_funding_rate")
|
||||
def get_funding_fees(self, pair: str, since: datetime):
|
||||
try:
|
||||
funding_history = self._api.fetch_funding_history(
|
||||
pair=pair,
|
||||
since=since
|
||||
)
|
||||
# TODO: sum all the funding fees in funding_history together
|
||||
funding_fees = funding_history
|
||||
return funding_fees
|
||||
except ccxt.DDoSProtection as e:
|
||||
raise DDosProtection(e) from e
|
||||
except (ccxt.NetworkError, ccxt.ExchangeError) as e:
|
||||
raise TemporaryError(
|
||||
f'Could not get funding fees due to {e.__class__.__name__}. Message: {e}') from e
|
||||
except ccxt.BaseError as e:
|
||||
raise OperationalException(e) from e
|
||||
|
||||
|
||||
def is_exchange_known_ccxt(exchange_name: str, ccxt_module: CcxtModuleType = None) -> bool:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
""" FTX exchange subclass """
|
||||
import logging
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any, Dict
|
||||
|
||||
import ccxt
|
||||
|
||||
@@ -152,18 +152,3 @@ class Ftx(Exchange):
|
||||
if order['type'] == 'stop':
|
||||
return safe_value_fallback2(order, order, 'id_stop', 'id')
|
||||
return order['id']
|
||||
|
||||
# https://help.ftx.com/hc/en-us/articles/360027946571-Funding
|
||||
def get_funding_fee(
|
||||
self,
|
||||
contract_size: float,
|
||||
mark_price: float,
|
||||
rate: Optional[float],
|
||||
# index_price: float,
|
||||
# interest_rate: float
|
||||
):
|
||||
"""
|
||||
Always paid in USD on FTX # TODO: How do we account for this
|
||||
"""
|
||||
(contract_size * mark_price) / 24
|
||||
return
|
||||
|
Reference in New Issue
Block a user