openapi: 3.0.1
info:
  title: Anboto Trading API
  description: "Anboto Trading API <BR><BR> <B>Authentication</B><BR>Please visit\
    \ Anboto's website to generate an API key<BR>   Mainnet:<BR>        - <a href=\"\
    https://api.trade.anboto.xyz\">https://api.trade.anboto.xyz</a><BR>   Testnet:<BR>\
    \        - <a href=\"https://api.testnet.anboto.xyz\">https://api.testnet.anboto.xyz</a><BR>\
    \          <I>(All trades are simulated on testnet and will not trade on any real\
    \ exchange)</I><BR><BR>Select Your API Key Type<BR>     1) <B>System-generated</B>\
    \ API Keys: The API key generated by Anboto use HMAC encryption. You will be provided\
    \ with a an API key and a secret key, that can be used to trade, please keep the\
    \ keys safe.<BR>   2) <B>Self-generated</B> API keys operate with RSA encryption.\
    \      You must create your public and private keys and only provide the public\
    \ key to Anboto, we will never hold your private key.<BR><BR><B>Parameters for\
    \ Authenticated Endpoints</B>The following HTTP header keys must be used for authentication\
    \ on <U>any endpoint annotated with <B>'ApiKeyAuth'</B></U>:<BR> - <B>X-API-KEY</B>\
    \ - API key<BR> - <B>X-TIMESTAMP</B> - timestamp in milliseconds from epoch<BR>\
    \ - <B>X-SIGN</B> - a signature derived from the request's parameters<BR> - <B>X-RECV-WINDOW</B>\
    \ (unit in millisecond and default value is 5,000) to specify how long an HTTP\
    \ request is valid. A smaller X-RECV-WINDOW is more secure, but your request may\
    \ fail if the transmission time is greater than your X-RECV-WINDOW.<BR><BR><B>Basic\
    \ steps:</B><BR>1. The string to sign should be a concatenation of 'timestamp\
    \ + API key + (recv_window) + (queryString | jsonBodyString)' The queryString\
    \ should be assembled in alphabetical order.<BR>2. Take your secret key and decode\
    \ from Base664 into a byte array and then use the HMAC_SHA256 (for system generated\
    \ keys) or RSA_SHA256 algorithm to sign the string in step 1.<BR>3. Convert the\
    \ signed value to a hex string (HMAC_SHA256) / base64 (RSA_SHA256) to obtain the\
    \ sign parameter.<BR>4. Append the sign parameter to request header, and send\
    \ the HTTP request. <BR><BR>Examples can be found here: <a href=\"https://github.com/anbotolabs/examples\"\
    >https://github.com/anbotolabs/examples</a><BR>The OpenAPI spec can be found here:\
    \ <a href=\"https://anbotolabs.github.io/anboto-api-docs/anboto-trading-api-2.0.yml\"\
    >https://anbotolabs.github.io/anboto-api-docs/anboto-trading-api-2.0.yml</a>"
  version: "2.0"
