Use conditional orders for stop orders
This commit is contained in:
parent
6c5dc7e0a9
commit
d84ece7258
@ -164,14 +164,17 @@ class Okx(Exchange):
|
|||||||
|
|
||||||
def _get_stop_params(self, side: BuySell, ordertype: str, stop_price: float) -> Dict:
|
def _get_stop_params(self, side: BuySell, ordertype: str, stop_price: float) -> Dict:
|
||||||
|
|
||||||
params = super()._get_stop_params(side, ordertype, stop_price)
|
params = self._params.copy()
|
||||||
|
# Verify if stopPrice works for your exchange!
|
||||||
|
params.update({'stopLossPrice': stop_price})
|
||||||
|
|
||||||
if self.trading_mode == TradingMode.FUTURES and self.margin_mode:
|
if self.trading_mode == TradingMode.FUTURES and self.margin_mode:
|
||||||
params['tdMode'] = self.margin_mode.value
|
params['tdMode'] = self.margin_mode.value
|
||||||
params['posSide'] = self._get_posSide(side, True)
|
params['posSide'] = self._get_posSide(side, True)
|
||||||
return params
|
return params
|
||||||
|
|
||||||
def fetch_stoploss_order(self, order_id: str, pair: str, params: Dict = {}) -> Dict:
|
def fetch_stoploss_order(self, order_id: str, pair: str, params: Dict = {}) -> Dict:
|
||||||
params1 = {'stop': True, 'ordType': 'trigger'}
|
params1 = {'stop': True, 'ordType': 'conditional'}
|
||||||
for method in (self._api.fetch_open_orders, self._api.fetch_closed_orders,
|
for method in (self._api.fetch_open_orders, self._api.fetch_closed_orders,
|
||||||
self._api.fetch_canceled_orders):
|
self._api.fetch_canceled_orders):
|
||||||
try:
|
try:
|
||||||
@ -204,5 +207,5 @@ class Okx(Exchange):
|
|||||||
return self.cancel_order(
|
return self.cancel_order(
|
||||||
order_id=order_id,
|
order_id=order_id,
|
||||||
pair=pair,
|
pair=pair,
|
||||||
params={'stop': True}
|
params={'ordType': 'conditional'}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user