_contract_size_to_amount only impacts limits.amount and not limits.cost, put _get_stake_amount_considering_leverage back in
This commit is contained in:
parent
ef6ad0e6d7
commit
2df5993812
@ -631,12 +631,8 @@ class Exchange:
|
|||||||
else:
|
else:
|
||||||
return 1 / pow(10, precision)
|
return 1 / pow(10, precision)
|
||||||
|
|
||||||
def get_min_pair_stake_amount(
|
def get_min_pair_stake_amount(self, pair: str, price: float, stoploss: float,
|
||||||
self,
|
leverage: Optional[float] = 1.0) -> Optional[float]:
|
||||||
pair: str,
|
|
||||||
price: float,
|
|
||||||
stoploss: float
|
|
||||||
) -> Optional[float]:
|
|
||||||
try:
|
try:
|
||||||
market = self.markets[pair]
|
market = self.markets[pair]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -653,7 +649,7 @@ class Exchange:
|
|||||||
|
|
||||||
if ('amount' in limits and 'min' in limits['amount']
|
if ('amount' in limits and 'min' in limits['amount']
|
||||||
and limits['amount']['min'] is not None):
|
and limits['amount']['min'] is not None):
|
||||||
min_stake_amounts.append(limits['amount']['min'] * price)
|
self._contract_size_to_amount(pair, min_stake_amounts.append(limits['amount']['min'] * price))
|
||||||
|
|
||||||
if not min_stake_amounts:
|
if not min_stake_amounts:
|
||||||
return None
|
return None
|
||||||
@ -670,11 +666,20 @@ class Exchange:
|
|||||||
# The value returned should satisfy both limits: for amount (base currency) and
|
# The value returned should satisfy both limits: for amount (base currency) and
|
||||||
# for cost (quote, stake currency), so max() is used here.
|
# for cost (quote, stake currency), so max() is used here.
|
||||||
# See also #2575 at github.
|
# See also #2575 at github.
|
||||||
return self._contract_size_to_amount(
|
return self._get_stake_amount_considering_leverage(
|
||||||
pair,
|
max(min_stake_amounts) * amount_reserve_percent,
|
||||||
max(min_stake_amounts) * amount_reserve_percent
|
leverage or 1.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _get_stake_amount_considering_leverage(self, stake_amount: float, leverage: float):
|
||||||
|
"""
|
||||||
|
Takes the minimum stake amount for a pair with no leverage and returns the minimum
|
||||||
|
stake amount when leverage is considered
|
||||||
|
:param stake_amount: The stake amount for a pair before leverage is considered
|
||||||
|
:param leverage: The amount of leverage being used on the current trade
|
||||||
|
"""
|
||||||
|
return stake_amount / leverage
|
||||||
|
|
||||||
# Dry-run methods
|
# Dry-run methods
|
||||||
|
|
||||||
def create_dry_run_order(self, pair: str, ordertype: str, side: str, amount: float,
|
def create_dry_run_order(self, pair: str, ordertype: str, side: str, amount: float,
|
||||||
|
Loading…
Reference in New Issue
Block a user