{
  "$id": "https://bloomberg.com/schemas/order.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Order",
  "description": "A trading order within Bloomberg AIM/EMSX, representing an instruction to buy or sell a financial instrument with specified parameters.",
  "type": "object",
  "required": [
    "sequenceNumber",
    "ticker",
    "side",
    "amount",
    "orderType",
    "timeInForce"
  ],
  "properties": {
    "sequenceNumber": {
      "type": "integer",
      "description": "Unique EMSX order sequence number assigned by the system"
    },
    "ticker": {
      "type": "string",
      "description": "Bloomberg security identifier for the order",
      "examples": [
        "IBM US Equity",
        "AAPL US Equity"
      ]
    },
    "side": {
      "type": "string",
      "description": "Order side indicating direction of the trade",
      "enum": [
        "BUY",
        "SELL",
        "SHRT"
      ]
    },
    "amount": {
      "type": "integer",
      "description": "Total order quantity (shares or contracts)",
      "minimum": 1
    },
    "orderType": {
      "type": "string",
      "description": "Type of order determining execution behavior",
      "enum": [
        "MKT",
        "LMT",
        "STP",
        "STP LMT"
      ]
    },
    "limitPrice": {
      "type": "number",
      "description": "Limit price for LMT and STP LMT orders"
    },
    "stopPrice": {
      "type": "number",
      "description": "Stop trigger price for STP and STP LMT orders"
    },
    "timeInForce": {
      "type": "string",
      "description": "Duration the order remains active",
      "enum": [
        "DAY",
        "GTC",
        "OPG",
        "IOC",
        "FOK",
        "GTD",
        "MOC",
        "LOC"
      ]
    },
    "gtdDate": {
      "type": "string",
      "format": "date",
      "description": "Expiry date for Good-Till-Date orders"
    },
    "status": {
      "type": "string",
      "description": "Current order status",
      "enum": [
        "ASSIGN",
        "CANCEL",
        "CONNECTED",
        "CXL_PND",
        "DONE",
        "EXPIRED",
        "FILL",
        "MOD_PND",
        "NEW",
        "PART_FILL",
        "RJCT",
        "SENT",
        "WORKING"
      ]
    },
    "filledAmount": {
      "type": "integer",
      "description": "Cumulative quantity filled across all routes",
      "minimum": 0,
      "default": 0
    },
    "workingAmount": {
      "type": "integer",
      "description": "Quantity currently working (routed but not yet filled)",
      "minimum": 0,
      "default": 0
    },
    "averagePrice": {
      "type": "number",
      "description": "Volume-weighted average fill price"
    },
    "account": {
      "type": "string",
      "description": "Trading account identifier"
    },
    "portfolio": {
      "type": "string",
      "description": "Portfolio name associated with the order"
    },
    "trader": {
      "type": "string",
      "description": "Trader responsible for the order"
    },
    "traderUuid": {
      "type": "string",
      "description": "UUID of the assigned trader"
    },
    "basketName": {
      "type": "string",
      "description": "Name of the basket this order belongs to"
    },
    "handInstruction": {
      "type": "string",
      "description": "Handling instruction for the order",
      "enum": [
        "ANY",
        "DIR",
        "FCM"
      ]
    },
    "investorId": {
      "type": "string",
      "description": "Investor identifier for allocation purposes"
    },
    "notes": {
      "type": "string",
      "description": "Free-text notes attached to the order"
    },
    "customNote1": {
      "type": "string",
      "description": "Custom note field 1"
    },
    "customNote2": {
      "type": "string",
      "description": "Custom note field 2"
    },
    "customNote3": {
      "type": "string",
      "description": "Custom note field 3"
    },
    "customNote4": {
      "type": "string",
      "description": "Custom note field 4"
    },
    "customNote5": {
      "type": "string",
      "description": "Custom note field 5"
    },
    "cfdFlag": {
      "type": "boolean",
      "description": "Whether this is a contract for difference order",
      "default": false
    },
    "locateBroker": {
      "type": "string",
      "description": "Locate broker for short sell orders"
    },
    "locateId": {
      "type": "string",
      "description": "Locate ID for short sell orders"
    },
    "createdDate": {
      "type": "string",
      "format": "date",
      "description": "Date the order was created"
    },
    "lastUpdated": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp of last order update"
    },
    "routes": {
      "type": "array",
      "description": "Routes associated with this order",
      "items": {
        "$ref": "https://bloomberg.com/schemas/trade.json"
      }
    }
  },
  "additionalProperties": false
}
