Chilkat Online Tools

Swift / Binance spot API / Margin Account Cancel OCO (TRADE)

Back to Collection Items

func chilkatTest() {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()
    var success: Bool

    http.SetRequestHeader("Content-Type", value: "application/json")
    http.SetRequestHeader("X-MBX-APIKEY", value: "{{binance-api-key}}")

    var resp: CkoHttpResponse? = http.QuickRequest("DELETE", url: "https://domain.com/sapi/v1/margin/orderList?symbol=BNBUSDT×tamp={{timestamp}}&signature={{signature}}")
    if http.LastMethodSuccess == false {
        print("\(http.LastErrorText)")
        return
    }

    print("\(resp!.StatusCode.intValue)")
    print("\(resp!.BodyStr)")
    resp = nil

}

Curl Command

curl -X DELETE
	-H "Content-Type: application/json"
	-H "X-MBX-APIKEY: {{binance-api-key}}"
https://domain.com/sapi/v1/margin/orderList?symbol=BNBUSDT&timestamp={{timestamp}}&signature={{signature}}

Postman Collection Item JSON

{
  "name": "Margin Account Cancel OCO (TRADE)",
  "request": {
    "method": "DELETE",
    "header": [
      {
        "key": "Content-Type",
        "type": "text",
        "value": "application/json"
      },
      {
        "key": "X-MBX-APIKEY",
        "value": "{{binance-api-key}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "{{url}}/sapi/v1/margin/orderList?symbol=BNBUSDT&timestamp={{timestamp}}&signature={{signature}}",
      "host": [
        "{{url}}"
      ],
      "path": [
        "sapi",
        "v1",
        "margin",
        "orderList"
      ],
      "query": [
        {
          "key": "symbol",
          "value": "BNBUSDT",
          "description": "Trading symbol, e.g. BNBUSDT"
        },
        {
          "key": "isIsolated",
          "value": "",
          "description": "* `TRUE` - For isolated margin\n* `FALSE` - Default, not for isolated margin",
          "disabled": true
        },
        {
          "key": "orderListId",
          "value": "",
          "description": "Order list id",
          "disabled": true
        },
        {
          "key": "listClientOrderId",
          "value": "",
          "description": "A unique Id for the entire orderList",
          "disabled": true
        },
        {
          "key": "newClientOrderId",
          "value": "",
          "description": "Used to uniquely identify this cancel. Automatically generated by default",
          "disabled": true
        },
        {
          "key": "recvWindow",
          "value": "5000",
          "description": "The value cannot be greater than 60000",
          "disabled": true
        },
        {
          "key": "timestamp",
          "value": "{{timestamp}}",
          "description": "UTC timestamp in ms"
        },
        {
          "key": "signature",
          "value": "{{signature}}",
          "description": "Signature"
        }
      ]
    },
    "description": "Cancel an entire Order List for a margin account\n\n- Canceling an individual leg will cancel the entire OCO\n- Either `orderListId` or `listClientOrderId` must be provided\n\nWeight(UID): 1"
  },
  "response": [
  ]
}