paths:
  /api/v2/data/exchanges:
    get:
      tags:
      - Data Rest API
      summary: Returns a list of exchanges supported
      description: Return a list of exchanges availablel to trade
      operationId: exchanges
      responses:
        "200":
          description: The exchanges.
          content:
            application/json:
              schema:
                type: string
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/data/fundingRateHistory:
    get:
      tags:
      - Data Rest API
      summary: Returns funding rates histroy
      description: Return all funding rates history based on filter parameters
      operationId: fundingRateHistory
      parameters:
      - name: exchange
        in: query
        description: Return last funding rates on this exchange for each asset
        schema:
          type: string
          nullable: true
      - name: symbol
        in: query
        description: Return last funding rates for this asset on each exchange
        schema:
          type: string
          nullable: true
      responses:
        "200":
          description: The last funding rates.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FundingRate'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/data/instruments:
    get:
      tags:
      - Data Rest API
      summary: Returns list of instruments
      description: Return all instruments based on filter parameters
      operationId: instruments
      parameters:
      - name: exchange
        in: query
        description: Return all instruments on this exchange for each asset
        schema:
          type: string
          nullable: true
      - name: symbol
        in: query
        description: Return instrument with this symbol
        schema:
          type: string
          nullable: true
      responses:
        "200":
          description: The instruments
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Instrument'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/data/lastFundingRates:
    get:
      tags:
      - Data Rest API
      summary: Returns last funding rates
      description: Return all funding rates based on filter parameters
      operationId: lastFundingRates
      parameters:
      - name: exchange
        in: query
        description: Return last funding rates on this exchange for each asset
        schema:
          type: string
          nullable: true
      - name: symbol
        in: query
        description: Return last funding rates for this asset on each exchange
        schema:
          type: string
          nullable: true
      responses:
        "200":
          description: The last funding rates.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FundingRate'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/trading/balance:
    get:
      tags:
      - Rest API
      summary: Returns the balance of assets in an exchange on default account
      description: shows the asset balance > 0
      operationId: getBalance
      parameters:
      - name: exchange
        in: query
        description: The exchange
        required: true
        schema:
          $ref: '#/components/schemas/Exchange'
      - name: subaccount
        in: query
        description: Sub-account
        schema:
          type: string
          nullable: true
      responses:
        "200":
          description: The list of asset balance > 0
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderDetailsList'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/trading/order/byId:
    get:
      tags:
      - Rest API
      summary: Returns the order details for all matching orders
      description: Either orderIds or clientOrderIds has to be provided for matching
      operationId: getOrders
      parameters:
      - name: orderIds
        in: query
        description: The list of anboto generated order ids
        schema:
          type: array
          nullable: true
          items:
            type: integer
            format: int64
      - name: clientOrderIds
        in: query
        description: The list of client generated order ids
        schema:
          type: array
          nullable: true
          items:
            type: string
      responses:
        "200":
          description: return a list of matching orders
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderDetailsList'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/trading/order/cancel:
    post:
      tags:
      - Rest API
      summary: Cancels the parent order
      description: This will initiate a cancellation request and set the order state
        to pending cancel. For the finalized state call /order/id?orderId=xxx
      operationId: cancelOrder
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelUpstreamOrderRequest'
        required: true
      responses:
        "200":
          description: Cancellation request processed and in progress.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderSummary'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/trading/order/cancelAll:
    get:
      tags:
      - Rest API
      summary: Cancels all open orders
      description: All orders that are not in a terminal state will be cancelled
      operationId: cancelAllOpenOrders
      responses:
        "200":
          description: The list of open orders that will be cancelled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderDetailsList'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/trading/order/cancelMany:
    post:
      tags:
      - Rest API
      summary: Cancels all of the parent orders specified in the batch request
      description: This will initiate the order cancellations and set the status of
        all orders to pending cancel. For the finalized state call /order?orderId=xxx
      operationId: cancelMany
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelManyUpstreamOrdersRequest'
        required: true
      responses:
        "200":
          description: Cancellation request processed and in progress.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderSummary'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/trading/order/create:
    post:
      tags:
      - Rest API
      summary: Create a new order
      description: Process a new order request and return order response
      operationId: createOrder
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateParentOrderRequest'
        required: true
      responses:
        "201":
          description: Order created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderSummary'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/trading/order/createMany:
    post:
      tags:
      - Rest API
      summary: Creates many new orders in a single request.
      description: "Process a set of new order request and returns a summary for each\
        \ order, the orders are not linked during execution and this endpoint is for\
        \ convenience only"
      operationId: createManyOrders
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateManyParentOrdersRequest'
        required: true
      responses:
        "201":
          description: Order processed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderSummaryList'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/trading/order/createMany/multilegs:
    post:
      tags:
      - Rest API
      summary: Creates many new multilegs orders in a single request.
      description: "Process a set of new order request and returns a summary for each\
        \ order, the orders are not linked during execution and this endpoint is for\
        \ convenience only"
      operationId: createManyMultiLegsOrders
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateManyMultiLegsParentOrdersRequest'
        required: true
      responses:
        "201":
          description: Order processed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderSummaryList'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/trading/order/create_multiLegs:
    post:
      tags:
      - Rest API
      summary: Create a new multilegs order
      description: Process a new order request and return order response
      operationId: createMultiLegsOrder
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateMultiLegsParentOrderRequest'
        required: true
      responses:
        "201":
          description: Order created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderSummary'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/trading/order/find:
    get:
      tags:
      - Rest API
      summary: Returns the order details for all matching orders
      description: Only matched order within 3 days will be return
      operationId: findOrders
      parameters:
      - name: startMs
        in: query
        description: The start time for the query as ms since epoch
        schema:
          type: integer
          format: int64
          nullable: true
      - name: endMs
        in: query
        description: The end time for the query as ms since epoch
        schema:
          type: integer
          format: int64
          nullable: true
      - name: limit
        in: query
        description: The maximum number of orders to return in the results
        schema:
          type: integer
          format: int32
          nullable: true
      responses:
        "200":
          description: The list of matching orders.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderDetailsList'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/trading/order/open:
    get:
      tags:
      - Rest API
      summary: Returns all open orders
      description: All orders that are not in a terminal state will be returned
      operationId: getOpenOrders
      responses:
        "200":
          description: The list of open orders.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderDetailsList'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/trading/position:
    get:
      tags:
      - Rest API
      summary: Returns the position of assets in an exchange on default account
      description: shows the asset position != 0
      operationId: getPosition
      parameters:
      - name: exchange
        in: query
        description: The exchange
        required: true
        schema:
          $ref: '#/components/schemas/Exchange'
      - name: subaccount
        in: query
        description: Sub-account
        schema:
          type: string
          nullable: true
      responses:
        "200":
          description: The list of matching orders.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderDetailsList'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /api/v2/trading/userTrades:
    get:
      tags:
      - Rest API
      summary: Returns the trades of orders in an exchange on default account by a
        list of order Ids/client order Ids
      description: Either orderIds or clientOrderIds has to be provided for matching
      operationId: getUserTrades
      parameters:
      - name: exchange
        in: query
        description: The exchange
        required: true
        schema:
          $ref: '#/components/schemas/Exchange'
      - name: subaccount
        in: query
        description: Sub-account
        schema:
          type: string
          nullable: true
      - name: orderIds
        in: query
        description: The list of anboto generated order ids
        schema:
          type: array
          nullable: true
          items:
            type: integer
            format: int64
      - name: clientOrderIds
        in: query
        description: The list of client generated order ids
        schema:
          type: array
          nullable: true
          items:
            type: string
      responses:
        "200":
          description: A list of matching trades.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderDetailsList'
        "401":
          description: "Unauthorized, Invalid Signature"
      security:
      - ApiKeyAuth: []
  /status/ping:
    get:
      operationId: status
      responses:
        "200":
          description: status 200 response
          content:
            application/json:
              schema:
                type: string
