changed kraken set lev implementation

This commit is contained in:
Sam Germain
2021-09-15 21:55:19 -06:00
parent 47677ccd91
commit cbaf477bec
4 changed files with 22 additions and 21 deletions

View File

@@ -775,6 +775,13 @@ class Exchange:
self.set_margin_mode(pair, self.collateral)
self._set_leverage(leverage, pair)
def _get_params(self, time_in_force: str, ordertype: str, leverage: float) -> Dict:
params = self._params.copy()
if time_in_force != 'gtc' and ordertype != 'market':
param = self._ft_has.get('time_in_force_parameter', '')
params.update({param: time_in_force})
return params
def create_order(self, pair: str, ordertype: str, side: str, amount: float,
rate: float, time_in_force: str = 'gtc', leverage=1.0) -> Dict:
@@ -784,10 +791,8 @@ class Exchange:
if self.trading_mode != TradingMode.SPOT:
self.lev_prep(pair, leverage)
params = self._params.copy()
if time_in_force != 'gtc' and ordertype != 'market':
param = self._ft_has.get('time_in_force_parameter', '')
params.update({param: time_in_force})
params = self._get_params(time_in_force, ordertype, leverage)
try:
# Set the precision for amount and price(rate) as accepted by the exchange

View File

@@ -182,8 +182,10 @@ class Kraken(Exchange):
Kraken set's the leverage as an option in the order object, so we need to
add it to params
"""
return
def _get_params(self, time_in_force: str, ordertype: str, leverage: float) -> Dict:
params = super()._get_params(time_in_force, ordertype, leverage)
if leverage > 1.0:
self._params['leverage'] = leverage
else:
if 'leverage' in self._params:
del self._params['leverage']
params['leverage'] = leverage
return params