bybit - Updating stop-loss of an active short-position - Stack Overflow

Im using the Pybit module to trade on Bybit - and my problem is updating the trailing stop-loss of shor

Im using the Pybit module to trade on Bybit - and my problem is updating the trailing stop-loss of short-positions. When i want to update using the set_trading_stop-call, i get an 34040 errorcode and the websocket is closed. The problem appears to be related to the stopLoss parameter of the position being returned is None, whereas the long-positions have a valid stop-loss/what i set during the place-order-call.

The call i make when i open the positions:

        order = self.session.place_order(
            category="linear",
            symbol="BTCUSDT",
            side=direction,
            triggerDirection=trigger_direction,
            orderType="Market",
            triggerPrice=str(int(target)),
            stopLoss=str(int(stop_loss_price)),
            positionIdx=position_idx,
            timeInForce="GTC",
            qty=quantity
        )

So i enter a position with direction being either "Sell" or "Buy". I want to enter conditionally if price goes x dollars above or below current price - at a Market-order if it triggers. This works fine for entering the positions, but again, the stopLoss parameter is empty for all short-positions, and set_trading_stop doesnt seem to like updating a stopLoss of None.

Anyone seen this before?

Code for updating stoploss (short-positions):

                self.session.set_trading_stop(
                    category="linear",
                    positionIdx=2,
                    symbol=self.symbol,
                    stopLoss=str(int(new_stop_loss))
                )

Long-positions:

                self.session.set_trading_stop(
                    category="linear",
                    positionIdx=1,
                    symbol=self.symbol,
                    stopLoss=str(int(new_stop_loss))
                )

Im using the Pybit module to trade on Bybit - and my problem is updating the trailing stop-loss of short-positions. When i want to update using the set_trading_stop-call, i get an 34040 errorcode and the websocket is closed. The problem appears to be related to the stopLoss parameter of the position being returned is None, whereas the long-positions have a valid stop-loss/what i set during the place-order-call.

The call i make when i open the positions:

        order = self.session.place_order(
            category="linear",
            symbol="BTCUSDT",
            side=direction,
            triggerDirection=trigger_direction,
            orderType="Market",
            triggerPrice=str(int(target)),
            stopLoss=str(int(stop_loss_price)),
            positionIdx=position_idx,
            timeInForce="GTC",
            qty=quantity
        )

So i enter a position with direction being either "Sell" or "Buy". I want to enter conditionally if price goes x dollars above or below current price - at a Market-order if it triggers. This works fine for entering the positions, but again, the stopLoss parameter is empty for all short-positions, and set_trading_stop doesnt seem to like updating a stopLoss of None.

Anyone seen this before?

Code for updating stoploss (short-positions):

                self.session.set_trading_stop(
                    category="linear",
                    positionIdx=2,
                    symbol=self.symbol,
                    stopLoss=str(int(new_stop_loss))
                )

Long-positions:

                self.session.set_trading_stop(
                    category="linear",
                    positionIdx=1,
                    symbol=self.symbol,
                    stopLoss=str(int(new_stop_loss))
                )
Share Improve this question edited Mar 13 at 9:34 DarkBee 15.5k8 gold badges72 silver badges118 bronze badges asked Mar 7 at 8:50 shakalakkashakalakka 1011 gold badge1 silver badge8 bronze badges
Add a comment  | 

1 Answer 1

Reset to default -1

Seems like i fot a parameter that is required - yet it works without it for Long-positions, but not Short-positions.

                self.session.set_trading_stop(
                    category="linear",
                    positionIdx=2,
                    tpslMode="Full",
                    symbol=self.symbol,
                    stopLoss=str(int(new_stop_loss))
                )

Added the tpslMode="Full", and the stop is updated.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744940788a4602308.html

相关推荐

  • bybit - Updating stop-loss of an active short-position - Stack Overflow

    Im using the Pybit module to trade on Bybit - and my problem is updating the trailing stop-loss of shor

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信