How do I set a Stop Loss, Stop Loss Limit, Trailing Stop Loss or Take Profit order via the API?

I am trying to place a stop loss and take profit while opening a position, is that possible and if yes, how?
Please do not refer me back to the documentation, it does not help me.

Let’s say I want to open a position like this:
info = client.futures_create_order(
symbol=‘BNBUSDT’,
side=SIDE_BUY,
type=ORDER_TYPE_MARKET,
quantity=5,
)

Can I also create a stop loss in the same function call, or would I have to do that with a seperate function call?

After extensive trial and error I think I got the hang of the Trailing Stop Loss, however it seems even if the position is closed the TSL remains open, even if I pass reduceOnly=‘true’.

My code:
def trailing_stop_loss(symbol, price, quantity):

        symbol=symbol,
        type="TRAILING_STOP_MARKET",
        callbackRate=1,
        side=SIDE_SELL,
        quantity=quantity,
        activationPrice=price*1.01,
        reduceOnly='true'
    )

You can read this - How to implement OTOCO(TP/SL) orders using API

I have made it somewhat work, however I encounter a different issue now.
When my position gets closed i want my stop loss orders to be closed as well. I realized it like this:

    while True:
        orders = client.futures_get_open_orders(symbol=symbol)
        order_ids = [order['clientOrderId'] for order in orders]
        if client.futures_position_information(symbol=symbol)[0]['positionAmt'] == '0.0':
            client.futures_cancel_orders(symbol=symbol, origClientOrderIdList=order_ids, recvWindows=5000, timestamp=time.time()*1000)
            break;

This all works until I make the call to cancel the outstanding orders.
binance.exceptions.BinanceAPIException: APIError(code=-1022): Signature for this request is not valid.

What am, I doing wrong?

client.futures_cancel_all_open_orders(symbol=symbol)
Is working for me and I will just use that. Note sure why the other call failed tho,

Is this function that caused the error? If so, you didn’t use this endpoint right - https://binance-docs.github.io/apidocs/futures/en/#cancel-multiple-orders-trade

Try this. This is work for close multiple orders. you need to encode the list.

    orderList = f"%5B{orderId1}%2C{orderId2}%5D"

    try:
        return self.client.futures_cancel_orders(symbol=self.symbol, orderIdList=orderList)
    except BinanceAPIException as e:
        return e.message