Adjusted _get_funding_fee_method
This commit is contained in:
parent
cba0a8cee6
commit
badc0fa445
@ -242,12 +242,12 @@ class Binance(Exchange):
|
||||
- interest rate: 0.03% daily, BNBUSDT, LINKUSDT, and LTCUSDT are 0%
|
||||
- premium: varies by price difference between the perpetual contract and mark price
|
||||
"""
|
||||
if premium_index is None:
|
||||
raise OperationalException("Premium index cannot be None for Binance._get_funding_fee")
|
||||
if mark_price is None:
|
||||
raise OperationalException("Mark price cannot be None for Binance._get_funding_fee")
|
||||
nominal_value = mark_price * contract_size
|
||||
funding_rate = self._calculate_funding_rate(pair, premium_index)
|
||||
if funding_rate is None:
|
||||
raise OperationalException("Funding rate should never be none on Binance")
|
||||
raise OperationalException(
|
||||
"Funding rate should never be none on Binance._get_funding_fee")
|
||||
return nominal_value * funding_rate
|
||||
|
||||
async def _async_get_historic_ohlcv(self, pair: str, timeframe: str,
|
||||
|
@ -89,6 +89,7 @@ class Exchange:
|
||||
self._api: ccxt.Exchange = None
|
||||
self._api_async: ccxt_async.Exchange = None
|
||||
self._markets: Dict = {}
|
||||
self._leverage_brackets: Dict = {}
|
||||
|
||||
self._config.update(config)
|
||||
|
||||
@ -157,6 +158,9 @@ class Exchange:
|
||||
self._api_async = self._init_ccxt(
|
||||
exchange_config, ccxt_async, ccxt_kwargs=ccxt_async_config)
|
||||
|
||||
if self.trading_mode != TradingMode.SPOT:
|
||||
self.fill_leverage_brackets()
|
||||
|
||||
logger.info('Using Exchange "%s"', self.name)
|
||||
|
||||
if validate:
|
||||
@ -179,10 +183,6 @@ class Exchange:
|
||||
self.markets_refresh_interval: int = exchange_config.get(
|
||||
"markets_refresh_interval", 60) * 60
|
||||
|
||||
self._leverage_brackets: Dict = {}
|
||||
if self.trading_mode != TradingMode.SPOT:
|
||||
self.fill_leverage_brackets()
|
||||
|
||||
def __del__(self):
|
||||
"""
|
||||
Destructor - clean up async stuff
|
||||
@ -1635,30 +1635,6 @@ class Exchange:
|
||||
except ccxt.BaseError as e:
|
||||
raise OperationalException(e) from e
|
||||
|
||||
def fill_leverage_brackets(self):
|
||||
"""
|
||||
Assigns property _leverage_brackets to a dictionary of information about the leverage
|
||||
allowed on each pair
|
||||
Not used if the exchange has a static max leverage value for the account or each pair
|
||||
"""
|
||||
return
|
||||
|
||||
def get_max_leverage(self, pair: Optional[str], nominal_value: Optional[float]) -> float:
|
||||
"""
|
||||
Returns the maximum leverage that a pair can be traded at
|
||||
:param pair: The base/quote currency pair being traded
|
||||
:nominal_value: The total value of the trade in quote currency (collateral + debt)
|
||||
"""
|
||||
market = self.markets[pair]
|
||||
if (
|
||||
'limits' in market and
|
||||
'leverage' in market['limits'] and
|
||||
'max' in market['limits']['leverage']
|
||||
):
|
||||
return market['limits']['leverage']['max']
|
||||
else:
|
||||
return 1.0
|
||||
|
||||
def _get_mark_price(self, pair: str, date: datetime) -> float:
|
||||
raise OperationalException(f'_get_mark_price has not been implemented on {self.name}')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user