{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/finance-dev/json-schema/finance-dev-pred-orders-order-schema.json",
  "title": "PredOrdersOrder",
  "description": "An order as recorded by order entry. Submitted terms (`quantity`, `price`, …) never change; working terms (`workingQuantity`, `workingPrice`, …) are the venue's answer. Optional decimals and timestamps are omitted when absent, never zero.",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/finance-dev-openapi.json#/components/schemas/PredOrdersOrder",
  "properties": {
    "accountId": {
      "type": "string"
    },
    "avgPx": {
      "description": "Average fill price. Exact decimal as a string.",
      "type": "string"
    },
    "certainty": {
      "description": "How sure order entry is of `state`. Anything other than `certain` means the order's state could not be confirmed; `certaintyReason` says why.",
      "enum": [
        "certain",
        "unknown_unacked",
        "unknown_gap",
        "unknown_store_lost"
      ],
      "type": "string"
    },
    "certaintyReason": {
      "type": "string"
    },
    "clOrdId": {
      "description": "Client order ID sent to the venue.",
      "type": "string"
    },
    "clientOrderRef": {
      "type": "string"
    },
    "closedAt": {
      "format": "date-time",
      "type": "string"
    },
    "contract": {
      "allOf": [
        {
          "$ref": "#/$defs/PredOrdersContract"
        }
      ],
      "description": "The contract's event, label, question and lifecycle. `null` when the event catalogue does not know `symbol`, or cannot be read; it never fails the request.",
      "nullable": true
    },
    "createdAt": {
      "format": "date-time",
      "type": "string"
    },
    "cumQty": {
      "description": "Quantity filled so far. Exact decimal as a string.",
      "type": "string"
    },
    "expireTime": {
      "format": "date-time",
      "type": "string"
    },
    "firstAckAt": {
      "description": "When the venue first acknowledged the order.",
      "format": "date-time",
      "type": "string"
    },
    "leavesQty": {
      "description": "Quantity still working. Exact decimal as a string.",
      "type": "string"
    },
    "orderId": {
      "format": "uuid",
      "type": "string"
    },
    "orderType": {
      "type": "string"
    },
    "outcome": {
      "enum": [
        "YES",
        "NO"
      ],
      "type": "string"
    },
    "pendingAction": {
      "enum": [
        "none",
        "replace",
        "cancel"
      ],
      "type": "string"
    },
    "placedBy": {
      "description": "The user who placed the order.",
      "type": "string"
    },
    "price": {
      "description": "Exact decimal as a string.",
      "type": "string"
    },
    "quantity": {
      "description": "Exact decimal as a string.",
      "type": "string"
    },
    "rejectReason": {
      "type": "string"
    },
    "rejectText": {
      "description": "The venue's own rejection text. Most rejections carry their useful detail only here.",
      "type": "string"
    },
    "sentAt": {
      "format": "date-time",
      "type": "string"
    },
    "side": {
      "type": "string"
    },
    "state": {
      "description": "Order lifecycle state. `unknown` means order entry lost track of the order and says so rather than guessing; see `certainty`.",
      "enum": [
        "pending_new",
        "new",
        "partially_filled",
        "filled",
        "canceled",
        "rejected",
        "expired",
        "done_for_day",
        "unknown"
      ],
      "type": "string"
    },
    "stopPx": {
      "description": "Exact decimal as a string.",
      "type": "string"
    },
    "symbol": {
      "type": "string"
    },
    "timeInForce": {
      "type": "string"
    },
    "updatedAt": {
      "format": "date-time",
      "type": "string"
    },
    "venueOrderId": {
      "description": "Assigned by the venue on acknowledgement.",
      "type": "string"
    },
    "version": {
      "description": "Rises with every change to the order. On the order stream, keep the highest version seen per orderId and ignore anything at or below it.",
      "format": "int64",
      "type": "integer"
    },
    "workingOrderType": {
      "type": "string"
    },
    "workingPrice": {
      "description": "Exact decimal as a string.",
      "type": "string"
    },
    "workingQuantity": {
      "description": "Exact decimal as a string.",
      "type": "string"
    }
  },
  "required": [
    "orderId",
    "accountId",
    "symbol",
    "contract",
    "outcome",
    "side",
    "orderType",
    "timeInForce",
    "quantity",
    "workingQuantity",
    "state",
    "cumQty",
    "leavesQty",
    "avgPx",
    "createdAt",
    "updatedAt"
  ],
  "type": "object",
  "$defs": {
    "PredOrdersContract": {
      "description": "The contract an order or position is in, from the event catalogue. `settlementValue`, `resultOutcome` and `settledAt` appear once `state` is `SETTLED`.",
      "properties": {
        "description": {
          "description": "The contract's short readable label: its display name, else the venue's strike description, else its strike.",
          "type": "string"
        },
        "eventDisplayName": {
          "description": "The event's readable title, for cards and position details.",
          "type": "string"
        },
        "eventId": {
          "description": "The event the contract belongs to, for navigation and grouping.",
          "type": "string"
        },
        "question": {
          "description": "The contract's full question.",
          "type": "string"
        },
        "resultOutcome": {
          "description": "The winning outcome, when `settlementValue` is `1` or `0`. Only when `SETTLED`.",
          "enum": [
            "YES",
            "NO"
          ],
          "type": "string"
        },
        "settledAt": {
          "description": "When the contract settled. Only when `SETTLED`.",
          "format": "date-time",
          "type": "string"
        },
        "settlementValue": {
          "description": "What one YES contract pays, from 0 to 1, as an exact decimal string. One NO pays 1 less it. Only when `SETTLED`.",
          "type": "string"
        },
        "state": {
          "description": "`ACTIVE` while it trades, `CLOSED` once trading has ended and the result is not yet known, `SETTLED` once it is, and `DELETED` if the venue withdrew it. `CLOSED` and `SETTLED` are never left.",
          "enum": [
            "ACTIVE",
            "CLOSED",
            "SETTLED",
            "DELETED"
          ],
          "type": "string"
        }
      },
      "required": [
        "eventId",
        "eventDisplayName",
        "description",
        "question",
        "state"
      ],
      "type": "object"
    }
  }
}