[Python] How to place an OTOCO order through the Binance API in Python

Discussão em 'Python' iniciado por Stack, Fevereiro 6, 2025.

  1. Stack

    Stack Membro Participativo

    Tried to submit the order detailed in params using

    response = requests.post(f"{base_url}/sapi/v1/margin/order/otoco", headers=headers, params=params)


    It goes through only if the "pendingBelow" data are provided, otherwise I get


    Error: 400, {"code":-1102,"msg":"Mandatory parameter 'pendingAboveType|pendingBelowType' was not sent, was empty/null, or malformed."}
    ​

    I just want a pending limit order. How to I do this or am I forced to provide, say, pendinBelowPrice=0? Also, if I place a similar SELL order, would I need to reverse the info, i.e. instead of adding data for pendingAbove?

    params = {
    "symbol": "BTCUSDT",
    "isIsolated": "FALSE",
    "sideEffectType": "MARGIN_BUY",
    "workingType": "LIMIT",
    "workingSide": "BUY",
    "workingPrice": 80000,
    "workingQuantity": 0.0002,
    "workingTimeInForce": "GTC",
    "pendingSide": "SELL",
    "pendingQuantity": 0.0002,
    "pendingAboveType": "LIMIT",
    "pendingAbovePrice": 110000,
    #"pendingBelowType": "STOP_LOSS_LIMIT",
    #"pendingBelowPrice": 70000,
    #"pendingBelowStopPrice": 60000,
    #"pendingBelowTimeInForce": "GTC",
    'timestamp': int(time.time() * 1000),
    }

    Continue reading...

Compartilhe esta Página