{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/tradingview/json-schema/tradingview-orders-response-schema.json",
  "title": "OrdersResponse",
  "x-generated": "2026-11-05",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/tradingview-broker-rest-api-openapi.yml#/components/schemas/OrdersResponse",
  "type": "object",
  "properties": {
    "s": {
      "$ref": "#/$defs/OkStatus"
    },
    "d": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Order"
      }
    }
  },
  "required": [
    "s",
    "d"
  ],
  "additionalProperties": false,
  "$defs": {
    "CustomFieldsValueItem": {
      "title": "CustomFieldsValueItem",
      "type": "object",
      "properties": {
        "id": {
          "description": "Column identifier as defined in [/config](#operation/getConfiguration) response.",
          "type": "string"
        },
        "value": {
          "description": "Localized column value",
          "type": "string"
        }
      },
      "required": [
        "id",
        "value"
      ],
      "additionalProperties": false
    },
    "OkStatus": {
      "title": "OkStatus",
      "type": "string",
      "description": "Status will always be `ok`.",
      "enum": [
        "ok"
      ]
    },
    "Order": {
      "title": "Order",
      "allOf": [
        {
          "$ref": "#/$defs/OrderCommon"
        },
        {
          "$ref": "#/$defs/OrderStatus"
        }
      ]
    },
    "OrderCommon": {
      "title": "OrderCommon",
      "type": "object",
      "properties": {
        "id": {
          "description": "Unique identifier.",
          "type": "string"
        },
        "instrument": {
          "description": "Instrument name that is used on a broker's side.",
          "type": "string"
        },
        "qty": {
          "description": "Quantity.",
          "type": "number"
        },
        "side": {
          "description": "Side.",
          "type": "string",
          "enum": [
            "buy",
            "sell"
          ]
        },
        "type": {
          "description": "Type.",
          "type": "string",
          "enum": [
            "market",
            "stop",
            "limit",
            "stoplimit"
          ]
        },
        "filledQty": {
          "description": "Filled quantity.",
          "type": "number"
        },
        "avgPrice": {
          "description": "Average price of order fills. It should be provided for filled / partly filled orders.\n",
          "type": "number"
        },
        "limitPrice": {
          "description": "Limit Price for Limit or StopLimit orders only. You should not send this field for other order types.",
          "type": "number"
        },
        "stopPrice": {
          "description": "Stop Price for Stop or StopLimit orders only. You should not send this field for other order types.",
          "type": "number"
        },
        "trailingStopPips": {
          "description": "Distance from the stop loss level to the current market price in pips for a position or to the order price if the parent is a stop or limit order.",
          "type": "number"
        },
        "isTrailingStop": {
          "description": "If this flag is set to `true`, then the stop order is a trailing stop.",
          "type": "boolean"
        },
        "isGuaranteedStop": {
          "description": "If this flag is set to `true`, then the stop order is a guaranteed stop.",
          "type": "boolean"
        },
        "parentId": {
          "description": "Identifier of a parent order or a parent position (for position brackets) depending on `parentType`.\nShould be set only for bracket orders.\n",
          "type": "string"
        },
        "parentType": {
          "description": "Type of order's parent. Should be set only for bracket orders.",
          "type": "string",
          "enum": [
            "order",
            "position"
          ]
        },
        "duration": {
          "description": "Expiration type and Unix timestamp date/time.",
          "type": "object",
          "properties": {
            "type": {
              "description": "Duration ID. Internal ID that you set in [/config](#operation/getConfiguration) response.",
              "type": "string"
            },
            "datetime": {
              "description": "Unix timestamp (UTC).",
              "type": "number"
            }
          },
          "required": [
            "type"
          ]
        },
        "lastModified": {
          "description": "Indicates the time when the order was last modified, Unix timestamp (UTC).",
          "type": "number"
        },
        "customFields": {
          "type": "array",
          "description": "Localized order custom fields values data.\nCustom fields are configured in the [/config](#operation/getConfiguration) endpoint response.\nCustom `Order dialog` fields are to be sent along with the standard fields in the order object.\n",
          "items": {
            "$ref": "#/$defs/CustomFieldsValueItem"
          },
          "minItems": 1
        },
        "message": {
          "$ref": "#/$defs/OrderInformationalMessage"
        },
        "exitLevelId": {
          "description": "The id of an exit level. Must be [lexicographic](https://en.wikipedia.org/wiki/Lexicographic_order). Exits are combined into a single level by sharing the same id. This field should be populated if an order represents an exit.",
          "type": "string"
        }
      },
      "required": [
        "id",
        "instrument",
        "qty",
        "side",
        "type"
      ]
    },
    "OrderInformationalMessage": {
      "title": "OrderInformationalMessage",
      "description": "Informational message description, that will be displayed for the order in the Account manager. The message will be marked\nwith a color, corresponding to a message type.\nThe text message will also be displayed in the notification pop-up in case the order status gets changed.\n",
      "type": "object",
      "properties": {
        "text": {
          "description": "Message text",
          "type": "string"
        },
        "type": {
          "description": "Message type",
          "type": "string",
          "enum": [
            "information",
            "warning",
            "error"
          ]
        }
      },
      "required": [
        "text",
        "type"
      ],
      "additionalProperties": false
    },
    "OrderStatus": {
      "title": "OrderStatus",
      "type": "object",
      "properties": {
        "status": {
          "description": "String constants to describe an order status.\n\n`Status`  | Description\n----------|-------------\nplacing   | order is not created on a broker's side yet\ninactive  | bracket order is created but waiting for a base order to be filled\nworking   | order is created but not fully executed yet\nrejected  | order is rejected for some reason\nfilled    | order is fully executed\ncancelled  | order is cancelled\n",
          "type": "string",
          "enum": [
            "placing",
            "inactive",
            "working",
            "rejected",
            "filled",
            "cancelled"
          ]
        }
      },
      "required": [
        "status"
      ]
    }
  }
}