Add stoploss tests for kucoin
This commit is contained in:
@@ -836,6 +836,7 @@ class Exchange:
|
||||
if stop_price_norm <= rate:
|
||||
raise OperationalException(
|
||||
'In stoploss limit order, stop price should be more than limit price')
|
||||
rate = self.price_to_precision(pair, rate)
|
||||
|
||||
if self._config['dry_run']:
|
||||
# TODO: will this work if ordertype is limit??
|
||||
@@ -848,8 +849,6 @@ class Exchange:
|
||||
|
||||
amount = self.amount_to_precision(pair, amount)
|
||||
|
||||
rate = self.price_to_precision(pair, rate)
|
||||
|
||||
order = self._api.create_order(symbol=pair, type=ordertype, side='sell',
|
||||
amount=amount, price=rate, params=params)
|
||||
logger.info(f"stoploss {user_order_type} order added for {pair}. "
|
||||
@@ -872,7 +871,8 @@ class Exchange:
|
||||
raise DDosProtection(e) from e
|
||||
except (ccxt.NetworkError, ccxt.ExchangeError) as e:
|
||||
raise TemporaryError(
|
||||
f'Could not place stoploss order due to {e.__class__.__name__}. Message: {e}') from e
|
||||
f"Could not place stoploss order due to {e.__class__.__name__}. "
|
||||
f"Message: {e}") from e
|
||||
except ccxt.BaseError as e:
|
||||
raise OperationalException(e) from e
|
||||
|
||||
|
@@ -33,7 +33,7 @@ class Kucoin(Exchange):
|
||||
Returns True if adjustment is necessary.
|
||||
"""
|
||||
# TODO: since kucoin uses Limit orders, changes to models will be required.
|
||||
return order['info']['stop'] is not None and stop_loss > float(order['stopPrice'])
|
||||
return order['info'].get('stop') is not None and stop_loss > float(order['stopPrice'])
|
||||
|
||||
def _get_stop_params(self, ordertype: str, stop_price: float) -> Dict:
|
||||
|
||||
|
Reference in New Issue
Block a user