fix: resolve Bybit Hedge Mode position idx error by adding positionIdx and settleCoin
This commit is contained in:
@ -152,7 +152,8 @@ class PingPongBot:
|
||||
# Get Position
|
||||
pos_response = self.session.get_positions(
|
||||
category="linear",
|
||||
symbol=self.symbol
|
||||
symbol=self.symbol,
|
||||
settleCoin="USDT"
|
||||
)
|
||||
|
||||
if pos_response['retCode'] == 0:
|
||||
@ -295,6 +296,9 @@ class PingPongBot:
|
||||
else:
|
||||
side = "Buy" if is_close else "Sell"
|
||||
|
||||
# Hedge Mode Index: 1 for Long, 2 for Short
|
||||
pos_idx = 1 if self.direction == "long" else 2
|
||||
|
||||
try:
|
||||
response = self.session.place_order(
|
||||
category="linear",
|
||||
@ -303,7 +307,8 @@ class PingPongBot:
|
||||
orderType="Market",
|
||||
qty=str(qty),
|
||||
timeInForce="GTC",
|
||||
reduceOnly=is_close
|
||||
reduceOnly=is_close,
|
||||
positionIdx=pos_idx
|
||||
)
|
||||
|
||||
if response['retCode'] == 0:
|
||||
|
||||
Reference in New Issue
Block a user