okex.get_max_pair_stake_amount
This commit is contained in:
@@ -692,13 +692,14 @@ class Exchange:
|
||||
self,
|
||||
pair: str,
|
||||
price: float,
|
||||
leverage: float = 1.0
|
||||
) -> float:
|
||||
max_stake_amount = self._get_stake_amount_limit(pair, price, 0.0, 'max')
|
||||
if max_stake_amount is None:
|
||||
# * Should never be executed
|
||||
raise OperationalException(f'{self.name}.get_max_pair_stake_amount should'
|
||||
'never set max_stake_amount to None')
|
||||
return max_stake_amount
|
||||
return max_stake_amount / leverage
|
||||
|
||||
def _get_stake_amount_limit(
|
||||
self,
|
||||
|
@@ -49,3 +49,23 @@ class Okx(Exchange):
|
||||
|
||||
def get_leverage_tiers(self, pair: str):
|
||||
return self._api.fetch_leverage_tiers(pair)
|
||||
|
||||
def get_max_pair_stake_amount(
|
||||
self,
|
||||
pair: str,
|
||||
price: float,
|
||||
leverage: float = 1.0
|
||||
) -> float:
|
||||
|
||||
if self.trading_mode == TradingMode.SPOT:
|
||||
return float('inf') # Not actually inf, but this probably won't matter for SPOT
|
||||
|
||||
if pair not in self._leverage_tiers:
|
||||
tiers = self.get_leverage_tiers_for_pair(pair)
|
||||
if not tiers: # Not a leveraged market
|
||||
return float('inf')
|
||||
else:
|
||||
self._leverage_tiers[pair] = tiers
|
||||
|
||||
pair_tiers = self._leverage_tiers[pair]
|
||||
return pair_tiers[-1]['max'] / leverage
|
||||
|
Reference in New Issue
Block a user