components:
  schemas:
    ApiErrorCode:
      type: string
      description: The error code used to describe why an order was rejected.
      enum:
      - OTHER
      - QUANTITY_EXCEED
      - AUTHENTICATION_ERROR
      - INSUFFICIENT_FUNDS
      - RATE_LIMIT_EXCEEDED
      - DDOS_PROTECTION
      - EXCHANGE_NOT_AVAILABLE
      - NETWORK_ERROR
      - INVALID_ORDER
      - EXCHANGE_ERROR
      - EMS_INSTANCES_DOWN
      - SLIPPAGE_EXCEEDED
      - EXPIRY_REACHED
      - MAX_FEE_PER_GAS_IS_TOO_LOW
      - PARENT_ORDER_WAS_TERMINATED
      - MAX_PRIORITY_FEE_PER_GAS_IS_TOO_LOW
      - INVALID_QUANTITY
      - INVALID_END_TIME
      - INVALID_TRADE_TIME
      - INVALID_FEE
      - INVALID_SYMBOL
      - INVALID_TRADE_STRATEGY
      - INVALID_LIMIT_PRICE
      - INVALID_WOULD_PRICE
      - INVALID_TRIGGER_PRICE
      - INVALID_PARAM
      - INVALID_EXCHANGE
      - INVALID_SIGNATURE
      - INVALID_API_KEY
      - INVALID_TIMESTAMP
      - BATCH_OVERSIZE
      - SYSTEM_ERROR
      - INVALID_REQUEST
      - SYSTEM_BUSY
    AssetCategory:
      type: string
      description: The Asset category of the order.
      enum:
      - SPOT
      - FUTURE
    AssetClass:
      type: string
      enum:
      - UNDEFINED
      - SPOT
      - FUTURE
      - OPTION
      - CFD
    CancelManyUpstreamOrdersRequest:
      required:
      - orders
      type: object
      properties:
        orders:
          type: array
          description: The list of parent cancellation requests
          items:
            $ref: '#/components/schemas/CancelUpstreamOrderRequest'
      description: Used for cancelling many parent orders at the same time
    CancelUpstreamOrderRequest:
      type: object
      properties:
        order_id:
          type: integer
          description: The Anboto generated order id
          format: int64
          nullable: true
          example: 123456
        client_order_id:
          type: string
          description: The client provided order id
          nullable: true
          example: xxx-yyy-zzzz
      description: Used for cancelling a parent order
    ClipSizeType:
      type: string
      description: The clip size for the child orders. The default is AUTOMATIC
      enum:
      - ABSOLUTE
      - PERCENTAGE
      - AUTOMATIC
    CreateManyMultiLegsParentOrdersRequest:
      required:
      - orders
      type: object
      properties:
        orders:
          type: array
          items:
            $ref: '#/components/schemas/CreateMultiLegsParentOrderRequest'
      description: A request to create many multilegs orders in a single request.
    CreateManyParentOrdersRequest:
      required:
      - orders
      type: object
      properties:
        orders:
          type: array
          items:
            $ref: '#/components/schemas/CreateParentOrderRequest'
      description: A request to create many parent orders in a single request.
    CreateMultiLegsParentOrderRequest:
      required:
      - algo
      - legs
      type: object
      properties:
        client_order_id:
          type: string
          description: A custom string to identify the order
          nullable: true
          example: ABC-12345^12-10-23
        subaccount:
          type: string
          description: The sub-account under which to trade the order
          nullable: true
        algo:
          description: The algo to execute the order
          allOf:
          - $ref: '#/components/schemas/MultiLegsAlgo'
        legs:
          type: array
          description: The order legs
          items:
            $ref: '#/components/schemas/CreateOrderLegRequest'
        start_time:
          type: string
          description: The start time in UTC
          nullable: true
          example: 2024-01-22T22:05:00Z
        end_time:
          type: string
          description: The end time in UTC
          nullable: true
          example: 2024-04-22T22:05:00Z
        params:
          nullable: true
          allOf:
          - $ref: '#/components/schemas/MultiLegsOrderParams'
      description: Used for creating a parent order.
    CreateOrderLegRequest:
      required:
      - asset_category
      - ccy
      - exchange
      - side
      - strategy
      - symbol
      - target_value
      type: object
      properties:
        exchange:
          description: "The execution exchange, e.g. BINANCE"
          allOf:
          - $ref: '#/components/schemas/Exchange'
        symbol:
          type: string
          description: "The symbol using Anboto symbology, e.g. BTC/USDT"
        asset_category:
          allOf:
          - $ref: '#/components/schemas/AssetCategory'
          - type: string
            description: The asset category
            example: SPOT
        side:
          $ref: '#/components/schemas/Side'
        target_value:
          type: string
          description: The target value to be filled
          example: "12.0"
        ccy:
          type: string
          description: The currency of target value
          example: USD
        limit_price:
          type: string
          description: The exchange valid limit price for the order leg
          nullable: true
          example: "2205.10"
        strategy:
          $ref: '#/components/schemas/ExecutionStrategy'
        clip_size_type:
          nullable: true
          allOf:
          - $ref: '#/components/schemas/ClipSizeType'
          - type: string
            description: The clip size type
            example: AUTOMATIC
            default: AUTOMATIC
          default: AUTOMATIC
        clip_size_val:
          type: string
          description: "The clip size value, required if the type is ABSOLUTE or PERCENTAGE"
          nullable: true
          example: "0.01"
        params:
          nullable: true
          allOf:
          - $ref: '#/components/schemas/OrderLegParams'
      description: Used for creating a parent order.
    CreateParentOrderRequest:
      required:
      - asset_category
      - exchange
      - quantity
      - side
      - strategy
      - symbol
      type: object
      properties:
        client_order_id:
          type: string
          description: A custom string to identify the order
          nullable: true
          example: ABC-12345^12-10-23
        exchange:
          description: "The execution exchange, e.g. BINANCE"
          allOf:
          - $ref: '#/components/schemas/Exchange'
        subaccount:
          type: string
          description: The sub-account under which to trade the order
          nullable: true
        symbol:
          type: string
          description: "The symbol using Anboto symbology, e.g. BTC/USDT"
        asset_category:
          allOf:
          - $ref: '#/components/schemas/AssetCategory'
          - type: string
            description: The asset category
            example: SPOT
        side:
          $ref: '#/components/schemas/Side'
        quantity:
          type: string
          description: "The quantity to trade as a exchange trade-able decimal value,\
            \ e.g. 0.015"
        strategy:
          $ref: '#/components/schemas/ExecutionStrategy'
        limit_price:
          type: string
          description: The exchange valid limit price for the order
          nullable: true
          example: "2205.10"
        start_time:
          type: string
          description: The start time in UTC
          nullable: true
          example: 2024-01-22T22:05:00Z
        end_time:
          type: string
          description: The end time in UTC
          nullable: true
          example: 2024-04-22T22:05:00Z
        clip_size_type:
          nullable: true
          allOf:
          - $ref: '#/components/schemas/ClipSizeType'
          - type: string
            description: The clip size type
            example: AUTOMATIC
            default: AUTOMATIC
          default: AUTOMATIC
        clip_size_val:
          type: string
          description: "The clip size value, required if the type is ABSOLUTE or PERCENTAGE"
          nullable: true
          example: "0.01"
        params:
          nullable: true
          allOf:
          - $ref: '#/components/schemas/OrderParams'
      description: Used for creating a parent order.
    Exchange:
      type: string
      description: The exchange where to trade the order.
      enum:
      - BINANCE
      - HUOBI
      - COINBASE_ADV
      - GATEIO
      - KRAKEN
      - KUCOIN
      - OKX
      - BYBIT
      - WOO
      - MEXC
      - BITGET
      - BULLISH
      - B2C2
      - HYPERLIQUID
      - COINBASE_PRIME
      - COINBASE_INTL
      - EXTENDED
    ExecutionStrategy:
      type: string
      description: The execution strategy for the order.
      enum:
      - TWAP
      - VWAP
      - ICEBERG
      - POV
      - MARKET
      - LIMIT
      - IS
    FundingRate:
      required:
      - exchange
      - nextTime
      - rate
      - symbol
      - time
      type: object
      properties:
        exchange:
          type: string
        symbol:
          type: string
        time:
          type: string
          format: date-time
        nextTime:
          type: string
          format: date-time
        rate:
          type: number
          format: double
        nextRate:
          type: number
          format: double
          nullable: true
        markPrice:
          type: number
          format: double
          nullable: true
    Instrument:
      required:
      - assetClass
      - baseAsset
      - enabled
      - exchange
      - exchangeAssetClass
      - exchangeSymbol
      - quoteAsset
      - symbol
      - timestamp
      type: object
      properties:
        exchange:
          $ref: '#/components/schemas/Exchange'
        symbol:
          type: string
        baseAsset:
          type: string
        quoteAsset:
          type: string
        exchangeSymbol:
          type: string
        exchangeAssetClass:
          type: string
        assetClass:
          $ref: '#/components/schemas/AssetClass'
        quantityPrecision:
          type: integer
          format: int32
          nullable: true
        pricePrecision:
          type: integer
          format: int32
          nullable: true
        maxQuantityLimit:
          type: number
          format: double
          nullable: true
        minQuantityLimit:
          type: number
          format: double
          nullable: true
        minCostLimit:
          type: number
          format: double
          nullable: true
        maxCostLimit:
          type: number
          format: double
          nullable: true
        contractSize:
          type: number
          format: double
          nullable: true
        minMarketLimit:
          type: number
          format: double
          nullable: true
        maxMarketLimit:
          type: number
          format: double
          nullable: true
        minPriceLimit:
          type: number
          format: double
          nullable: true
        maxPriceLimit:
          type: number
          format: double
          nullable: true
        enabled:
          type: boolean
        timestamp:
          type: string
          format: date-time
        priceSignificantFigure:
          type: integer
          format: int32
          nullable: true
        quantitySignificantFigure:
          type: integer
          format: int32
          nullable: true
        assetId:
          type: string
          nullable: true
    MultiLegsAlgo:
      type: string
      description: The execution strategy for the order.
      enum:
      - PAIR
    MultiLegsOrderParams:
      type: object
      properties: {}
      description: The advanced order parameters to modify the execution behavior.
    OrderDetails:
      required:
      - average_price
      - filled_quantity
      - last_price
      - last_quantity
      - leaves_quantity
      - status
      - symbol
      type: object
      properties:
        order_id:
          type: integer
          description: The Anboto generated order id
          format: int64
          nullable: true
          example: 123456
        client_order_id:
          type: string
          description: The client provided order id
          nullable: true
          example: xxx-yyy-zzz
        symbol:
          type: string
          description: The order symbol using Anboto symbology
        status:
          $ref: '#/components/schemas/OrderStatus'
        filled_quantity:
          type: number
          description: The absolute amount of the order quantity filled
          example: 0
        leaves_quantity:
          type: number
          description: The absolute amount of the order quantity remaining to be filled
          example: 0
        side:
          nullable: true
          allOf:
          - $ref: '#/components/schemas/Side'
        last_quantity:
          type: number
          description: The last qty received in a fill from the exchange
          example: 0
        last_price:
          type: number
          description: The last price executed on the exchange
          example: 0
        average_price:
          type: number
          description: The average execution price of the order
          example: 0
    OrderDetailsList:
      required:
      - orders
      type: object
      properties:
        orders:
          type: array
          description: The list of order details for separate orders.
          items:
            $ref: '#/components/schemas/OrderDetails'
    OrderLegParams:
      type: object
      properties:
        duration_seconds:
          type: string
          description: "The duration of the order in seconds, this is a required field\
            \ for TWAP and VWAP."
          nullable: true
          example: "120"
        trading_style:
          nullable: true
          allOf:
          - $ref: '#/components/schemas/TradingStyle'
          - type: string
            description: The trading style to use for the order
        urgency:
          description: IS strategy
          nullable: true
          allOf:
          - $ref: '#/components/schemas/Urgency'
          - type: string
            description: "The urgency level to use for the IS strategy. Default: MEDIUM"
        randomize_amount:
          type: boolean
          description: Whether to randomize the slice amount
          nullable: true
        would:
          nullable: true
          allOf:
          - $ref: '#/components/schemas/WouldInfo'
        trigger:
          nullable: true
          allOf:
          - $ref: '#/components/schemas/TriggerInfo'
        placement_infos:
          nullable: true
          allOf:
          - $ref: '#/components/schemas/PlacementInfo'
          - type: object
            description: The placement information for the order
        is_leading:
          type: boolean
          description: true if this is a leading leg
      description: The advanced order parameters to modify the execution behavior.
    OrderParams:
      type: object
      properties:
        duration_seconds:
          type: string
          description: "The duration of the order in seconds, this is a required field\
            \ for TWAP and VWAP."
          nullable: true
          example: "120"
        trading_style:
          nullable: true
          allOf:
          - $ref: '#/components/schemas/TradingStyle'
          - type: string
            description: The trading style to use for the order
        urgency:
          description: IS strategy
          nullable: true
          allOf:
          - $ref: '#/components/schemas/Urgency'
          - type: string
            description: "The urgency level to use for the IS strategy. Default: MEDIUM"
        randomize_amount:
          type: boolean
          description: Whether to randomize the slice amount
          nullable: true
        would:
          nullable: true
          allOf:
          - $ref: '#/components/schemas/WouldInfo'
        trigger:
          nullable: true
          allOf:
          - $ref: '#/components/schemas/TriggerInfo'
        placement_infos:
          nullable: true
          allOf:
          - $ref: '#/components/schemas/PlacementInfo'
          - type: object
            description: The placement information for the order
        reduce_only:
          type: boolean
          description: Reduce Only for future positions
      description: The advanced order parameters to modify the execution behavior.
    OrderStatus:
      type: string
      description: The order status
      enum:
      - PENDING_NEW
      - ACCEPTED
      - REJECTED
      - PARTIALLY_FILLED
      - FILLED
      - PENDING_CANCEL
      - CANCELLED
      - PENDING_PAUSE
      - PAUSED
      - PENDING_UNPAUSE
      - EXPIRED
      - CANCEL_REJECTED
    OrderSummary:
      required:
      - created_at
      type: object
      properties:
        order_id:
          type: integer
          description: The Anboto assigned order identifier
          format: int64
          nullable: true
        client_order_id:
          type: string
          description: A custom string to identify the order
          nullable: true
          example: ABC-12345^12-10-23
        status:
          description: "The status of the order, e.g. PENDING_NEW"
          nullable: true
          allOf:
          - $ref: '#/components/schemas/OrderStatus'
        created_at:
          type: string
          description: The time in UTC when the order was created
          format: date-time
          nullable: true
          example: 2024-01-22T22:05:00Z
        message:
          type: string
          description: "Any additional information, usually if the order was rejected"
          nullable: true
        error_code:
          description: The error code if the order was rejected
          nullable: true
          allOf:
          - $ref: '#/components/schemas/ApiErrorCode'
          - type: string
            description: The error code if the order was rejected
            example: INVALID_ORDER
      description: Summarizes the state of the parent order
    OrderSummaryList:
      required:
      - orders
      type: object
      properties:
        orders:
          type: array
          description: The list of order summaries for separate orders.
          items:
            $ref: '#/components/schemas/OrderSummary'
    PlacementInfo:
      required:
      - placement_mode
      type: object
      properties:
        placement_mode:
          allOf:
          - $ref: '#/components/schemas/PlacementMode'
          - type: string
            description: How to place an order into the book
        placement:
          type: string
          description: "Where to place new orders in the book, e.g. 2 would slice\
            \ at the second best observed price."
          nullable: true
        cancel:
          type: string
          description: "At what level to cancel an existing order on the book, e.g.\
            \ 6 would cancel the order when it got to level 6 in the book"
          nullable: true
      description: How to place an order into the book
    PlacementMode:
      type: string
      description: The style used to place an order in the book. DEFAULT is the default
        and will be at the discretion of the trading strategy
      enum:
      - DEFAULT
      - TIGHT
      - CUSTOM
    Side:
      type: string
      description: The side of the book to trade.
      enum:
      - BUY
      - SELL
    TradingStyle:
      type: string
      description: "The trading style of the order, the default is HYBRID"
      enum:
      - PASSIVE
      - AGGRESSIVE
      - HYBRID
    TriggerCondition:
      type: string
      description: The trigger condition to start the order
      enum:
      - ABOVE
      - BELOW
    TriggerInfo:
      required:
      - trigger_condition
      - trigger_price
      type: object
      properties:
        trigger_price:
          type: string
          description: The price to monitor for the trigger
        trigger_condition:
          allOf:
          - $ref: '#/components/schemas/TriggerCondition'
          - type: string
            description: The condition to trigger the order
      description: Information related to how the order should be triggered.
    Urgency:
      type: string
      description: "The Urgency or Risk Aversion of the IS strategy, the default is\
        \ MEDIUM. The parameter is not case-sensitive. Each risk aversion levels correspond\
        \ to a lambda value, \"that is, how much we penalize variance relative to\
        \ expected cost\" Low : 0.2e-6 Medium: 1e-6 High: 5e-6 Based on the paper\
        \ from Almgren Chriss https://www.smallake.kr/wp-content/uploads/2016/03/optliq.pdf"
      enum:
      - LOW
      - MEDIUM
      - HIGH
    WouldInfo:
      required:
      - would_pct
      - would_style
      type: object
      properties:
        would_price:
          type: string
          description: The price to trigger Would mode
          nullable: true
        would_pct:
          type: string
          description: The percent of the order to trade when the Would price triggers
        would_style:
          allOf:
          - $ref: '#/components/schemas/TradingStyle'
          - type: string
            description: The trading style to use when the Would price triggers
        would_is_arrival:
          type: boolean
          description: Would price as arrival price
      description: Information to instruct how to execute a Would price trigger.
