bybit-market-maker
bybit-market-maker copied to clipboard
Error When trying to modify SL
Hey all, I'm trying to implement a system where there are multiple TP levels and everytime the price reaches those levels the SL will move upwards like to entry, tp1 and so on. I've been using the amend method and I get this issue. From what I see the order is placed with the original TP and SL.
# Place the order for entry 1
orderlinkid_entry1 = f"t{int(time.time())}-test-postonly"
response_entry1 = session.place_order(
category="linear",
symbol=coin,
side=side,
orderType="Limit",
qty=str(formatted_qty),
price=entry1,
timeInForce="PostOnly",
orderlinkid=orderlinkid_entry1,
isLeverage=1,
orderFilter="Order",
takeProfit=str(tp5), # Target 5
stopLoss=str(sl), # SL
tpTriggerBy="MarkPrice",
slTriggerB="IndexPrice",
tpslMode="Partial",
tpOrderType="Limit",
slOrderType="Limit",
tpSize="20",
slSize="100",
tpLimitPrice=str(tp1),
slLimitPrice=str(sl), # SL
)
## Amending Stop Loss to Entry as soon as TP1 is reached
print(session.amend_order(
category="linear",
symbol=coin,
orderLinkId=orderlinkid_entry1,
triggerPrice=str(tp1),
stopLoss=str(entry1),
))
Error Message :
pybit.exceptions.InvalidRequestError: order not exists or too late to replace (ErrCode: 110001) (ErrTime: 04:33:13).
Request → POST https://api-testnet.bybit.com/v5/order/amend: {"category": "linear", "symbol": "CHZUSDT", "orderLinkId": "t1701664392-test-postonly", "triggerPrice": "0.0778", "stopLoss": "0.0735"}.