lil
lil

Reputation: 1

Is it a way to cancel tp/sl with BiByt API

In the ByBit API, you can easily create TP/SL: https://bybit-exchange.github.io/docs/v5/position/trading-stop

But can it be removed?

I've come to the problems that there can only be 20 TP/SL a time, but I need to rearrange them, so it would be great if I could rearrange some of them.

I searched all the documentation, but there was nothing about it anywhere.

Upvotes: 0

Views: 357

Answers (2)

Tippman
Tippman

Reputation: 67

In my case setting takeProfit='0' 'stopLoss='0' raise and error "nothing change".

Solve the problem with getting open orders and filter them by closeOnTrigger key:

    open_orders = session.get_open_orders(
        category="linear",
        symbol="BTCUSDT",
    )['result']['list']

    [session.cancel_order(
        category="linear",
        symbol="BTCUSDT",
        orderId=o['orderId'],
    ) for o in open_orders if o['closeOnTrigger']]

Upvotes: 0

Naveed Ali
Naveed Ali

Reputation: 101

Creating TP/SL orders using trading-stop doesn't provide orderId, so when you don't have orderId you can't cancel it through their cancel order api.

You can cancel the TP/SL order using trading-stop API, just pass takeProfit='0' 'stopLoss='0'

takeProfit: Cannot be less than 0, 0 means cancel TP.

stopLoss: Cannot be less than 0, 0 means cancel SL

Upvotes: 0

Related Questions