{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/woox/main/json-schema/woox-stop-bracket-stop-bracket-schema.json",
  "title": "Stop bracket",
  "x-generated": "2026-10-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/woox-openapi.json#/components/schemas/stop_bracket_stop_bracket",
  "allOf": [
    {
      "$ref": "#/$defs/common_algo_common_algo"
    },
    {
      "type": "object",
      "required": [
        "type",
        "price",
        "childOrders"
      ],
      "properties": {
        "algoType": {
          "type": "string",
          "description": "STOP_BRACKET: bracket order with stop market or stop limit order as the initial order and an attached POSITIONAL_TP_SL or TP_SL order"
        },
        "type": {
          "type": "string",
          "description": "LIMIT/MARKET"
        },
        "price": {
          "type": "string",
          "description": "Order price, only applicable if LIMIT order"
        },
        "reduceOnly": {
          "type": "boolean",
          "description": "Only applicable to perpetual instruments; whether the LIMIT/MARKET order can only reduce in position size; only support false for STOP_BRACKET orders"
        },
        "triggerPrice": {
          "type": "string",
          "description": "Trigger price of the initial stop order"
        },
        "triggerPriceType": {
          "type": "string",
          "description": "Trigger price type of the initial stop order, currently only support MARKET_PRICE (i.e. last price)"
        },
        "childOrders": {
          "type": "array",
          "description": "Attached TP/SL orders, only support 1 set of POSITIONAL_TP_SL or TP_SL",
          "items": {
            "type": "object",
            "properties": {
              "algoType": {
                "type": "string",
                "description": "POSITIONAL_TP_SL/TP_SL"
              },
              "childOrders": {
                "type": "array",
                "description": "Details of the TP/SL information, can contain at most 1 TAKE_PROFIT and 1 STOP_LOSS",
                "items": {
                  "type": "object",
                  "properties": {
                    "algoType": {
                      "type": "string",
                      "description": "TAKE_PROFIT/STOP_LOSS"
                    },
                    "side": {
                      "type": "string",
                      "description": "Required to be SELL if side of the initial order is BUY;  Required to be BUY if side of the initial order is SELL"
                    },
                    "triggerPrice": {
                      "type": "string",
                      "description": "Trigger price of the TP/SL"
                    },
                    "triggerPriceType": {
                      "type": "string",
                      "description": "Trigger price type, currently only support MARKET_PRICE (i.e. last price)"
                    },
                    "type": {
                      "type": "string",
                      "description": "CLOSE_POSITION for POSITIONAL_TP_SL; MARKET for TP_SL"
                    }
                  },
                  "required": [
                    "algoType",
                    "side",
                    "triggerPrice",
                    "type"
                  ]
                }
              }
            },
            "required": [
              "algoType",
              "childOrders"
            ]
          }
        }
      }
    }
  ],
  "$defs": {
    "common_algo_common_algo": {
      "type": "object",
      "required": [
        "symbol",
        "algoType"
      ],
      "properties": {
        "symbol": {
          "type": "string",
          "description": "Symbol name"
        },
        "clientAlgoOrderId": {
          "type": "integer",
          "description": "Client algo order Id as assigned by the user"
        },
        "algoOrderTag": {
          "type": "string",
          "description": "An optional tag for this order, max string length: 64"
        },
        "side": {
          "type": "string",
          "description": "BUY/SELL, not required for POSITIONAL_TP_SL or TP_SL order"
        },
        "positionSide": {
          "type": "string",
          "description": "BOTH for one way mode; LONG or SHORT for hedge mode;  Only applicable to perpetual instruments"
        },
        "quantity": {
          "type": "string",
          "description": "Order quantity, not required for POSITIONAL_TP_SL order"
        },
        "visibleQuantity": {
          "type": "string",
          "description": "The order quantity shown on orderbook;  for POSITIONAL_TP_SL order, visibleQuantity applies directly to the child orders"
        },
        "marginMode": {
          "type": "string",
          "description": "CROSS / ISOLATED"
        }
      }
    }
  }
}