openapi: 3.0.0
servers:
  - url: https://api.exchange.bullish.com/trading-api
    description: PRODUCTION
  - url: https://registered.api.exchange.bullish.com/trading-api
    description: PRODUCTION
  - url: https://prod.access.bullish.com/trading-api
    description: PRODUCTION (Direct Connect)
  - url: https://api.bugbounty.bullish.com/trading-api
    description: SECURITY SANDBOX
  - url: https://api.simnext.bullish-test.com/trading-api
    description: API SANDBOX
  - url: https://registered.api.simnext.bullish-test.com/trading-api
    description: API SANDBOX
  - url: https://simnext.access.bullish.com/trading-api
    description: API SANDBOX (Direct Connect)
info:
  description: |
    # Overview

    Welcome to the _Bullish Deprecated Features & APIs_ documentation!

    This documentation provides a list of Features and APIs that have been marked as deprecated, and will be decommissioned soon.
    You will still be able to use these Features or APIs till the stated decommission date. 

    ## Additional Links

    - API documentations - [Trading API Documentation](/rest/introduction)

    ## Deprecated Features
    List of Features that are marked for deprecation.

    ## Bullish Key
    `Decommissioned`: *Creation of Bullish API key has been suspended as of `29 March, 2024`*

    `Deprecated`: *Existing Bullish API key will no longer be usable as of `28 June, 2024`*
    - A Bullish API key is a public/private key pair used for ECDSA based signing of trading and custody API requests
    - From here on the:
      - public key will be referred to as `PUBLIC_KEY`
      - private key will be referred to as `PRIVATE_KEY`
    - For information about the format of keys please review EOS Wallet Specification
    - Always store your private keys in a secure medium as they are used to sign your requests. Do not share your private keys in any publicly accessible areas such as code repositories, client side code, or other vulnerable areas and make sure the keys are not shipped with your mobile or web apps.

    A Bullish API key additionally has a `metadata` string associated with it which is displayed along side the key.
    You must base64 decode the `metadata` to extract your `userId` (example follows). You will need the `userId` in the next step.
    Please note that the `accountId` field is deprecated, and will be removed along with `v1/users/login` API towards the end of Q4 2023. Clients should reference the `userId` field instead.
    Old `metadata` strings generated before the March 2023 upgrade will not contain the `userId` field; clients are advised to get the `metadata` from the Settings page on the UI again.

    ```shell
    echo eyJwdWJsaWNLZXkiOiJQVUJfUjFfNWNpVW52TW5rVThMOVBCWnZaa1BGcjhqdkRnUHpzcHhWNGlqOThIN1JqM1FSNzJyMkEiLCJhY2NvdW50SWQiOjIyMjAwMDAwMDAwMDAwNCwiY3JlZGVudGlhbElkIjoiMTAifQ== | base64 --decode
    {"publicKey":"PUB_R1_5ciUnvMnkU8L9PBZvZkPFr8jvDgPzspxV4ij98H7Rj3QR72r2A","userId":"12345","accountId":"12345","credentialId":"10"}
    ```

    ## Signing Format (Old)

    `Deprecated`: *Please use the new [Signing Format](/rest/authentication#signing-format)*

    Before signing the `<COMMAND>` string remove any spaces and newline characters.

    The resulting value is also referred to as the request signature. Each component of the signature is detailed below:
      - `<TIMESTAMP>`: number of milliseconds since EPOCH
      - `<NONCE>`: client side incremented 64-bit unsigned integer
      - `<AUTHORIZER>`: JWT authorizer you obtain along with the [JWT token](/rest/authentication#add-authenticated-request-header)
      - `<COMMAND>`: the command which is sent in the request payload, JSON encoded

    ### How To Sign - Bullish API Key

    To obtain the signature:

    1. Encode the request JSON payload, also referred to as body, with the SHA-256 hash function and take the hexdigest
    2. Sign the hexdigest from step 1 with ECDSA P-256 using your `<PRIVATE_KEY>`
    3. Various signing examples can be found on [GitHub](https://github.com/bullish-exchange)

    ### How To Sign - HMAC API Key

    To obtain the signature:

    1. Encode the request JSON payload, also referred to as body, with the SHA-256 hash function and take the hexdigest
    2. Sign the hexdigest from step 1 with your HMAC Secret Key.

    See sign a request with HMAC for a sample Python script.

    ## Hybrid Order Book WebSocket (unauthenticated)
    `Deprecated`: *Please use the [unauthenticated multi-order book WebSocket](/websocket/public/market-data/orderbook).*

    **Route**
    - `/markets/{symbol}/orderbook/hybrid`
    - `/v2/market-data/orderbook/hybrid/{symbol}?depth={depth}&aggregationFactor={aggregationFactor}`

    **Additional notes**: 
    - Allowable depths - `[ 10, 50, 100, 200 ]`.
    - Allowable aggregation factors - `[ 1, 5, 10 ]`.
    - This endpoint does not require subscriptions.

    On connection, the client receives a snapshot of the current hybrid order book with default depth of 10 (unless specified otherwise).
    Subsequently, if the order book moves, the client then receives a conflated update of the hybrid order book periodically 
    at 300ms with standard ingress and at 100ms with Cloudflare bypass. If there is a sequence number mismatch between the 
    conflated update and the snapshot, the server disconnects the client with the following error message - 
    `4003 (Try Again, sequence number miss-match between snapshot and updates)`.

    ### l2Snapshot response

    | Name                    | Type   | Description                                                                                                                                                                                                              |
    |---------------------    |--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
    | symbol                  | String | market symbol                                                                                                                                                                                                            |
    | bids                    | Array  | array of size 20 (default unless specified otherwise by the `depth` parameter) where even indices denote price, odd indices denote absolute quantities                                                                   |
    | asks                    | Array  | array of size 20 (default unless specified otherwise by the `depth` parameter) where even indices denote price, odd indices denote absolute quantities                                                                   |
    | sequenceNumberRange     | Array  | array of size 2 where first element denotes lower bound, second element denotes upper bound of sequence numbers <br /> lower and upper bound are equal for initial snapshot; this may differ for subsequent snapshots    |
    | datetime                | String | denotes the time the update was created by the engine, ISO 8601 with millisecond as string                                                                                                                               |
    | timestamp               | String | denotes the time the update was created by the engine                                                                                                                                                                    |
    | publishedAtTimestamp    | String | denotes the time the update was broadcasted to connected WebSockets                                                                                                                                                      |

    ```json
    {
      "type": "snapshot",
      "dataType": "V1TALevel2",
      "data": {
        "symbol": "BTCUSD",
        "bids": [
          "5199.5000",
          "110.92467647",
          "5199.4000",
          "20.92470365",
          "5199.3000",
          "0.92473034",
          "5199.2000",
          "0.92475701",
          "5199.1000",
          "0.92478369",
          "5199.0000",
          "0.92481038",
          "5198.9000",
          "0.92483705",
          "5198.8000",
          "0.92486375",
          "5198.7000",
          "0.92489042",
          "5198.6000",
          "0.92491712"
        ],
        "asks": [
          "5199.6000",
          "96.37848193",
          "5199.7000",
          "0.92465082",
          "5199.8000",
          "11.04464563",
          "5199.9000",
          "0.92459696",
          "5200.0000",
          "0.92457029",
          "5200.1000",
          "0.92454362",
          "5200.2000",
          "0.92451695",
          "5200.3000",
          "0.92449028",
          "5200.4000",
          "0.92446361",
          "5200.5000",
          "0.92443695"
        ],
        "sequenceNumberRange": [6, 6],
        "datetime": "2020-05-13T10:23:46.000Z",
        "timestamp": "1589365426000",
        "publishedAtTimestamp": "1589365426100"
      }
    }
    ```


    ### l2Update response

    | Name                  | Type   | Description                                                                                                                                                |
    |---------------------  |--------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
    | symbol                | String | market symbol                                                                                                                                              |
    | bids                  | Array  | even indices denote price, odd indices denote absolute quantities                                                                                          |
    | asks                  | Array  | even indices denote price, odd indices denote absolute quantities                                                                                          |
    | sequenceNumberRange   | Array  | array of size 2 where first element denotes lower bound, second element denotes upper <br /> bound of sequence numbers represented by the conflated update |
    | datetime              | String | denotes the time the update was created by the engine, ISO 8601 with millisecond as string                                                                 |
    | timestamp             | String | denotes the time the update was created by the engine                                                                                                      |
    | publishedAtTimestamp  | String | denotes the time the update was broadcasted to connected WebSockets                                                                                        |

    ```json
    {
      "type": "update",
      "dataType": "V1TALevel2",
      "data": {
        "symbol": "BTCUSD",
        "bids": [],
        "asks": ["5199.7000", "101.30313224"],
        "sequenceNumberRange": [7, 10],
        "datetime": "2020-06-29T06:28:55.500Z",
        "timestamp": "1593412135500",
        "publishedAtTimestamp": "1593412135600"
      }
    }
    ```

    ### Maintaining Hybrid Order Book
    1. Connect to hybrid order book WebSocket API.
    2. Receive initial snapshot message.
    3. Record sequence number and create order book.
    4. Compare current sequence number with that of new message. If sequence number is out of order, reconnect.
    5. Receive update messages of price levels with new absolute quantity and update order book.
       If quantity is 0, price level is removed.
    6. Receive a subsequent snapshot message and reset existing order book. Create order book with new price levels.

    See connect to hybrid order book WebSocket for a sample Python script.

    ## Market Data WebSocket (authenticated)
    `Deprecated`: *Please use the [unauthenticated multi-order book WebSocket](/websocket/public/market-data/orderbook).*

    Route
    - `/v1/market-data`
    | Topic         |  Description                              | Data Type        | Subscription Type           |
    |:--------------|:------------------------------------------|:-----------------|:----------------------------|
    | l1Orderbook   | Provides updates for Level 1 market data  | `V1TABookLevel1` | By `<TOPIC>` and `<SYMBOL>` |
    ### l1Orderbook response
    - Level 1 market data updates are realtime.
    - If the `sequenceNumber` of an incoming update is smaller than that of a previously received update, then the
    `sequenceNumber` is out of order. Terminate the WebSocket connection and reconnect.
    | Name           | Type   | Description                                                                          |
    |:---------------|:-------|:-----------------------------------------------------------------                    |
    | sequenceNumber | String | incrementing, unique, unsigned integer that identifies a state of the L1 order book   |
    | symbol         | String | market symbol                                                                        |
    | timestamp      | String | denotes the time the update was created                                              |
    | bid            | Array  | nested array containing price and quantity of highest bid                            |
    | ask            | Array  | nested array containing price and quantity of lowest ask                             |
    ```json
    {
      "type": "update",
      "dataType": "V1TABookLevel1",
      "data": {
        "sequenceNumber": "1",
        "symbol": "BTCUSD",
        "timestamp": "1466812800000",
        "bid": [ [ "35.0000", "2.00000000" ] ],
        "ask": [ [ "35.5000", "1.00000000" ] ]
      }
    }
    ```
    See connect to market data WebSocket for a sample Python script.

    ## Spot Account
    `Deprecated`: *Spot Account will be replaced by `Asset Account` which provides a more granular view of the assets in your trading account*

    - REST Endpoints [(Get Spot Accounts)](/rest/deprecated/user-get-spot-accounts)
      - REST - `GET /accounts/spot` replaced by REST - [GET /accounts/asset](/rest/api/get-asset-accounts)
      - REST - `GET /accounts/spot/{symbol}` replaced by REST - [GET `/accounts/asset/{symbol}`](/rest/api/get-asset-account-by-symbol)

    - [Private Data WebSocket (Authenticated)](/websocket/private/private-data)
      - Topic: `spotAccounts` replaced by `assetAccounts`
      - Response: `V1TASpotAccount` replaced by `V1TAAssetAccount`
    ### spotAccounts response

    The *Formula* colummn below shows how the fields in `V1TASpotAccount` are calculated.

    | Name                 | Type   | Description                                                                                                                                                                         |  Formula <br /> (expressed in `assetAccounts` response fields)      |
    |:---------------------|:-------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------|
    | accountId            | String | unique spot account ID                                                                                                                                                              |                                                                     |
    | symbol               | String | asset symbol                                                                                                                                                                        |                                                                     |
    | type                 | String | type of account                                                                                                                                                                     |                                                                     |
    | total                | String | total is `free` + `used` assets within the account, see [asset value](/rest/general/price-quantity-precision) format                                             |   =max(0, availableQuantity - borrowedQuantity) + lockedQuantity    |
    | free                 | String | refers to the assets that are available to use on the account excluding borrowed assets, see [asset value](/rest/general/price-quantity-precision) format.       |   =max(0, availableQuantity - borrowedQuantity)                     |
    | used                 | String | refers to the assets that are locked in orders, see [asset value](/rest/general/price-quantity-precision) format                                                 |   =lockedQuantity                                                   |
    | updatedAtDatetime    | String | denotes the time the spot account was updated by the exchange, ISO 8601 with millisecond as string                                                                                  |                                                                     |
    | updatedAtTimestamp   | String | denotes the time the spot account was updated by the exchange                                                                                                                       |                                                                     |
    | publishedAtTimestamp | String | denotes the time the update was broadcasted to connected WebSockets                                                                                                                 |                                                                     |


    ```json
    {
      "tradingAccountId": "1111",
      "type": "snapshot",
      "dataType": "V1TASpotAccount",
      "data": [
        {
          "accountId": "1",
          "type": "spot",
          "symbol": "BTC",
          "total": "4.00000000",
          "free": "4.00000000",
          "used": "0.00000000",
          "updatedAtDatetime": "2021-12-30T07:36:35.918Z",
          "updatedAtTimestamp": "1640849795918",
          "publishedAtTimestamp": "1640849795920"
        }
      ]
    }
    ```

    ## Anonymous Trades WebSocket (unauthenticated)
    **Route**
    - `/v1/market-data/trades/{symbol}`

    **Note**: This endpoint does not require subscriptions.

    On connection, the client receives a snapshot of the latest 100 trades, in descending order. Subsequently,
    the client receives real-time updates of trades that have been executed. If the `tradeId` of an incoming update is 
    smaller than that of a previously received update, then the `tradeId` is out of order. Terminate the
    WebSocket connection and reconnect.

    ### Trades response

    | Name                 | Type      | Description                                                                               |
    |:---------------------|:----------|:------------------------------------------------------------------------------------------|
    | tradeId              | String    | unique trade ID                                                                           |
    | symbol               | String    | market symbol                                                                             |
    | price                | String    | price, see [asset value](/rest/general/price-quantity-precision) format                  |
    | quantity             | String    | quantity, see [asset value](/rest/general/price-quantity-precision) format               |
    | side                 | String    | order side                                                                                |
    | isTaker              | Boolean   | denotes whether this is a taker's trade                                                   |
    | createdAtTimestamp   | String    | denotes the time the order was ACK'd by the exchange                                      |
    | createdAtDatetime    | String    | denotes the time the order was ACK'd by the exchange, ISO 8601 with millisecond as string |
    | publishedAtTimestamp | String    | denotes the time the update was broadcasted to connected WebSockets                       |

    ```json
    {
      "type": "update",
      "dataType": "V1TAAnonymousTrade",
      "data": {
        "tradeId": "100000000000001050",
        "symbol": "BTCUSD",
        "price": "11528.2203",
        "quantity": "1.00000000",
        "side": "BUY",
        "isTaker": true,
        "createdAtTimestamp": "1662453438774",
        "createdAtDatetime": "2022-09-06T08:37:18.774Z",
        "publishedAtTimestamp": "1662453438780"
      }
    }
    ```

    See [connect to trades WebSocket](https://github.com/bullish-exchange/api-examples/blob/master/websocket/trades_web_socket.py) for a sample Python script.

    ## Decommissioned Features
    List of Features that have been decommissioned and no longer usable.

    ## Changelog
    ### 2025 Changes
      - May
        - Deprecated Features:
          - Anonymous Trades WebSocket (unauthenticated)
    ### 2024 Changes
      - April
        - Deprecated Features:
          - Bullish API Key
          - Signing Format (Old)
          - Hybrid OrderBook WebSocket (unauthenticated)
          - Market Data WebSocket (authenticated)
          - Spot Account
        - Deprecated APIs for end of Q3 2024:
          - REST - `GET | POST | DELETE /trading-api/v1/orders`
          - REST - `GET /v1/orders/{orderId}`
          - REST - `POST /v1/command?commandType=V1CancelAllOrders`
          - REST - `POST /v1/command?commandType=V1CancelAllOrdersByMarket`
          - REST - `POST /v1/command?commandType=V1DelayedCancelAllOrders`
          - REST - `POST /v1/command?commandType=V1UnsetDelayedCancelAllOrders`
          - REST - `GET | POST | DELETE /v1/amm-instructions`
          - REST - `GET /v1/amm-instructions/{liquidityId}`
        - Deprecated APIs:
          - REST `GET /accounts/spot`
          - REST `GET /accounts/spot/asset`

  version: 1.0.0
  title: Bullish Deprecated Features & APIs

tags:
  - name: deprecated - q3 2024
    description: List of deprecated APIs that will be removed towards the end of Q3 2024.
  - name: deprecated
    description: List of APIs that has been marked to be deprecated. You can still use these APIs till their end of service date.
  - name: decommissioned
    description: List of deprecated APIs that that are removed and no longer accessible.

paths:
  /v1/orders:
    get:
      tags:
        - deprecated - q3 2024
      deprecated: true
      summary: Get Orders
      description: |
        Gets the orders list based on specified filters.
        - requires [bearer token](/rest/authentication#add-authenticated-request-header) in authorization header
        - [supports pagination](/rest/general/pagination)
        - supports filtering on `symbol`, `handle`, `side`, `status`, `createdAtDatetime`, `createdAtTimestamp`

        **Ratelimited:** `True`
      operationId: trade-get-orders
      parameters:
        - $ref: "#/components/parameters/Authorization"
        - in: query
          name: symbol
          schema:
            $ref: "#/components/schemas/MarketSymbol"
          required: false
        - in: query
          name: handle
          description: Unique numeric (i64) identifier generated on the client side expressed as a string value
          schema:
            $ref: "#/components/schemas/OrderHandle"
          required: false
        - in: query
          name: side
          description: order side
          schema:
            $ref: "#/components/schemas/OrderSide"
          required: false
        - in: query
          name: status
          description: order status
          schema:
            $ref: "#/components/schemas/OrderStatus"
          required: false
        - in: query
          name: tradingAccountId
          description: Id of the trading account
          schema:
            $ref: "#/components/schemas/TradingAccountId"
          required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                minItems: 0
                maxItems: 10
                items:
                  $ref: "#/components/schemas/Order"
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      security:
        - jwtTokenAuth: []
    post:
      tags:
        - deprecated - q3 2024
      deprecated: true
      summary: Create Order
      description: |
        Creates an order, requires [bearer token](/rest/authentication#add-authenticated-request-header) in authorization header.

        Requires strict field ordering in the request body.

        [Command Example](/rest/authentication#construct-the-command-you-want-to-send)

        **Ratelimited:** `True`
      operationId: trade-create-order
      parameters:
        - $ref: "#/components/parameters/Authorization"
        - $ref: "#/components/parameters/BX-SIGNATURE"
        - $ref: "#/components/parameters/BX-TIMESTAMP"
        - $ref: "#/components/parameters/BX-NONCE"
        - $ref: "#/components/parameters/BX-NONCE-WINDOW-ENABLED"
        - in: query
          name: test
          description: to validate integration with the `POST /orders` API pass the query parameter `test=true` e.g. `/orders?test=true`. The request will be validated but not executed.
          schema:
            $ref: "#/components/schemas/Boolean"
          required: false
      responses:
        "200":
          description: Status OK. This means an create order command was successfully acknowledged. It does not necessarily mean the order was created. To check the current status of the order, query [Get Order by ID](/rest/deprecated/trade-get-order-by-id) using the `orderId` received in the response payload. Also consult the section [How To Ensure The Order Of *Create Order* or *Cancel Order* Requests](/rest/order-processing-create-cancel-request-mechanism).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CreateOrderResponse"
        "400":
          description: |+
            Bad Request

            For example, sending a request with the `BX-SIGNATURE` header missing will result in the following response:
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadOrderEntryResponse"
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      requestBody:
        description: new order request body
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateOrderRequest"
      security:
        - jwtTokenAuth: []
    delete:
      tags:
        - deprecated - q3 2024
      deprecated: true
      summary: Cancel Order
      description: |
        Cancels an order, requires [bearer token](/rest/authentication#add-authenticated-request-header) in authorization header.

        Requires strict field ordering in the JSON request payload.

        Please use either the `handle` or `orderId` field in the query parameters.

        [Command example](/rest/authentication#cancel-order-example)

        **Ratelimited:** `True`
      operationId: trade-cancel-order
      parameters:
        - $ref: "#/components/parameters/Authorization"
        - $ref: "#/components/parameters/BX-SIGNATURE"
        - $ref: "#/components/parameters/BX-TIMESTAMP"
        - $ref: "#/components/parameters/BX-NONCE"
        - $ref: "#/components/parameters/BX-NONCE-WINDOW-ENABLED"
        - in: query
          name: symbol
          schema:
            $ref: "#/components/schemas/MarketSymbol"
          required: true
        - in: query
          name: handle
          description: Unique numeric (i64) identifier generated on the client side expressed as a string value
          schema:
            $ref: "#/components/schemas/OrderHandle"
          required: false
        - in: query
          name: orderId
          description: unique order ID
          schema:
            $ref: "#/components/schemas/OrderID"
          required: false
        - in: query
          name: test
          description: to validate integration with the `DELETE /orders` API pass the query parameter `test=true` e.g. `/orders?test=true`. The request will be validated but not executed.
          schema:
            $ref: "#/components/schemas/Boolean"
          required: false
        - in: query
          name: tradingAccountId
          description: Id of the trading account
          schema:
            $ref: "#/components/schemas/TradingAccountId"
          required: true
      responses:
        "204":
          description: Status OK. This means an cancel order command was successfully acknowledged. It does not necessarily mean the order was cancelled. To check the current status of the order, query [Get Order by ID](/rest/deprecated/trade-get-order-by-id) using the `orderId`. Also consult the section [How To Ensure The Order Of *Create Order* or *Cancel Order* Requests](/rest/order-processing-create-cancel-request-mechanism).
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "404":
          description: Resource Not Found
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      security:
        - jwtTokenAuth: []
  /v1/orders/{orderId}:
    parameters:
      - in: path
        name: orderId
        schema:
          type: number
        required: true
        description: order ID
    get:
      tags:
        - deprecated - q3 2024
      deprecated: true
      summary: Get Order by ID
      description: |
        Gets an order by ID, requires [bearer token](/rest/authentication#add-authenticated-request-header) in authorization header

        **Ratelimited:** `True`
      operationId: trade-get-order-by-id
      parameters:
        - $ref: "#/components/parameters/Authorization"
        - in: query
          name: tradingAccountId
          description: Id of the trading account
          schema:
            $ref: "#/components/schemas/TradingAccountId"
          required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Order"
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      security:
        - jwtTokenAuth: []

  /v1/command?commandType=V1CancelAllOrders:
    post:
      tags:
        - deprecated - q3 2024
      deprecated: true
      summary: Cancel All Open Limit Orders
      description: |
        Cancels all open limit orders

        Requires
        - strict field ordering in the JSON request payload.
        - [bearer token](/rest/authentication#add-authenticated-request-header) in authorization header

        **Ratelimited:** `True`
      operationId: trade-cancel-all-open-limit-orders
      parameters:
        - $ref: "#/components/parameters/Authorization"
      responses:
        "200":
          description: Status OK. This means a cancel all open limit orders command was successfully acknowledged.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CancelAllOrdersResponse"
        "400":
          description: |+
            Bad Request

            For example, sending a request with the `BX-SIGNATURE` header missing will result in the following response:
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadOrderEntryResponse"
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      requestBody:
        description: Cancel All Open Limit Orders request body
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CancelAllOrdersRequest"

      security:
        - jwtTokenAuth: []

  /v1/command?commandType=V1CancelAllOrdersByMarket:
    post:
      tags:
        - deprecated - q3 2024
      deprecated: true
      summary: Cancel All Open Limit Orders by Market
      description: |
        Cancels all open orders by market

        Requires
        - strict field ordering in the JSON request payload.
        - [bearer token](/rest/authentication#add-authenticated-request-header) in authorization header

        **Ratelimited:** `True`
      operationId: trade-cancel-all-open-limit-orders-by-market
      parameters:
        - $ref: "#/components/parameters/Authorization"
      responses:
        "200":
          description: Status OK. This means a cancel all Open Limit orders by market command was successfully acknowledged.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CancelAllOrdersByMarketResponse"
        "400":
          description: |+
            Bad Request

            For example, sending a request with the `BX-SIGNATURE` header missing will result in the following response:
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadOrderEntryResponse"
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      requestBody:
        description: Cancel All Open Limit Orders by market request body
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CancelAllOrdersByMarketRequest"

      security:
        - jwtTokenAuth: []

  /v1/command?commandType=V1DelayedCancelAllOrders:
    post:
      tags:
        - deprecated - q3 2024
      deprecated: true
      summary: Cancel All Open Limit Orders after Delay
      description: |
        Cancel All Open Limit Orders after Delay
        - requires [bearer token](/rest/authentication#add-authenticated-request-header) in authorization header
        - provides a “Dead Man's Switch” mechanism to protect customers from network malfunction. 
          The customer can send a request with a delay (in seconds), that will start a countdown timer 
          which cancels all open limit orders for a specific trading account when the timer expires.
        - can be disabled by another command type: V1UnsetDelayedCancelAllOrders

        **Ratelimited:** `True`
      operationId: trade-delayed-cancel-all-open-limit-orders
      parameters:
        - $ref: "#/components/parameters/Authorization"
      requestBody:
        description: Cancel All Open Limit Orders after Delay request body
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DelayedCancelAllOrdersRequest"
      responses:
        "200":
          description: Status OK. This means a cancel all open limit orders command was successfully acknowledged.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DelayedCancelAllOrdersResponse"
        "400":
          description: |+
            Bad Request

            For example, sending a request with the `BX-SIGNATURE` header missing will result in the following response:
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadOrderEntryResponse"
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      security:
        - jwtTokenAuth: []
  /v1/command?commandType=V1UnsetDelayedCancelAllOrders:
    post:
      tags:
        - deprecated - q3 2024
      deprecated: true
      summary: Cancel All Open Limit Orders after Delay Disable
      description: |
        Cancel All Open Limit Orders after Delay Disable
        - requires [bearer token](/rest/authentication#add-authenticated-request-header) in authorization header
        - Disable the delay set on a trading account that initiates cancelling all open limit orders
          (i.e. disable the previous V1DelayedCancelAllOrders command)

        **Ratelimited:** `True`
      operationId: trade-unset-delayed-cancel-all-open-limit-orders
      parameters:
        - $ref: "#/components/parameters/Authorization"
      requestBody:
        description: Cancel All Open Limit Orders after Delay Disable request body
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UnsetDelayedCancelAllOrdersRequest"
      responses:
        "200":
          description: Status OK. This means a cancel all open limit orders command was successfully acknowledged.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnsetDelayedCancelAllOrdersResponse"
        "400":
          description: |+
            Bad Request

            For example, sending a request with the `BX-SIGNATURE` header missing will result in the following response:
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadOrderEntryResponse"
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      security:
        - jwtTokenAuth: []

  /v1/amm-instructions:
    get:
      tags:
        - deprecated - q3 2024
      deprecated: true
      summary: Get AMM Instructions
      description: |
        Gets a list of AMM instructions based on applied filters.
        - requires [bearer token](/rest/authentication#add-authenticated-request-header) in authorization header
        - [supports pagination](/rest/general/pagination)
        - supports filtering on `symbol` and `status`

        **Ratelimited:** `True`
      operationId: trade-get-amm-instructions
      parameters:
        - $ref: "#/components/parameters/Authorization"
        - in: query
          name: symbol
          schema:
            $ref: "#/components/schemas/MarketSymbol"
          required: false
        - in: query
          name: status
          description: order status
          schema:
            $ref: "#/components/schemas/AMMInstructionStatus"
          required: false
        - in: query
          name: tradingAccountId
          description: Id of the trading account
          schema:
            $ref: "#/components/schemas/TradingAccountId"
          required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                minItems: 0
                maxItems: 10
                items:
                  $ref: "#/components/schemas/AMMInstruction"
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      security:
        - jwtTokenAuth: []
    post:
      tags:
        - deprecated - q3 2024
      deprecated: true
      summary: Create AMM Instruction
      description: |
        Creates an AMM instruction, requires [bearer token](/rest/authentication#add-authenticated-request-header) 
        in authorization header.

        Requires strict field ordering in the JSON request payload.

        [Command Example](/rest/api/create-amm-instruction)

        **Ratelimited:** `True`
      operationId: trade-create-amm-instruction
      parameters:
        - $ref: "#/components/parameters/Authorization"
        - $ref: "#/components/parameters/BX-SIGNATURE"
        - $ref: "#/components/parameters/BX-TIMESTAMP"
        - $ref: "#/components/parameters/BX-NONCE"
        - in: query
          name: test
          description: to validate integration with the `POST /amm-instructions` API pass the query parameter `test=true` e.g. `/amm-instructions?test=true`. The request will be validated but not executed.
          schema:
            $ref: "#/components/schemas/Boolean"
          required: false
      responses:
        "200":
          description: Status OK. This means a create AMM instruction command was successfully acknowledged. It does not necessarily mean the instruction was created. To check the current status, query [Get AMM Instruction by ID](/rest/api/get-amm-instruction-by-id-v-2) using the `liquidityId` received in the response payload.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CreateAMMInstructionResponse"
        "400":
          description: |+
            Bad Request

            For example, sending a request with the `BX-SIGNATURE` header missing will result in the following response:
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadOrderEntryResponse"
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      requestBody:
        description: new AMM instruction
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateAMMInstructionRequest"
      security:
        - jwtTokenAuth: []
    delete:
      tags:
        - deprecated - q3 2024
      deprecated: true
      summary: Terminate AMM Instruction
      description: |
        Terminates a specific AMM instruction, requires [bearer token](/rest/authentication#add-authenticated-request-header) in authorization header.

        Requires strict field ordering in the JSON request payload.

        [Command Example](/rest/api/create-amm-instruction)

        **Ratelimited:** `True`
      operationId: trade-terminate-amm-instruction
      parameters:
        - $ref: "#/components/parameters/Authorization"
        - $ref: "#/components/parameters/BX-SIGNATURE"
        - $ref: "#/components/parameters/BX-TIMESTAMP"
        - $ref: "#/components/parameters/BX-NONCE"
        - in: query
          name: symbol
          schema:
            $ref: "#/components/schemas/MarketSymbol"
          required: true
        - in: query
          name: liquidityId
          description: unique AMM instruction ID
          schema:
            $ref: "#/components/schemas/AMMInstructionID"
          required: true
        - in: query
          name: tradingAccountId
          description: id of the trading account
          schema:
            $ref: "#/components/schemas/TradingAccountId"
          required: true
        - in: query
          name: test
          description: to validate integration with the `DELETE /amm-instructions` API pass the query parameter `test=true` e.g. `/amm-instructions?test=true`. The request will be validated but not executed.
          schema:
            $ref: "#/components/schemas/Boolean"
          required: false
      responses:
        "204":
          description: Status OK. This means an terminate AMM instruction command was successfully acknowledged. It does not necessarily mean the AMM instruction was terminated. To check the current status, query [Get AMM Instruction by ID](/rest/api/get-amm-instruction-by-id-v-2) using the `liquidityId` received in the response payload.
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "404":
          description: Resource Not Found
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      security:
        - jwtTokenAuth: []
  /v1/amm-instructions/{liquidityId}:
    parameters:
      - in: path
        name: liquidityId
        schema:
          type: number
        required: true
        description: unique AMM instruction ID
      - in: query
        name: tradingAccountId
        description: Id of the trading account
        schema:
          $ref: "#/components/schemas/TradingAccountId"
        required: true
    get:
      tags:
        - deprecated - q3 2024
      deprecated: true
      summary: Get AMM Instruction by ID
      description: |
        Gets a specific AMM instruction based on the `liquidityId`, 
        requires [bearer token](/rest/authentication#add-authenticated-request-header) in authorization header

        **Ratelimited:** `True`
      operationId: trade-get-amm-instruction-by-id
      parameters:
        - $ref: "#/components/parameters/Authorization"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AMMInstruction"
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      security:
        - jwtTokenAuth: []

  /v1/accounts/spot:
    get:
      tags:
        - deprecated
      deprecated: true
      summary: Get Spot Accounts
      description: |
        `Deprecated`: Please look at [Asset Account](/rest/api/get-asset-accounts) instead.

        Gets the spot accounts, requires [bearer token](/rest/authentication#add-authenticated-request-header) in authorization header

        **Ratelimited:** `True`
      operationId: user-get-spot-accounts
      parameters:
        - $ref: "#/components/parameters/Authorization"
        - in: query
          name: tradingAccountId
          description: Id of the trading account
          schema:
            $ref: "#/components/schemas/TradingAccountId"
          required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                minItems: 0
                maxItems: 10
                items:
                  $ref: "#/components/schemas/SpotAccount"
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      security:
        - jwtTokenAuth: []
  /v1/accounts/spot/{symbol}:
    get:
      deprecated: true
      parameters:
        - $ref: "#/components/parameters/Authorization"
        - in: path
          name: symbol
          schema:
            $ref: "#/components/schemas/AssetSymbol"
          required: true
        - in: query
          name: tradingAccountId
          description: Id of the trading account
          schema:
            $ref: "#/components/schemas/TradingAccountId"
          required: true
      tags:
        - deprecated
      summary: Get Spot Account by Symbol
      description: |
        `Deprecated`: Please look at [Asset Account by Symbol](/rest/api/get-asset-account-by-symbol) instead.

        Gets the spot account by symbol, requires [bearer token](/rest/authentication#add-authenticated-request-header) in authorization header

        **Ratelimited:** `True`
      operationId: user-get-spot-account-by-symbol
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SpotAccount"
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "404":
          description: Resource Not Found
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      security:
        - jwtTokenAuth: []
  /v1/command:
    post:
      deprecated: true
      tags:
        - deprecated
      summary: Transfer Asset
      description: |
        Send command to transfer asset between two trading accounts.
      operationId: submitAssetTransferCommand
      parameters:
        - $ref: "#/components/parameters/Authorization"
        - $ref: "#/components/parameters/BX-SIGNATURE"
        - $ref: "#/components/parameters/BX-TIMESTAMP"
        - $ref: "#/components/parameters/BX-NONCE"
        - in: query
          name: commandType
          description: The command type, must be 'V1TransferAsset'
          required: true
          schema:
            type: string
            enum: [V1TransferAsset]
            example: V1TransferAsset
      responses:
        "200":
          description: Status OK. This means the request was successfully acknowledged. It does not necessarily mean the command was successfully executed.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TradingAccountTransferResponse"
        "400":
          description: |
            Bad Request

            For example, sending a request with the `BX-SIGNATURE` header missing will result in the following response:
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadOrderEntryResponse"
        "401":
          description: Not Authenticated
        "403":
          description: Access Forbidden
        "429":
          description: Too Many Requests
        "500":
          description: Internal Server Error
      requestBody:
        description: Command for action
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TradingAccountTransferRequest"
      security:
        - jwtTokenAuth: []

components:
  securitySchemes:
    jwtTokenAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  parameters:
    Authorization:
      in: header
      name: Authorization
      description: authorization header, its value must be 'Bearer ' + [token](/rest/authentication#generate-a-jwt-token)
      required: true
      schema:
        type: string
    BX-SIGNATURE:
      in: header
      name: BX-SIGNATURE
      description: signature obtained using the [signing format](#overview--how-to-ensure-the-order-of-create-order-or-cancel-order-requests)
      required: true
      schema:
        type: string
    BX-TIMESTAMP:
      in: header
      name: BX-TIMESTAMP
      description: timestamp is the number of milliseconds since EPOCH
      required: true
      schema:
        type: string
    BX-NONCE:
      in: header
      name: BX-NONCE
      description: nonce is a client side incremented unsigned 64 bit integer
      required: true
      schema:
        type: string
    BX-NONCE-WINDOW-ENABLED:
      in: header
      name: BX-NONCE-WINDOW-ENABLED
      description: string representation of a boolean value, [enables out-of-order order requests to be processed](/rest/order-processing-create-cancel-request-mechanism)
      required: false
      schema:
        type: string
        enum:
          - "false"
          - "true"
        default: "false"
  schemas:
    Boolean:
      type: boolean
      format: true or false
    OrderTypeAsString:
      type: string
      description: order type can have the following string values `"LMT"`, `"MKT"`, `"STOP_LIMIT"`, `"POST_ONLY"`
      example: "LMT"
    OrderSideAsString:
      type: string
      description: order side can have the following string values `"BUY"`, `"SELL"`
      example: BUY
    OrderTimeInForceAsString:
      type: string
      description: time in force can have the following string values `"GTC"`, `"FOK"`, `"IOC"`, see [details](/rest/general/order-type)
    OrderStatusAsString:
      type: string
      description: order status can have the following string values `"OPEN"`, `"CLOSED"`, `"CANCELLED"`, `"REJECTED"`
      example: OPEN
    TimeStampAsString:
      type: string
      format: string
      example: "1621490985000"
      description: unsigned 64 bit integer value which is the number of milliseconds since EPOCH expressed as string
    NonceAsString:
      type: string
      format: string
      example: "123456789"
      description: the nonce is a client side incremented unsigned 64 bit integer expressed as string
    SpotAccountID:
      type: string
      example: "1"
    OrderID:
      type: string
      example: "297735387747975680"
    AMMInstructionID:
      type: string
      example: "297735387747975680"
    RequestID:
      type: string
      example: "197735387747975680"
    OrderHandle:
      description: Unique numeric (i64) identifier generated on the client side expressed as a string value
      type: string
      example: "187"
    TradingAccountId:
      description: unique trading account ID
      type: string
      example: "111000000000001"
    AssetValue:
      description: see [asset value](/rest/general/price-quantity-precision) format
      type: string
      example: "1.00000000"
    DateTime:
      type: string
      format: date-time
      example: "2021-05-20T01:01:01.000Z"
      description: ISO 8601 with millisecond as string
    SpotAccount:
      type: object
      required:
        - accountId
        - type
        - symbol
        - total
        - free
        - used
        - updatedAtDatetime
        - updatedAtTimestamp
      properties:
        accountId:
          description: unique spot account ID
          allOf:
            - $ref: "#/components/schemas/SpotAccountID"
        type:
          description: Spot Account
          allOf:
            - type: string
              description: Type of Account
              example: spot
        symbol:
          description: asset symbol
          allOf:
            - $ref: "#/components/schemas/AssetSymbol"
        total:
          description: total is `free` + `used` assets within the account, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        free:
          description: refers to the assets that are available to use on the account excluding borrowed assets, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        used:
          description: refers to the assets that are locked in orders ,loans and AMM instructions, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        updatedAtDatetime:
          description: denotes the time the AMM instruction was updated by the exchange, ISO 8601 with millisecond as string
          allOf:
            - $ref: "#/components/schemas/DateTime"
        updatedAtTimestamp:
          description: denotes the time the AMM instruction was updated by the exchange
          allOf:
            - $ref: "#/components/schemas/TimeStampAsString"
    CreateOrderResponse:
      type: object
      required:
        - message
        - requestId
        - orderId
        - test
      properties:
        message:
          description: message
          type: string
          example: "Command acknowledged - CreateOrder"
        requestId:
          description: unique request ID
          allOf:
            - $ref: "#/components/schemas/RequestID"
        orderId:
          description: unique order ID
          allOf:
            - $ref: "#/components/schemas/OrderID"
    CreateOrderCommand:
      type: object
      required:
        - commandType
        - handle
        - symbol
        - type
        - side
        - price
        - stopPrice
        - quantity
        - allowMargin
        - timeInForce
        - tradingAccountId
      properties:
        commandType:
          description: The command type, it must be 'V2CreateOrder'
          type: string
          example: "V2CreateOrder"
        handle:
          allOf:
            - $ref: "#/components/schemas/OrderHandle"
        symbol:
          allOf:
            - $ref: "#/components/schemas/MarketSymbol"
        type:
          allOf:
            - $ref: "#/components/schemas/OrderTypeAsString"
          example: "LMT"
        side:
          allOf:
            - $ref: "#/components/schemas/OrderSideAsString"
          example: "BUY"
        price:
          description: price, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        stopPrice:
          description: stop price, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        quantity:
          description: quantity, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        timeInForce:
          allOf:
            - $ref: "#/components/schemas/OrderTimeInForceAsString"
          example: "GTC"
        allowMargin:
          description: allows to borrow on the order
          type: boolean
          example: false
        tradingAccountId:
          allOf:
            - $ref: "#/components/schemas/TradingAccountId"

    CreateAMMInstructionResponse:
      type: object
      required:
        - message
        - requestId
        - liquidityId
        - test
      properties:
        message:
          description: message
          type: string
          example: "Command acknowledged - AddLiquidity"
        requestId:
          description: unique request ID
          allOf:
            - $ref: "#/components/schemas/RequestID"
        liquidityId:
          description: unique AMM instruction ID
          allOf:
            - $ref: "#/components/schemas/AMMInstructionID"
    BadOrderEntryResponse:
      type: object
      required:
        - message
        - errorCode
        - errorCodeName
      properties:
        message:
          description: message
          type: string
          example: "Missing signature header"
        errorCode:
          description: unique error code
          type: integer
          example: 6029
        errorCodeName:
          description: unique error code name
          type: string
          example: "MISSING_SIGNATURE_HEADER"
    CreateAMMInstructionCommand:
      type: object
      required:
        - commandType
        - symbol
        - baseQuantity
        - quoteQuantity
        - upperBound
        - lowerBound
        - feeTierId
        - tradingAccountId
      properties:
        commandType:
          description: The command type, it must be 'V2AddLiquidity'
          type: string
          example: "V2AddLiquidity"
        symbol:
          allOf:
            - $ref: "#/components/schemas/MarketSymbol"
        baseQuantity:
          description: base quantity, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        quoteQuantity:
          description: quote quantity, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        upperBound:
          type: string
          description: upper bound of price range, in quote currency
          example: "14000.0000"
        lowerBound:
          type: string
          description: lower bound of price range, in quote currency
          example: "12000.0000"
        feeTierId:
          allOf:
            - $ref: "#/components/schemas/FeeTierId"
        tradingAccountId:
          allOf:
            - $ref: "#/components/schemas/TradingAccountId"
    CancelAllOrdersRequest:
      type: object
      required:
        - timestamp
        - nonce
        - authorizer
        - command
      properties:
        timestamp:
          allOf:
            - $ref: "#/components/schemas/TimeStampAsString"
        nonce:
          allOf:
            - $ref: "#/components/schemas/NonceAsString"
        authorizer:
          description: JWT authorizer you obtain along with the [JWT token](/rest/authentication#generate-a-jwt-token)
          allOf:
            - $ref: "#/components/schemas/Authorizer"
        command:
          description: the command to be executed which is sent in the request payload
          allOf:
            - $ref: "#/components/schemas/CancelAllOrdersCommand"
    CancelAllOrdersCommand:
      type: object
      required:
        - commandType
        - tradingAccountId
      properties:
        commandType:
          description: The command type, it must be 'V1CancelAllOrders'
          type: string
        tradingAccountId:
          description: unique trading account Id
          allOf:
            - $ref: "#/components/schemas/TradingAccountId"
      example:
        commandType: "V1CancelAllOrders"
        tradingAccountId: "111000000000001"
    CancelAllOrdersResponse:
      type: object
      required:
        - message
        - requestId
      properties:
        message:
          description: message
          type: string
        requestId:
          description: unique request ID
          allOf:
            - $ref: "#/components/schemas/RequestID"
      example:
        message: "Command acknowledged - CancelAllOrders"
        requestId: "633900538459062272"

    DelayedCancelAllOrdersRequest:
      type: object
      required:
        - timestamp
        - nonce
        - authorizer
        - command
      properties:
        timestamp:
          allOf:
            - $ref: "#/components/schemas/TimeStampAsString"
        nonce:
          allOf:
            - $ref: "#/components/schemas/NonceAsString"
        authorizer:
          description: JWT authorizer you obtain along with the [JWT token](/rest/authentication#generate-a-jwt-token)
          allOf:
            - $ref: "#/components/schemas/Authorizer"
        command:
          description: the command to be executed which is sent in the request payload
          allOf:
            - $ref: "#/components/schemas/DelayedCancelAllOrdersCommand"
    DelayedCancelAllOrdersCommand:
      type: object
      required:
        - commandType
        - delayBySeconds
        - tradingAccountId
      properties:
        commandType:
          description: The command type, it must be 'V1DelayedCancelAllOrders'
          type: string
          example: "V1DelayedCancelAllOrders"
        cancelId:
          allOf:
            - $ref: "#/components/schemas/CancelId"
        delayBySeconds:
          description: "Delay of the cancel-all-order in seconds"
          allOf:
            - $ref: "#/components/schemas/DelayBySeconds"
        tradingAccountId:
          allOf:
            - $ref: "#/components/schemas/TradingAccountId"
      example:
        commandType: "V1DelayedCancelAllOrders"
        delayBySeconds: "5"
        tradingAccountId: "111000000000001"
    DelayedCancelAllOrdersResponse:
      type: object
      required:
        - message
        - requestId
      properties:
        message:
          description: message
          type: string
        requestId:
          description: unique request ID
          allOf:
            - $ref: "#/components/schemas/RequestID"
      example:
        message: "Command acknowledged - DelayedCancelAllOrders"
        requestId: "633914459442118656"
    UnsetDelayedCancelAllOrdersRequest:
      type: object
      required:
        - timestamp
        - nonce
        - authorizer
        - command
      properties:
        timestamp:
          allOf:
            - $ref: "#/components/schemas/TimeStampAsString"
        nonce:
          allOf:
            - $ref: "#/components/schemas/NonceAsString"
        authorizer:
          description: JWT authorizer you obtain along with the [JWT token](/rest/authentication#generate-a-jwt-token)
          allOf:
            - $ref: "#/components/schemas/Authorizer"
        command:
          description: the command to be executed which is sent in the request payload
          allOf:
            - $ref: "#/components/schemas/UnsetDelayedCancelAllOrdersCommand"
    UnsetDelayedCancelAllOrdersCommand:
      type: object
      required:
        - commandType
        - tradingAccountId
      properties:
        commandType:
          description: The command type, it must be 'V1UnsetDelayedCancelAllOrders'
          type: string
          example: "V1UnsetDelayedCancelAllOrders"
        tradingAccountId:
          allOf:
            - $ref: "#/components/schemas/TradingAccountId"
      example:
        commandType: "V1UnsetDelayedCancelAllOrders"
        tradingAccountId: "111000000000001"
    UnsetDelayedCancelAllOrdersResponse:
      type: object
      required:
        - message
        - requestId
      properties:
        message:
          description: message
          type: string
        requestId:
          description: unique request ID
          allOf:
            - $ref: "#/components/schemas/RequestID"
      example:
        message: "Command acknowledged - UnsetDelayedCancelAllOrders"
        requestId: "633914459442118656"
    Authorizer:
      type: string
      format: string
      example: "03E02367E8C900000500000000000000"
      description: JWT authorizer you obtain along with the [JWT token](/rest/authentication#generate-a-jwt-token)
    TradingAccountTransferRequest:
      type: object
      required:
        - timestamp
        - nonce
        - authorizer
        - command
      properties:
        timestamp:
          allOf:
            - $ref: "#/components/schemas/TimeStampAsString"
        nonce:
          allOf:
            - $ref: "#/components/schemas/NonceAsString"
        authorizer:
          description: JWT authorizer you obtain along with the [JWT token](/rest/authentication#generate-a-jwt-token)
          allOf:
            - $ref: "#/components/schemas/Authorizer"
        command:
          description: the command to be executed which is sent in the request payload
          allOf:
            - $ref: "#/components/schemas/TransferAssetCommand"
    TradingAccountTransferResponse:
      type: object
      required:
        - message
        - requestId
      properties:
        message:
          description: message
          type: string
        requestId:
          description: unique request ID
          allOf:
            - $ref: "#/components/schemas/RequestID"
      example:
        message: "Command acknowledged - TransferAsset"
        requestId: "633909659774222336"
    TransferAssetCommand:
      type: object
      required:
        - commandType
        - assetSymbol
        - quantity
        - fromTradingAccountId
        - toTradingAccountId
      properties:
        commandType:
          description: The command type, e.g. 'V1TransferAsset'
          type: string
          example: "V1TransferAsset"
        assetSymbol:
          description: Symbol of the asset. i.e. currency
          allOf:
            - $ref: "#/components/schemas/AssetSymbol"
        quantity:
          description: Quantity of the asset.
          type: string
          example: "100"
        fromTradingAccountId:
          description: Source of the asset transfer
          allOf:
            - $ref: "#/components/schemas/TradingAccountId"
        toTradingAccountId:
          description: Destination of the asset transfer
          allOf:
            - $ref: "#/components/schemas/TradingAccountId"
    CancelAllOrdersByMarketRequest:
      type: object
      required:
        - timestamp
        - nonce
        - authorizer
        - command
      properties:
        timestamp:
          allOf:
            - $ref: "#/components/schemas/TimeStampAsString"
        nonce:
          allOf:
            - $ref: "#/components/schemas/NonceAsString"
        authorizer:
          description: JWT authorizer you obtain along with the [JWT token](/rest/authentication#generate-a-jwt-token)
          allOf:
            - $ref: "#/components/schemas/Authorizer"
        command:
          description: the command to be executed which is sent in the request payload
          allOf:
            - $ref: "#/components/schemas/CancelAllOrdersByMarketCommand"
    CancelAllOrdersByMarketCommand:
      type: object
      required:
        - commandType
        - symbol
        - tradingAccountId
      properties:
        commandType:
          description: The command type, it must be 'V1CancelAllOrdersByMarket'
          type: string
        symbol:
          description: market symbol
          allOf:
            - $ref: "#/components/schemas/MarketSymbol"
        tradingAccountId:
          description: unique trading account Id
          allOf:
            - $ref: "#/components/schemas/TradingAccountId"
      example:
        commandType: "V1CancelAllOrdersByMarket"
        symbol: "BTCUSDC"
        tradingAccountId: "111000000000001"
    CancelAllOrdersByMarketResponse:
      type: object
      required:
        - message
        - requestId
      properties:
        message:
          description: message
          type: string
        requestId:
          description: unique request ID
          allOf:
            - $ref: "#/components/schemas/RequestID"
      example:
        message: "Command acknowledged - CancelAllOrdersByMarket"
        requestId: "633914459442118656"
    CreateOrderRequest:
      type: object
      required:
        - timestamp
        - nonce
        - authorizer
        - command
      properties:
        timestamp:
          allOf:
            - $ref: "#/components/schemas/TimeStampAsString"
        nonce:
          allOf:
            - $ref: "#/components/schemas/NonceAsString"
        authorizer:
          description: JWT authorizer you obtain along with the [JWT token](/rest/authentication#generate-a-jwt-token)
          allOf:
            - $ref: "#/components/schemas/Authorizer"
        command:
          description: the command to be executed which is sent in the request payload
          allOf:
            - $ref: "#/components/schemas/CreateOrderCommand"
    CreateAMMInstructionRequest:
      type: object
      required:
        - timestamp
        - nonce
        - authorizer
        - command
      properties:
        timestamp:
          allOf:
            - $ref: "#/components/schemas/TimeStampAsString"
        nonce:
          allOf:
            - $ref: "#/components/schemas/NonceAsString"
        authorizer:
          description: JWT authorizer you obtain along with the [JWT token](/rest/authentication#generate-a-jwt-token)
          allOf:
            - $ref: "#/components/schemas/Authorizer"
        command:
          description: the command to be executed which is sent in the request payload
          allOf:
            - $ref: "#/components/schemas/CreateAMMInstructionCommand"
    Order:
      type: object
      required:
        - orderId
        - handle
        - clientOrderId
        - symbol
        - price
        - stopPrice
        - averageFillPrice
        - margin
        - allowBorrow
        - quantity
        - quantityFilled
        - quoteAmount
        - baseFee
        - quoteFee
        - borrowedQuantity
        - borrowedBaseQuantity
        - borrowedQuoteQuantity
        - isLiquidation
        - side
        - type
        - timeInForce
        - status
        - statusReason
        - statusReasonCode
        - createdAtTimestamp
        - createdAtDatetime
      properties:
        handle:
          deprecated: true
          allOf:
            - $ref: "#/components/schemas/OrderHandle"
        clientOrderId:
          allOf:
            - $ref: "#/components/schemas/OrderHandle"
        orderId:
          description: unique order ID
          allOf:
            - $ref: "#/components/schemas/OrderID"
        symbol:
          description: market symbol
          allOf:
            - $ref: "#/components/schemas/MarketSymbol"
        price:
          description: price, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        averageFillPrice:
          description: average fill price, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        stopPrice:
          description: stop price, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        margin:
          description: indicates if the order was allowed to borrow (does not indicate that borrowing occurred)
          type: boolean
          deprecated: true
          example: false
        allowBorrow:
          description: indicates if the order was allowed to borrow (does not indicate that borrowing occurred)
          type: boolean
          example: false
        quantity:
          description: quantity, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        quantityFilled:
          description: quantity filled, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        quoteAmount:
          description: quote quantity deducted from asset account, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        baseFee:
          description: base fee, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        quoteFee:
          description: quote fee, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        borrowedQuantity:
          deprecated: true
          description: quantity borrowed, see [asset value](/rest/general/price-quantity-precision) format - BUY order borrows quote, SELL order borrows base
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        borrowedBaseQuantity:
          description: quantity borrowed, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        borrowedQuoteQuantity:
          description: quantity borrowed, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        isLiquidation:
          description: indicates if the order was executed as a liquidation order
          type: boolean
          example: false
        side:
          description: order side
          allOf:
            - $ref: "#/components/schemas/OrderSideAsString"
          example: "BUY"
        type:
          description: order type
          allOf:
            - $ref: "#/components/schemas/OrderTypeAsString"
          example: "LMT"
        timeInForce:
          description: time in force
          allOf:
            - $ref: "#/components/schemas/OrderTimeInForceAsString"
          example: "GTC"
        status:
          description: order status
          allOf:
            - $ref: "#/components/schemas/OrderStatusAsString"
          example: "OPEN"
        statusReason:
          description: status reason, describes why the order is in a specific state
          type: string
          example: "User cancelled"
        statusReasonCode:
          description: status reason code, see [details](/rest/general/error-rejection-codes)
          type: string
          example: "1002"
        createdAtDatetime:
          description: denotes the time the order was ACK'd by the exchange, ISO 8601 with millisecond as string
          allOf:
            - $ref: "#/components/schemas/DateTime"
        createdAtTimestamp:
          description: denotes the time the order was ACK'd by the exchange
          allOf:
            - $ref: "#/components/schemas/TimeStampAsString"
    AMMInstruction:
      type: object
      required:
        - apy
        - baseCurrentQuantity
        - baseFee
        - baseInvestQuantity
        - basePrice
        - baseWithdrawQuantity
        - createdAtDatetime
        - createdAtTimestamp
        - currentValue
        - dislocationEnabled
        - feeTierId
        - impermanentLoss
        - initialBasePrice
        - initialQuotePrice
        - initialValue
        - liquidityId
        - instructionId
        - lowerBound
        - price
        - quoteFee
        - quoteInvestQuantity
        - quotePrice
        - quoteWithdrawQuantity
        - requestId
        - staticSpreadFee
        - status
        - statusReason
        - statusReasonCode
        - symbol
        - updatedAtDatetime
        - updatedAtTimestamp
        - upperBound
        - yieldEarn
      properties:
        liquidityId:
          description: unique AMM instruction ID
          deprecated: true
          allOf:
            - $ref: "#/components/schemas/AMMInstructionID"
        instructionId:
          description: unique AMM instruction ID
          allOf:
            - $ref: "#/components/schemas/AMMInstructionID"
        symbol:
          description: market symbol
          allOf:
            - $ref: "#/components/schemas/MarketSymbol"
        baseFee:
          description: base fee, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        quoteFee:
          description: quote fee, see [asset value](/rest/general/price-quantity-precision) format
          allOf:
            - $ref: "#/components/schemas/AssetValue"
        status:
          description: order status
          allOf:
            - $ref: "#/components/schemas/OrderStatusAsString"
          example: "OPEN"
        statusReason:
          description: status reason, describes why the order is in a specific state
          type: string
          example: "Ok"
        statusReasonCode:
          description: status reason code, see [details](/rest/general/error-rejection-codes)
          type: integer
          example: 1001
        createdAtDatetime:
          description: denotes the time the order was ACK'd by the exchange, ISO 8601 with millisecond as string
          allOf:
            - $ref: "#/components/schemas/DateTime"
        createdAtTimestamp:
          description: denotes the time the order was ACK'd by the exchange
          allOf:
            - $ref: "#/components/schemas/TimeStampAsString"
        24HrApy:
          type: string
          description: APY of the last 24 Hours, only for AMM instructions with `OPEN` status
          example: "2.3319"
        24HrYieldEarn:
          type: string
          description: amount of money earned in USD from the last 24 Hours, only for AMM instructions with `OPEN` status
          example: "0.00"
        apy:
          type: string
          description: yield generated from the time AMM instruction was created, in annualised percentage
          example: "0.0000"
        baseCurrentQuantity:
          type: string
          description: amount of base asset this AMM instruction currently holds, only for AMM instruction with `OPEN` status
          example: "0.00000000"
        baseInvestQuantity:
          type: string
          description: initial base investment
          example: "0.00000008"
        basePrice:
          type: string
          description: current price of base asset
          example: "345.6700"
        baseWithdrawQuantity:
          type: string
          description: amount of base asset returned when AMM instruction is terminated
          example: "0.00000010"
        currentValue:
          type: string
          description: value of assets (base and quote) in USD amount that this AMM instruction currently holds
          example: "0.0000"
        dislocationEnabled:
          description: dislocation enabled/disabled
          type: boolean
          example: false
        feeTierId:
          allOf:
            - $ref: "#/components/schemas/FeeTierId"
        finalValue:
          type: string
          description: value of assets (base and quote) in USD amount when AMM instruction was terminated, only for AMM instruction with `CLOSED` status
          example: "0.0001"
        impermanentLoss:
          type: string
          description: impermanent loss
          example: "0.0000"
        initialBasePrice:
          type: string
          description: price of base asset when AMM instruction was created
          example: "100.0000"
        initialQuotePrice:
          type: string
          description: price of quote asset when AMM instruction was created
          example: "0.0100"
        initialValue:
          type: string
          description: value of assets (base and quote) in USD amount when AMM instruction was created
          example: "0.0000"
        lowerBound:
          type: string
          description: lower bound of price range, in quote currency
          example: "0.0013"
        price:
          type: string
          description: current price of AMM, see [Get Tick By Symbol](/rest/api/get-market-tick)
          example: "456.7800"
        quoteCurrentQuantity:
          type: string
          description: amount of quote asset this AMM instruction currently holds, only for AMM instruction with `OPEN` status
          example: "0.0000"
        quoteInvestQuantity:
          type: string
          description: initial quote investment
          example: "0.0009"
        quotePrice:
          type: string
          description: current price of quote asset
          example: "1.0000"
        quoteWithdrawQuantity:
          type: string
          description: amount of quote asset returned when AMM instruction is terminated
          example: "0.0011"
        lastDistributedPrice:
          type: string
          nullable: true
          description: (Perpetual market only) The price used at the time of settlement for AMM Instructions that can be used to determine mtmPnl and the actual Pnl
          example: null
        requestId:
          description: unique request ID
          allOf:
            - $ref: "#/components/schemas/RequestID"
        staticSpreadFee:
          type: string
          description: static spread fee, see [Get Market By Symbol](/rest/api/get-market-by-symbol)
          example: "0.00200000"
        updatedAtDatetime:
          description: denotes the time the AMM instruction was updated by the exchange, ISO 8601 with millisecond as string
          allOf:
            - $ref: "#/components/schemas/DateTime"
        updatedAtTimestamp:
          description: denotes the time the AMM instruction was updated by the exchange
          allOf:
            - $ref: "#/components/schemas/TimeStampAsString"
        upperBound:
          type: string
          description: upper bound of price range, in quote currency
          example: "14000.0000"
        yieldEarn:
          type: string
          description: amount of money earned in USD
          example: "0.00"
    MarketSymbol:
      type: string
      description: market symbol. E.g. `BTCUSDC` for SPOT and `BTC-USDC-PERP` for PERPETUAL market
      example: "BTCUSDC"
    FeeTierId:
      type: string
      description: unique fee tier ID, see [Get Market By Symbol](/rest/api/get-market-by-symbol)
      example: "1"
    AssetSymbol:
      type: string
      description: asset symbol as denoted in the world
      example: "BTC"
    OrderSide:
      type: string
      example: BUY
      enum:
        - BUY
        - SELL
    OrderStatus:
      type: string
      example: OPEN
      enum:
        - OPEN
        - CLOSED
        - CANCELLED
        - REJECTED
    AMMInstructionStatus:
      type: string
      example: OPEN
      enum:
        - OPEN
        - CLOSED
    DelayBySeconds:
      description: Delay the cancel-all-orders request by (seconds) as a timeout mechanism
      type: string
      enum:
        - "5"
        - "10"
        - "15"
        - "20"
        - "25"
        - "30"
        - "40"
        - "50"
        - "60"
      example: "5"
    CancelId:
      description: Unique id for this cancel request which is an unsigned 64 bit integer expressed as string
      type: string
      example: "123456789"
