{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/btse/main/json-schema/btse-twap-schema.json",
  "title": "Twap",
  "description": "TWAP order — slices a large order into smaller child orders spread across a time window",
  "x-generated": "2026-10-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/btse-spot-openapi.yml#/components/schemas/Twap",
  "allOf": [
    {
      "$ref": "#/$defs/PlaceAlgoOrderReq"
    },
    {
      "type": "object",
      "properties": {
        "symbol": {
          "type": "string",
          "description": "Trading pair, e.g. BTC-USDT"
        },
        "orderType": {
          "type": "string",
          "description": "TWAP",
          "enum": [
            "LIMIT",
            "MARKET",
            "PEG",
            "OCO",
            "TWAP",
            "CONDITIONAL",
            "TRAILING"
          ]
        },
        "orderSide": {
          "type": "string",
          "description": "BUY or SELL",
          "enum": [
            "BUY",
            "SELL"
          ]
        },
        "orderSize": {
          "type": "number",
          "format": "double",
          "description": "Total order quantity in base currency"
        },
        "timePeriod": {
          "type": "integer",
          "format": "int64",
          "description": "Total execution window in seconds"
        },
        "clOrderId": {
          "type": "string",
          "description": "Client-supplied order identifier, echoed in the response (max 64 characters)"
        },
        "makerFirst": {
          "type": "boolean",
          "description": "If true, place child orders as post-only first before falling back to taker"
        },
        "randomizeSize": {
          "type": "boolean",
          "description": "If true, randomize child order sizes to reduce predictability"
        },
        "subTwapMaxOrderSize": {
          "type": "number",
          "format": "double",
          "description": "Maximum size of each child order, in base currency"
        },
        "maxSpread": {
          "type": "number",
          "format": "double",
          "description": "Pause execution while the bid-ask spread exceeds this value"
        },
        "maxDistanceThroughBook": {
          "type": "number",
          "format": "double",
          "default": -1,
          "description": "0 to 1; omit or set negative to disable, defaults to -1 (disabled)"
        },
        "pausePrice": {
          "type": "number",
          "format": "double",
          "description": "Pause execution when the reference price crosses this level"
        },
        "activationTriggerPrice": {
          "type": "number",
          "format": "double",
          "description": "Delay execution until the market price reaches this level"
        },
        "activationTriggerPriceType": {
          "type": "string",
          "description": "Reference price for the activation trigger (LAST_PRICE, MARK_PRICE, or INDEX_PRICE)",
          "enum": [
            "INDEX_PRICE",
            "LAST_PRICE",
            "MARK_PRICE"
          ]
        }
      }
    }
  ],
  "required": [
    "orderSide",
    "orderSize",
    "orderType",
    "symbol",
    "timePeriod"
  ],
  "$defs": {
    "PlaceAlgoOrderReq": {
      "properties": {
        "orderType": {
          "type": "string"
        }
      },
      "required": [
        "orderType"
      ]
    }
  }
}