{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hitbtc/json-schema/hitbtc-trading-futures-order-request-schema.json",
  "title": "trading_FuturesOrderRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hitbtc-futures-orders-api-openapi.yml#/components/schemas/trading_FuturesOrderRequest",
  "allOf": [
    {
      "type": "object"
    },
    {
      "title": "Futures request",
      "oneOf": [
        {
          "$ref": "#/$defs/trading_FuturesLimitOrderRequest"
        },
        {
          "$ref": "#/$defs/trading_FuturesMarketOrderRequest"
        },
        {
          "$ref": "#/$defs/trading_FuturesStopLimitOrderRequest"
        },
        {
          "$ref": "#/$defs/trading_FuturesStopMarketOrderRequest"
        },
        {
          "$ref": "#/$defs/trading_FuturesStopLimitOrderRequest"
        },
        {
          "$ref": "#/$defs/trading_FuturesStopMarketOrderRequest"
        }
      ]
    }
  ],
  "$defs": {
    "trading_ClosePositionFieldRequest": {
      "title": "Close position",
      "type": "object",
      "properties": {
        "close_position": {
          "type": "boolean",
          "default": false,
          "description": "Flag indicating a stop market order must close a margin position\n when executed or be canceled otherwise.\n\nConditions: `quantity` is omitted.\n"
        }
      }
    },
    "trading_Contract": {
      "title": "Contract"
    },
    "trading_FuturesLimitOrderRequest": {
      "title": "Limit order",
      "allOf": [
        {
          "$ref": "#/$defs/trading_OrderRequestBase"
        },
        {
          "$ref": "#/$defs/trading_ReduceOnlyRequest"
        },
        {
          "$ref": "#/$defs/trading_Contract"
        },
        {
          "$ref": "#/$defs/trading_HiddenOrderFields"
        },
        {
          "$ref": "#/$defs/trading_PriceRequest"
        },
        {
          "$ref": "#/$defs/trading_MarginModeRequest"
        },
        {
          "$ref": "#/$defs/trading_LimitDefaultTIF"
        },
        {
          "$ref": "#/$defs/trading_MarginAutoRequest"
        }
      ]
    },
    "trading_FuturesMarketOrderRequest": {
      "title": "Market order",
      "allOf": [
        {
          "$ref": "#/$defs/trading_OrderRequestBase"
        },
        {
          "$ref": "#/$defs/trading_ReduceOnlyRequest"
        },
        {
          "$ref": "#/$defs/trading_Contract"
        },
        {
          "$ref": "#/$defs/trading_MarginModeRequest"
        },
        {
          "$ref": "#/$defs/trading_MarginAutoRequest"
        },
        {
          "type": "object",
          "required": [
            "type"
          ]
        }
      ]
    },
    "trading_FuturesStopLimitOrderRequest": {
      "title": "Stop limit order",
      "allOf": [
        {
          "$ref": "#/$defs/trading_FuturesLimitOrderRequest"
        },
        {
          "$ref": "#/$defs/trading_StopPriceRequest"
        },
        {
          "$ref": "#/$defs/trading_HiddenOrderFields"
        },
        {
          "$ref": "#/$defs/trading_LimitDefaultTIF"
        },
        {
          "required": [
            "stop_price"
          ]
        }
      ]
    },
    "trading_FuturesStopMarketOrderRequest": {
      "title": "Stop market order",
      "allOf": [
        {
          "$ref": "#/$defs/trading_ClosePositionFieldRequest"
        },
        {
          "$ref": "#/$defs/trading_FuturesMarketOrderRequest"
        },
        {
          "$ref": "#/$defs/trading_StopPriceRequest"
        },
        {
          "required": [
            "stop_price"
          ]
        }
      ]
    },
    "trading_HiddenOrderFields": {
      "title": "Hidden order",
      "type": "object",
      "properties": {
        "display_quantity": {
          "type": "string",
          "enum": [
            "0"
          ],
          "description": "The visible part of the hidden order quantity.\n\nConditions: `time_in_force` is `GTC`, `Day`, `GTD`\n"
        }
      }
    },
    "trading_LimitDefaultTIF": {
      "title": "Time-in-Force",
      "type": "object",
      "properties": {
        "time_in_force": {
          "default": "GTC"
        }
      }
    },
    "trading_MarginAutoRequest": {
      "title": "Auto margin management",
      "type": "object",
      "properties": {
        "margin_auto": {
          "type": "boolean",
          "description": "Flag requesting AMM (auto margin management) for the margin account\n or position the order belongs to.\n\nIf AMM is enabled, the margin required for the order and for the\n position is reserved from the trading balance automatically, and no\n margin account has to be created in advance.\n\nℹ️ The value is applied only if the margin account is idle, meaning\n that it has no open positions and no active orders. Otherwise, the\n value of the account is kept and the value of the order is ignored.\n\nConditions: applicable to margin orders only\n\nDefault: `false`\n\nℹ️ The exchange web interface sends the value of `current_amm`\n returned by `GET /margin-settings`. An API client that follows the\n user setting has to pass the flag explicitly.\n"
        }
      }
    },
    "trading_MarginModeCommon": {
      "title": "Margin mode",
      "type": "string",
      "enum": [
        "cross",
        "Cross",
        "isolated",
        "Isolated"
      ],
      "description": "Margin mode."
    },
    "trading_MarginModeRequest": {
      "title": "Margin mode",
      "type": "object",
      "properties": {
        "margin_mode": {
          "allOf": [
            {
              "default": "isolated"
            },
            {
              "$ref": "#/$defs/trading_MarginModeCommon"
            }
          ]
        }
      }
    },
    "trading_OrderRequestBase": {
      "title": "Order request",
      "allOf": [
        {
          "$ref": "#/$defs/trading_StrictValidateRequest"
        },
        {
          "$ref": "#/$defs/trading_QuantityRequest"
        },
        {
          "type": "object",
          "required": [
            "side",
            "symbol"
          ],
          "properties": {
            "client_order_id": {
              "type": "string",
              "minLength": 8,
              "maxLength": 32,
              "pattern": "^[a-zA-Z0-9_\\-]{8,32}$",
              "description": "Client-provided identifier of an order.\n\n⚠️ Uniqueness must be guaranteed until the last order with the same `client_order_id` becomes inactive (canceled, expired, or fully executed) and some time after that.\n\nℹ️ If omitted, will be generated by the system.\n"
            },
            "symbol": {
              "type": "string",
              "description": "Symbol code."
            },
            "side": {
              "type": "string",
              "enum": [
                "sell",
                "buy"
              ],
              "description": "Order side."
            },
            "type": {
              "type": "string",
              "default": "limit",
              "enum": [
                "limit",
                "market",
                "stopLimit",
                "stopMarket",
                "takeProfitLimit",
                "takeProfitMarket"
              ],
              "description": "Order type.\n\nConditions: required if `market`, `stopMarket`, `takeProfitMarket`\n\nValues:\n  * `limit`—an order that will be executed at or better than the specified price. The remainder, if any, is added to the order book or expired by terms of its Time-In-Force instruction;\n  * `market`—an order that will be executed at the \"best\" available market price. If the order depletes its price level, then leaves quantity is placed to the order book at this limit price;\n  * `stopLimit`—a limit order that remains inactive until the market crosses a specified stop price (for sell orders—falls below, for buy orders—rises above);\n  * `stopMarket`—a market order that remains inactive until the market crosses a specified stop price (for sell orders—falls below, for buy orders—rises above);\n  * `takeProfitLimit`—a limit order that remains inactive until the market crosses a specified stop price (for sell orders—rises above, for buy orders—falls below);\n  * `takeProfitMarket`—a market order that remains inactive until the market crosses a specified stop price (for sell orders—rises above, for buy orders—falls below).\n"
            },
            "time_in_force": {
              "type": "string",
              "enum": [
                "GTC",
                "IOC",
                "FOK",
                "Day",
                "GTD"
              ],
              "default": "FOK",
              "description": "Order expiration mode.\n\nConditions: `post_only` omitted\n\nValues:\n  * `GTC` (\"Good-Till-Canceled\")—order will not be closed until it is filled;\n  * `IOC` (\"Immediate-Or-Cancel\")—order must be executed immediately. Any part of an IOC order that cannot be filled immediately will be canceled;\n  * `FOK` (\"Fill-Or-Kill\")—order must be executed immediately and completely or not executed at all;\n  * `Day`—keeps the order active until the end of the trading day (23:59 UTC+0);\n  * `GTD` (\"Good-Till-Date\")—order will be canceled on the specified date.\n"
            },
            "expire_time": {
              "type": "string",
              "format": "date-time",
              "description": "Date and time of order expiration.\n\nConditions: `time_in_force` is `\"GTD\"`\n"
            },
            "post_only": {
              "type": "boolean",
              "description": "A post-only order is an order that does not remove liquidity.\n\nConditions: `time_in_force` omitted\n\n⚠️ If the post-only order would cause a match with a pre-existing order as a taker, then the order will be canceled.\n",
              "default": false
            }
          }
        }
      ]
    },
    "trading_PriceRequest": {
      "title": "Price",
      "type": "object",
      "required": [
        "price"
      ],
      "properties": {
        "price": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Order price."
        }
      }
    },
    "trading_QuantityRequest": {
      "title": "Quantity",
      "type": "object",
      "required": [
        "quantity"
      ],
      "properties": {
        "quantity": {
          "type": "string",
          "exclusiveMinimum": 0,
          "description": "Order quantity."
        }
      }
    },
    "trading_ReduceOnlyRequest": {
      "title": "Reduce-only",
      "type": "object",
      "properties": {
        "reduce_only": {
          "type": "boolean",
          "default": false,
          "description": "Flag indicating whether the order, being filled, guarantees not to put the position quantity to the point when the position flips.\n\nConditions:\n  * if there is at least 1 reduce-only order, the maximum number of close orders must not exceed 20;\n  * the maximum number of reduce-only orders must not exceed 3.\n"
        }
      }
    },
    "trading_StopPriceRequest": {
      "title": "Stop price",
      "type": "object",
      "properties": {
        "stop_price": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "The price level that triggers order activation."
        }
      }
    },
    "trading_StrictValidateRequest": {
      "title": "Strict validate",
      "type": "object",
      "properties": {
        "strict_validate": {
          "type": "boolean",
          "description": "Price and quantity will be checked for incrementation within the symbol tick size and quantity step (see the symbol `tick_size` and `quantity_increment`).",
          "default": false
        }
      }
    }
  }
}