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
1 Answer
Reset to default -1Seems 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
评论列表(0条)