changed kraken set lev implementation
This commit is contained in:
parent
47677ccd91
commit
cbaf477bec
@ -775,6 +775,13 @@ class Exchange:
|
|||||||
self.set_margin_mode(pair, self.collateral)
|
self.set_margin_mode(pair, self.collateral)
|
||||||
self._set_leverage(leverage, pair)
|
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,
|
def create_order(self, pair: str, ordertype: str, side: str, amount: float,
|
||||||
rate: float, time_in_force: str = 'gtc', leverage=1.0) -> Dict:
|
rate: float, time_in_force: str = 'gtc', leverage=1.0) -> Dict:
|
||||||
|
|
||||||
@ -784,10 +791,8 @@ class Exchange:
|
|||||||
|
|
||||||
if self.trading_mode != TradingMode.SPOT:
|
if self.trading_mode != TradingMode.SPOT:
|
||||||
self.lev_prep(pair, leverage)
|
self.lev_prep(pair, leverage)
|
||||||
params = self._params.copy()
|
|
||||||
if time_in_force != 'gtc' and ordertype != 'market':
|
params = self._get_params(time_in_force, ordertype, leverage)
|
||||||
param = self._ft_has.get('time_in_force_parameter', '')
|
|
||||||
params.update({param: time_in_force})
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Set the precision for amount and price(rate) as accepted by the exchange
|
# Set the precision for amount and price(rate) as accepted by the exchange
|
||||||
|
@ -182,8 +182,10 @@ class Kraken(Exchange):
|
|||||||
Kraken set's the leverage as an option in the order object, so we need to
|
Kraken set's the leverage as an option in the order object, so we need to
|
||||||
add it to params
|
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:
|
if leverage > 1.0:
|
||||||
self._params['leverage'] = leverage
|
params['leverage'] = leverage
|
||||||
else:
|
return params
|
||||||
if 'leverage' in self._params:
|
|
||||||
del self._params['leverage']
|
|
||||||
|
@ -1110,7 +1110,13 @@ def test_create_order(default_conf, mocker, side, ordertype, rate, marketprice,
|
|||||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name)
|
exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name)
|
||||||
|
|
||||||
order = exchange.create_order(
|
order = exchange.create_order(
|
||||||
pair='ETH/BTC', ordertype=ordertype, side=side, amount=1, rate=200)
|
pair='ETH/BTC',
|
||||||
|
ordertype=ordertype,
|
||||||
|
side=side,
|
||||||
|
amount=1,
|
||||||
|
rate=200,
|
||||||
|
leverage=3.0
|
||||||
|
)
|
||||||
|
|
||||||
assert 'id' in order
|
assert 'id' in order
|
||||||
assert 'info' in order
|
assert 'info' in order
|
||||||
|
@ -305,15 +305,3 @@ def test_fill_leverage_brackets_kraken(default_conf, mocker):
|
|||||||
'XLTCUSDT': [1],
|
'XLTCUSDT': [1],
|
||||||
'LTC/ETH': [1]
|
'LTC/ETH': [1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def test__set_leverage_kraken(default_conf, mocker):
|
|
||||||
exchange = get_patched_exchange(mocker, default_conf, id="kraken")
|
|
||||||
exchange._set_leverage(1)
|
|
||||||
assert 'leverage' not in exchange._params
|
|
||||||
exchange._set_leverage(3)
|
|
||||||
assert exchange._params['leverage'] == 3
|
|
||||||
exchange._set_leverage(1.0)
|
|
||||||
assert 'leverage' not in exchange._params
|
|
||||||
exchange._set_leverage(3.0)
|
|
||||||
assert exchange._params['leverage'] == 3
|
|
||||||
|
Loading…
Reference in New Issue
Block a user