{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/clearstreet8e71/main/json-schema/clearstreet8e71-order-schema.json",
  "title": "Order",
  "description": "A trading order with its current state and execution details.\n\nThis is the unified API representation of an order across its lifecycle,\ncombining data from execution reports, order status queries, and parent/child tracking.",
  "x-generated": "2026-10-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/clearstreet8e71-openapi.yaml#/components/schemas/Order",
  "type": "object",
  "required": [
    "id",
    "client_order_id",
    "account_id",
    "venue",
    "side",
    "quantity",
    "order_type",
    "time_in_force",
    "status",
    "filled_quantity",
    "leaves_quantity",
    "created_at",
    "updated_at"
  ],
  "properties": {
    "account_id": {
      "$ref": "#/$defs/i64",
      "description": "Account placing the order"
    },
    "average_fill_price": {
      "type": [
        "string",
        "null"
      ],
      "description": "Average fill price across all executions. For multileg orders this is the venue's\nstrategy-level average when reported, else the signed net package price derived from\nthe leg averages: net debit positive, net credit negative, zero possible.\nWhen a null/undefined value is observed, it indicates that there is no available data."
    },
    "client_order_id": {
      "type": "string",
      "description": "Client-provided identifier echoed back."
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp when order was created (UTC)"
    },
    "details": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Contains execution, rejection or cancellation details, if any"
    },
    "expires_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Timestamp when the order will expire (UTC). Present when time_in_force is GOOD_TILL_DATE.\nWhen a null/undefined value is observed, it indicates it does not apply."
    },
    "extended_hours": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "Whether the order is eligible for extended-hours trading."
    },
    "filled_quantity": {
      "type": "string",
      "description": "Cumulative filled quantity"
    },
    "id": {
      "type": "string",
      "description": "Engine-assigned unique identifier for this order (UUID)."
    },
    "instrument_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Instrument identifier for the traded instrument. `null` when the order is a\nmultileg strategy whose legs are reported individually in `legs[]`.\nWhen a null/undefined value is observed, it indicates it does not apply."
    },
    "instrument_type": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/$defs/SecurityType",
          "description": "Type of security. `null` when the order is a multileg strategy whose legs are\nreported individually in `legs[]`.\nWhen a null/undefined value is observed, it indicates it does not apply."
        }
      ]
    },
    "leaves_quantity": {
      "type": "string",
      "description": "Remaining unfilled quantity"
    },
    "limit_offset": {
      "type": [
        "string",
        "null"
      ],
      "description": "Limit offset for trailing stop-limit orders (signed)\nWhen a null/undefined value is observed, it indicates it does not apply."
    },
    "limit_price": {
      "type": [
        "string",
        "null"
      ],
      "description": "Limit price (for LIMIT and STOP_LIMIT orders)\nWhen a null/undefined value is observed, it indicates it does not apply."
    },
    "order_type": {
      "$ref": "#/$defs/OrderType",
      "description": "Type of order (MARKET, LIMIT, etc.)"
    },
    "quantity": {
      "type": "string",
      "description": "Total order quantity"
    },
    "queue_state": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/$defs/QueueState",
          "description": "Parent order queue state, present when the order is awaiting release or released.\nWhen a null/undefined value is observed, it indicates it does not apply."
        }
      ]
    },
    "releases_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Scheduled release time for orders awaiting release.\nWhen a null/undefined value is observed, it indicates it does not apply."
    },
    "side": {
      "$ref": "#/$defs/Side",
      "description": "Side of the order (BUY or SELL)"
    },
    "status": {
      "$ref": "#/$defs/OrderStatus",
      "description": "Current status of the order"
    },
    "stop_price": {
      "type": [
        "string",
        "null"
      ],
      "description": "Stop price (for STOP and STOP_LIMIT orders)\nWhen a null/undefined value is observed, it indicates it does not apply."
    },
    "strategy": {
      "type": "object",
      "description": "The execution strategy the order was submitted with, if any.",
      "required": [
        "type"
      ],
      "properties": {
        "destination": {
          "type": "string",
          "description": "Venue code the order is routed to. DMA only."
        },
        "end_at": {
          "type": "string",
          "format": "date-time",
          "description": "UTC timestamp (RFC 3339) at which execution ends."
        },
        "start_at": {
          "type": "string",
          "format": "date-time",
          "description": "UTC timestamp (RFC 3339) at which execution begins."
        },
        "type": {
          "type": "string",
          "description": "Execution strategy type.",
          "enum": [
            "SOR",
            "VWAP",
            "TWAP",
            "DMA"
          ]
        }
      },
      "additionalProperties": true
    },
    "symbol": {
      "type": [
        "string",
        "null"
      ],
      "description": "Trading symbol. `null` when the order is a multileg strategy whose legs are\nreported individually in `legs[]`.\nWhen a null/undefined value is observed, it indicates it does not apply."
    },
    "time_in_force": {
      "$ref": "#/$defs/TimeInForce",
      "description": "Time in force instruction"
    },
    "trailing_limit_px": {
      "type": [
        "string",
        "null"
      ],
      "description": "Current trailing limit price computed by the trailing strategy\nWhen a null/undefined value is observed, it indicates it does not apply."
    },
    "trailing_offset": {
      "type": [
        "string",
        "null"
      ],
      "description": "Trailing offset amount for trailing orders\nWhen a null/undefined value is observed, it indicates it does not apply."
    },
    "trailing_offset_type": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/$defs/TrailingOffsetType",
          "description": "Trailing offset type for trailing orders\nWhen a null/undefined value is observed, it indicates it does not apply."
        }
      ]
    },
    "trailing_stop_px": {
      "type": [
        "string",
        "null"
      ],
      "description": "Current trailing stop price computed by the trailing strategy\nWhen a null/undefined value is observed, it indicates it does not apply."
    },
    "trailing_watermark_px": {
      "type": [
        "string",
        "null"
      ],
      "description": "Trailing watermark price for trailing orders. Strategy-computed, so it\nis absent on the order-submission acknowledgement and only appears\nonce fetched via the order fetch or list endpoints.\nWhen a null/undefined value is observed, it indicates it does not apply."
    },
    "trailing_watermark_ts": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Trailing watermark timestamp for trailing orders. Strategy-computed, so\nit is absent on the order-submission acknowledgement and only appears\nonce fetched via the order fetch or list endpoints.\nWhen a null/undefined value is observed, it indicates it does not apply."
    },
    "underlying_instrument_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Instrument ID of the option's underlying instrument. Populated only for\noptions orders. A `null` means one of two things: the order is not an\noption, so the field does not apply; or the order is an option whose\nunderlier has not yet been resolved.\nWhen a null/undefined value is observed, it indicates it does not apply."
    },
    "underlying_instrument_type": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/$defs/SecurityType",
          "description": "Type of the underlying instrument, alongside `underlying_instrument_id`.\nWhen a null/undefined value is observed, it indicates it does not apply."
        }
      ]
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp of the most recent update (UTC)"
    },
    "venue": {
      "type": "string",
      "description": "MIC code of the venue where the order is routed"
    }
  },
  "$defs": {
    "OrderStatus": {
      "type": "string",
      "description": "Order status",
      "enum": [
        "PENDING_NEW",
        "QUEUED",
        "PENDING_TRIGGER",
        "NEW",
        "PARTIALLY_FILLED",
        "FILLED",
        "CANCELED",
        "REJECTED",
        "EXPIRED",
        "PENDING_CANCEL",
        "PENDING_REPLACE",
        "REPLACED",
        "DONE_FOR_DAY",
        "STOPPED",
        "SUSPENDED",
        "CALCULATED",
        "OTHER"
      ]
    },
    "OrderType": {
      "type": "string",
      "description": "Order type",
      "enum": [
        "MARKET",
        "LIMIT",
        "STOP",
        "STOP_LIMIT",
        "TRAILING_STOP",
        "TRAILING_STOP_LIMIT",
        "OTHER"
      ]
    },
    "QueueState": {
      "type": "string",
      "description": "Parent order queue or hold state.",
      "enum": [
        "AWAITING_RELEASE",
        "RELEASED"
      ]
    },
    "SecurityType": {
      "type": "string",
      "description": "Security type",
      "enum": [
        "COMMON_STOCK",
        "INDEX",
        "OPTION",
        "CASH"
      ]
    },
    "Side": {
      "type": "string",
      "description": "Side of the order (BUY or SELL).",
      "enum": [
        "BUY",
        "SELL"
      ]
    },
    "TimeInForce": {
      "type": "string",
      "description": "Time in force",
      "enum": [
        "DAY",
        "GOOD_TILL_CANCEL",
        "IMMEDIATE_OR_CANCEL",
        "FILL_OR_KILL",
        "GOOD_TILL_DATE",
        "AT_OPEN",
        "AT_CLOSE",
        "OTHER"
      ]
    },
    "TrailingOffsetType": {
      "type": "string",
      "description": "Trailing offset type for trailing stop orders.",
      "enum": [
        "PRICE",
        "BPS"
      ]
    },
    "i64": {
      "type": "integer",
      "format": "int64"
    }
  }
}