openapi: 3.0.0
info:
  title: Algo724 Cadenza Lite API
  description: OpenAPI Specification for Algo724 Cadenza Lite API
  version: 1.15.0
  license:
    name: MIT
    url: https://github.com/openai/openai-openapi/blob/master/LICENSE
servers:
  - url: http://localhost:8088
    description: Local development server
  - url: https://cadenza-lite.algo724.com
    description: Production server
  - url: https://cadenza-lite.uat.algo724.com
    description: UAT server
tags:
  - name: Utility
    description: Utility
  - name: Account
    description: Exchange Account management
  - name: Market
    description: Market data
  - name: Trading
    description: Trading
  - name: IB
    description: IB Operation
  - name: Portfolio
    description: Portfolio
  - name: Webhook
    description: Webhook
  - name: Event
    description: Event
security:
  - BearerAuth: []
paths:
  /api/v2/health:
    get:
      operationId: healthCheck
      summary: Health check
      description: Health check
      tags:
        - Utility
      responses:
        '200':
          $ref: '#/components/responses/okTextResponse'
        '401':
          $ref: '#/components/responses/AuthenticationErrorResponse'
        '403':
          $ref: '#/components/responses/AuthorizationErrorResponse'
  /api/v2/client/getInfo:
    get:
      operationId: getClientInfo
      summary: Get user information
      description: Check available exchange types in user information
      tags:
        - Account
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  exchangeTypes:
                    type: array
                    items:
                      $ref: '#/components/schemas/exchangeType'
                    description: Available exchange types
                    example:
                      - BINANCE
                      - B2C2
                      - WINTERMUTE
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/exchange/addExchangeAccount:
    post:
      operationId: addExchangeAccount
      summary: Add exchange account
      description: Add exchange account
      tags:
        - Account
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/addExchangeRequest'
      responses:
        '200':
          $ref: '#/components/responses/okResponse'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/exchange/listExchangeAccounts:
    get:
      operationId: listExchangeAccounts
      summary: List exchange accounts
      description: List exchange accounts
      tags:
        - Account
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/exchangeAccount'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/exchange/updateExchangeAccount:
    post:
      operationId: updateExchangeAccount
      summary: Update exchange account
      description: >-
        Update exchange account, now only support Binance account API key and
        secret
      tags:
        - Account
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/updateExchangeRequest'
      responses:
        '200':
          $ref: '#/components/responses/okResponse'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/exchange/removeExchangeAccount:
    post:
      operationId: removeExchangeAccount
      summary: Remove exchange account
      description: >-
        Remove exchange account, now only support Binance account API key and
        secret
      tags:
        - Account
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                exchangeAccountId:
                  type: string
                  format: uuid
                  description: Exchange account ID
              required:
                - exchangeAccountId
      responses:
        '200':
          $ref: '#/components/responses/okResponse'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/market/listSymbolInfo:
    get:
      operationId: listSymbolInfo
      summary: List available exchange symbols
      description: List available exchange symbols
      tags:
        - Market
      parameters:
        - $ref: '#/components/parameters/exchangeType'
        - $ref: '#/components/parameters/symbol'
        - in: query
          name: detail
          schema:
            type: boolean
            example: false
          required: false
          description: Whether to return detailed information
      responses:
        '200':
          $ref: '#/components/responses/ListSymbolInfoResponse'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/market/ticker:
    get:
      operationId: ticker
      summary: Symbol price
      description: Symbol price
      tags:
        - Market
      parameters:
        - in: query
          name: exchangeType
          schema:
            $ref: '#/components/schemas/exchangeType'
            type: string
          description: Exchange type
        - in: query
          name: symbol
          schema:
            type: string
            example: BTC/USDT
          required: true
          description: Symbol
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ticker'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/market/orderbook:
    get:
      operationId: orderBook
      summary: Order book
      description: Get order book
      tags:
        - Market
      parameters:
        - in: query
          name: exchangeType
          description: Exchange type
          schema:
            $ref: '#/components/schemas/exchangeType'
            type: string
          required: true
        - in: query
          name: symbol
          schema:
            type: string
            example: BTC/USDT
          required: true
          description: Symbol
        - $ref: '#/components/parameters/limit'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/orderbook'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/market/kline:
    get:
      operationId: kline
      summary: Historical kline data
      description: Get historical kline data
      tags:
        - Market
      parameters:
        - in: query
          name: exchangeType
          schema:
            $ref: '#/components/schemas/exchangeType'
            type: string
          required: true
          description: Exchange type
        - in: query
          name: symbol
          schema:
            type: string
            example: BTC/USDT
          required: true
          description: Symbol
        - in: query
          name: interval
          schema:
            $ref: '#/components/schemas/interval'
            type: string
          required: true
          description: Kline interval
        - $ref: '#/components/parameters/startTime'
        - $ref: '#/components/parameters/endTime'
        - $ref: '#/components/parameters/limit'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/kline'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/exchange/setExchangePriority:
    post:
      operationId: setExchangePriority
      summary: Set the priority of exchanges
      description: Set the priority of exchanges
      tags:
        - Account
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - priority
              properties:
                priority:
                  type: array
                  items:
                    type: string
                  description: Priority list of exchanges in descending order
                  example:
                    - my_exchange_1
                    - my_exchange_2
                    - my_exchange_3
      responses:
        '200':
          $ref: '#/components/responses/okResponse'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/exchange/ib/account:
    post:
      summary: Create Account
      operationId: create_account_api_v1_account_post
      tags:
        - IB
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AccountForm'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v2/exchange/ib/accounts:
    get:
      summary: List Accounts
      operationId: list_accounts_api_v1_accounts_get
      tags:
        - IB
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                title: Response List Accounts Api V1 Accounts Get
                items:
                  $ref: '#/components/schemas/AccountResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v2/exchange/ib/account/{account_username}:
    get:
      summary: Get Account
      operationId: get_account_api_v1_account__account_username__get
      tags:
        - IB
      parameters:
        - name: account_username
          in: path
          required: true
          schema:
            type: string
            title: Account Username
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v2/exchange/ib/bridge/{account_username}/connect:
    post:
      summary: Connect
      operationId: connect_api_v1_bridge__account_username__connect_post
      tags:
        - IB
      parameters:
        - name: account_username
          in: path
          required: true
          schema:
            type: string
            title: Account Username
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v2/exchange/ib/bridge/{account_username}/disconnect:
    post:
      summary: Disconnect
      operationId: disconnect_api_v1_bridge__account_username__disconnect_post
      tags:
        - IB
      parameters:
        - name: account_username
          in: path
          required: true
          schema:
            type: string
            title: Account Username
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v2/trading/placeOrder:
    post:
      operationId: placeOrder
      summary: Place order
      description: Place order
      tags:
        - Trading
      parameters:
        - $ref: '#/components/parameters/idempotencyKeyHeader'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/placeOrderRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/order'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/trading/cancelOrder:
    post:
      operationId: cancelOrder
      summary: Cancel order
      description: Cancel order. If the order is already filled, it will return an error.
      tags:
        - Trading
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/cancelOrderRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/order'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/trading/listOrders:
    get:
      operationId: listOrders
      summary: List Exchange Orders
      description: List orders
      tags:
        - Trading
      parameters:
        - $ref: '#/components/parameters/orderId'
        - $ref: '#/components/parameters/orderStatus'
        - $ref: '#/components/parameters/exchangeAccountId'
        - $ref: '#/components/parameters/symbol'
        - $ref: '#/components/parameters/startTime'
        - $ref: '#/components/parameters/endTime'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/tenantId'
        - $ref: '#/components/parameters/ascending'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/order'
                  limit:
                    type: integer
                    description: Limit of the returned results
                  offset:
                    type: integer
                    description: Offset of the returned results
                  total:
                    type: integer
                    description: Total number of orders
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/trading/getQuoteExecutionReport:
    get:
      operationId: getQuoteExecutionReport
      summary: Get Quote Execution Report
      description: Quote will give the best quote from all available exchange accounts
      tags:
        - Trading
      parameters:
        - $ref: '#/components/parameters/quoteRequestId'
      responses:
        '200':
          $ref: '#/components/responses/listExecutionReportsResponse'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/trading/listExecutionReports:
    get:
      operationId: listExecutionReports
      summary: List Execution Reports
      description: Quote will give the best quote from all available exchange accounts
      tags:
        - Trading
      parameters:
        - $ref: '#/components/parameters/quoteRequestId'
        - $ref: '#/components/parameters/startTime'
        - $ref: '#/components/parameters/endTime'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/ascending'
      responses:
        '200':
          $ref: '#/components/responses/listExecutionReportsResponse'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/trading/fetchQuotes:
    post:
      operationId: fetchQuotes
      summary: RFQ, Request for Quote, Indicated Quote, National Best Bid Offer, NBBO
      description: Quote will give the best quote from all available exchange accounts
      tags:
        - Trading
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/quoteRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/quote'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/portfolio/summary:
    get:
      operationId: listPortfolioSummaries
      summary: List Portfolio Summary
      description: List Portfolio Summary
      tags:
        - Portfolio
      parameters:
        - $ref: '#/components/parameters/exchangeAccountId'
        - $ref: '#/components/parameters/hideEmptyValue'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/exchangeAccountPortfolio'
                description: List of account portfolio summaries
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/portfolio/listCredit:
    get:
      operationId: listCredit
      summary: List credit
      description: List credit
      tags:
        - Portfolio
      parameters:
        - $ref: '#/components/parameters/exchangeAccountId'
        - $ref: '#/components/parameters/hideEmptyValue'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/exchangeAccountCredit'
                description: List of account credit info
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/portfolio/listBalances:
    get:
      operationId: listBalances
      summary: List balances
      description: List balances
      tags:
        - Portfolio
      parameters:
        - $ref: '#/components/parameters/exchangeAccountId'
        - $ref: '#/components/parameters/hideEmptyValue'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/exchangeBalance'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/portfolio/listPositions:
    get:
      operationId: listPositions
      summary: List positions
      description: List positions
      tags:
        - Portfolio
      parameters:
        - $ref: '#/components/parameters/exchangeAccountId'
        - $ref: '#/components/parameters/hideEmptyValue'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/exchangePosition'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/webhook/pubsub:
    post:
      operationId: receiveEventFromPubSub
      summary: PubSub event handler
      description: PubSub Event Handler
      tags:
        - Webhook
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/pubSubMessage'
      responses:
        '200':
          $ref: '#/components/responses/okResponse'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/webhook/cloudScheduler/updatePortfolioRoutine:
    post:
      operationId: updatePortfolioRoutine
      summary: Cloud scheduler updatePortfolioRoutine webhook handler
      description: Cloud scheduler update portfolio routine task
      tags:
        - Webhook
      responses:
        '200':
          $ref: '#/components/responses/okResponse'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/webhook/cloudScheduler/updateOrdersRoutine:
    post:
      operationId: updateOrdersRoutine
      summary: Cloud scheduler updateOrdersRoutine webhook handler
      description: Cloud scheduler update Orders Routine task
      tags:
        - Webhook
      responses:
        '200':
          $ref: '#/components/responses/okResponse'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/webhook/pubsub/event:
    post:
      operationId: pubsubEvent
      summary: PubSub event handler placeholder
      description: PubSub event handler placeholder
      tags:
        - Event
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Event'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Event'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/webhook/pubsub/task/quote:
    post:
      operationId: pubsubTaskQuote
      summary: PubSub event handler placeholder for quote request acknowledgment event
      description: PubSub event handler placeholder for quote request acknowledgment event
      tags:
        - Event
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaskQuote'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskQuote'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/webhook/pubsub/dropCopy/quoteRequestAck:
    post:
      operationId: pubsubDropCopyQuoteRequestAck
      summary: PubSub event handler placeholder for quote request acknowledgment event
      description: PubSub event handler placeholder for quote request acknowledgment event
      tags:
        - Event
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DropCopyQuoteRequestAck'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DropCopyQuoteRequestAck'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/webhook/pubsub/dropCopy/placeOrderRequestAck:
    post:
      operationId: pubsubDropCopyPlaceOrderRequestAck
      summary: >-
        PubSub event handler placeholder for place order request acknowledgment
        event
      description: >-
        PubSub event handler placeholder for place order request acknowledgment
        event
      tags:
        - Event
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DropCopyPlaceOrderRequestAck'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DropCopyPlaceOrderRequestAck'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/webhook/pubsub/dropCopy/cancelOrderRequestAck:
    post:
      operationId: pubsubDropCopyCancelOrderRequestAck
      summary: >-
        PubSub event handler placeholder for cancel order request acknowledgment
        event
      description: >-
        PubSub event handler placeholder for cancel order request acknowledgment
        event
      tags:
        - Event
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DropCopyCancelOrderRequestAck'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DropCopyCancelOrderRequestAck'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/webhook/pubsub/dropCopy/quote:
    post:
      operationId: pubsubDropCopyQuote
      summary: PubSub event handler placeholder for quote event
      description: PubSub event handler placeholder for quote event
      tags:
        - Event
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DropCopyQuote'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DropCopyQuote'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/webhook/pubsub/dropCopy/order:
    post:
      operationId: pubsubDropCopyOrder
      summary: PubSub event handler placeholder for order event
      description: PubSub event handler placeholder for order event
      tags:
        - Event
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DropCopyOrder'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DropCopyOrder'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/webhook/pubsub/dropCopy/executionReport:
    post:
      operationId: pubsubDropCopyExecutionReport
      summary: PubSub event handler for execution report drop copy event
      description: PubSub event handler for execution report drop copy event
      tags:
        - Event
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DropCopyExecutionReport'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DropCopyExecutionReport'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/webhook/pubsub/dropCopy/portfolio:
    post:
      operationId: pubsubDropCopyPortfolio
      summary: PubSub event handler placeholder for portfolio event
      description: PubSub event handler placeholder for portfolio event
      tags:
        - Event
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DropCopyPortfolio'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DropCopyPortfolio'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/webhook/pubsub/marketData/orderBook:
    post:
      operationId: pubsubMarketDataOrderBook
      summary: PubSub event handler placeholder for order book event
      description: PubSub event handler placeholder for order book event
      tags:
        - Event
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MarketDataOrderBook'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MarketDataOrderBook'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
  /api/v2/webhook/pubsub/marketData/kline:
    post:
      operationId: pubsubMarketDataKline
      summary: PubSub event handler placeholder for kline event
      description: PubSub event handler placeholder for kline event
      tags:
        - Event
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MarketDataKline'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MarketDataKline'
        '400':
          $ref: '#/components/responses/errorResponse'
        '500':
          $ref: '#/components/responses/errorResponse'
components:
  parameters:
    idempotencyKeyHeader:
      in: header
      name: Idempotency-Key
      description: >-
        Idempotency key is used to ensure that the same request is not processed
        more than once.

        If the same request is received again, the server will return the same
        response as the first time.
      schema:
        type: string
        example: my_idempotency_key
    arraySymbols:
      in: query
      name: symbol
      description: List of symbols
      schema:
        type: array
        items:
          type: string
        example:
          - BTC/USDT
          - ETH/USDT
    exchangeType:
      in: query
      name: exchangeType
      description: Exchange type
      schema:
        $ref: '#/components/schemas/exchangeType'
        type: string
    interval:
      in: query
      name: interval
      description: Kline interval
      schema:
        $ref: '#/components/schemas/interval'
        type: string
    orderId:
      in: query
      name: orderId
      schema:
        type: string
      description: Order ID
    quoteRequestId:
      in: query
      name: quoteRequestId
      schema:
        type: string
      description: Quote Request ID
    orderStatus:
      in: query
      name: orderStatus
      description: Order status
      schema:
        $ref: '#/components/schemas/orderStatus'
        type: string
    exchangeAccountId:
      in: query
      name: exchangeAccountId
      schema:
        type: string
      description: Exchange account ID
    symbol:
      in: query
      name: symbol
      schema:
        type: string
      description: Symbol
    startTime:
      in: query
      name: startTime
      schema:
        type: integer
        $ref: '#/components/schemas/millisecond'
        example: 1622505600000
      description: Start time (in unix milliseconds)
    endTime:
      in: query
      name: endTime
      schema:
        $ref: '#/components/schemas/millisecond'
        type: integer
      description: End time (in unix milliseconds)
    limit:
      in: query
      name: limit
      schema:
        type: integer
        example: 100
      description: Limit the number of returned results.
    offset:
      in: query
      name: offset
      schema:
        type: integer
        example: 0
      description: 'Offset of the returned results. Default: 0'
    tenantId:
      in: query
      name: tenantId
      schema:
        type: string
      description: Tenant ID
    ascending:
      in: query
      name: ascending
      schema:
        type: boolean
      description: Return records in ascending order
    hideEmptyValue:
      in: query
      name: hideEmptyValue
      schema:
        type: boolean
      description: Hide small account
      example: false
  responses:
    okTextResponse:
      description: Simple text Successful response
      content:
        text/plain:
          schema:
            type: string
            default: ok
    okResponse:
      description: Simple JSON Successful response
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                default: ok
                type: string
    eventResponse:
      description: Event in JSON response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MetaEvent'
    errorResponse:
      description: Error response
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: integer
                description: Error code
              error:
                type: string
                description: Error message
            required:
              - code
              - error
    AuthenticationErrorResponse:
      description: Authentication error response
      content:
        text/html:
          schema:
            type: string
    AuthorizationErrorResponse:
      description: Authorization error response
      content:
        text/html:
          schema:
            type: string
    ListSymbolInfoResponse:
      description: Successful Response
      content:
        application/json:
          schema:
            type: array
            items:
              $ref: '#/components/schemas/instrument'
    listExecutionReportsResponse:
      description: Successful Response
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                type: array
                items:
                  $ref: '#/components/schemas/executionReport'
              limit:
                type: integer
                description: Limit of the returned results
              offset:
                type: integer
                description: Offset of the returned results
              total:
                type: integer
                description: Total number of orders
            required:
              - data
              - limit
              - offset
              - total
  schemas:
    addExchangeRequest:
      type: object
      properties:
        exchangeType:
          $ref: '#/components/schemas/exchangeType'
        apiKey:
          type: string
          example: my_api_key
          description: API key
        apiSecret:
          type: string
          example: my_api_secret
          description: API secret
        exchangeAccountName:
          type: string
          example: my_exchange
          description: >-
            Exchange account name, Available characters: a-z, A-Z, 0-9, _,
            (space)
        environment:
          type: integer
          enum:
            - 0
            - 1
          example: 0
          description: Environment(0 - real, 1 - sandbox)
      required:
        - exchangeType
        - apiKey
        - apiSecret
        - exchangeAccountName
        - environment
    updateExchangeRequest:
      type: object
      properties:
        exchangeAccountId:
          type: string
          format: uuid
          description: Exchange account ID
        exchangeAccountName:
          type: string
          example: my_exchange
          description: >-
            Exchange account name, Available characters: a-z, A-Z, 0-9, _,
            (space)
        apiKey:
          type: string
          example: my_api_key
          description: API key
        apiSecret:
          type: string
          example: my_api_secret
          description: API secret
      required:
        - exchangeAccountId
    AccountForm:
      type: object
      title: AccountForm
      properties:
        username:
          type: string
          title: Username
        consumer_key:
          type: string
          nullable: true
          title: Consumer Key
        dhparam:
          type: string
          nullable: true
          title: Dhparam
        encryption_private_key:
          type: string
          nullable: true
          title: Encryption Private Key
        signature_private_key:
          type: string
          nullable: true
          title: Signature Private Key
        access_token:
          type: string
          nullable: true
          title: Access Token
        access_token_secret:
          type: string
          nullable: true
          title: Access Token Secret
        live_session_token:
          type: string
          nullable: true
          title: Live Session Token
      required:
        - username
    AccountResponse:
      type: object
      title: AccountResponse
      properties:
        id:
          type: string
          format: uuid
          title: Id
        username:
          type: string
          title: Username
        account_id:
          type: string
          nullable: true
          title: Account Id
        master_id:
          type: string
          format: uuid
          nullable: true
          title: Master Id
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        last_auth_method:
          type: string
          nullable: true
          title: Last Auth Method
        session_status:
          type: string
          nullable: true
          title: Session Status
        conn_status:
          type: string
          nullable: true
          title: Conn Status
      required:
        - id
        - username
        - created_at
        - updated_at
    HTTPValidationError:
      type: object
      title: HTTPValidationError
      properties:
        detail:
          type: array
          title: Detail
          items:
            $ref: '#/components/schemas/ValidationError'
    ValidationError:
      type: object
      title: ValidationError
      properties:
        loc:
          type: array
          title: Location
          items:
            anyOf:
              - type: string
              - type: integer
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      required:
        - loc
        - msg
        - type
    placeOrderRequest:
      type: object
      properties:
        quoteRequestId:
          description: Quote request ID
          $ref: '#/components/schemas/uuidString'
        exchangeAccountId:
          description: Exchange account ID
          $ref: '#/components/schemas/uuidString'
        leverage:
          description: Levarage
          type: integer
        orderSide:
          allOf:
            - $ref: '#/components/schemas/orderSide'
          description: Order side
        orderType:
          allOf:
            - $ref: '#/components/schemas/orderType'
          description: Order type
        positionId:
          type: string
          description: Position ID for closing position in margin trading
          format: uuid
        price:
          type: number
          description: Price
        priceSlippageTolerance:
          type: number
          description: 'Price slippage tolerance, range: [0, 0.1] with 2 decimal places'
        quantity:
          type: number
          description: >-
            Quantity. One of quantity or quoteQuantity must be provided. If both
            is provided, only quantity will be used.
        quoteQuantity:
          type: number
          description: Quote Quantity
        symbol:
          type: string
          description: Symbol
          example: BTC/USDT
        timeInForce:
          allOf:
            - $ref: '#/components/schemas/timeInForce'
          description: Time in force
        routePolicy:
          $ref: '#/components/schemas/routePolicy'
        priority:
          type: array
          items:
            type: string
          description: Priority list of exchange account ID in descending order
          example:
            - exchange_account_id_1
            - exchange_account_id_2
            - exchange_account_id_3
        quoteId:
          type: string
          description: >-
            Quote ID used by exchange for RFQ, e.g. WINTERMUTE need this field
            to execute QUOTED order
        tenantId:
          type: string
          description: Tenant ID
          example: tenantId
      required:
        - routePolicy
    exchangeType:
      type: string
      enum:
        - BINANCE
        - BINANCE_MARGIN
        - B2C2
        - WINTERMUTE
        - BLOCKFILLS
        - STONEX
        - CUMBERLAND
      description: Exchange type
    uuidString:
      type: string
      format: uuid
      description: UUID string
    cancelOrderRequest:
      type: object
      properties:
        orderId:
          type: string
          description: Order ID
      required:
        - orderId
    millisecond:
      type: integer
      example: 1632933600000
      description: Unix timestamp in milliseconds
    instrument:
      description: Trading Instrument
      type: object
      properties:
        baseSymbol:
          type: string
          description: Base currency
          example: BTC
        description:
          type: string
          description: Symbol description
        exchangeType:
          $ref: '#/components/schemas/exchangeType'
        marginRate:
          type: number
          description: Margin rate
        maxQuantity:
          type: number
          description: Max quantity
        minQuantity:
          type: number
          description: Min quantity
        quantityStep:
          type: number
          description: Quantity step, round lot
        minTick:
          type: number
          description: Min tick, Price Tick
        orderTypes:
          description: Supported order types
          type: array
          items:
            $ref: '#/components/schemas/orderType'
        pipSize:
          type: number
          description: Pip size
        pipValue:
          type: number
          description: Pip value
        pricePrecision:
          type: integer
          description: Price precision
        quantityPrecision:
          type: integer
          description: Quantity precision
        quoteSymbol:
          type: string
          description: Quoted currency
          example: USDT
        securityType:
          $ref: '#/components/schemas/securityType'
        symbol:
          type: string
          description: Symbol name
          example: BTC/USDT
        timeInForce:
          type: array
          description: Supported time in force
          items:
            $ref: '#/components/schemas/timeInForce'
      required:
        - exchangeType
        - symbol
    interval:
      type: string
      enum:
        - 1s
        - 1m
        - 5m
        - 15m
        - 30m
        - 1h
        - 2h
        - 1d
        - 1w
    ticker:
      properties:
        askPrice:
          type: number
          description: Ask price
        askQuantity:
          type: number
          description: Ask quantity
        bidPrice:
          type: number
          description: Bid price
        bidQuantity:
          type: number
          description: Bid quantity
        exchangeType:
          $ref: '#/components/schemas/exchangeType'
        lastPrice:
          type: number
          description: Last price
        lastQuantity:
          type: number
          description: Last quantity
        symbol:
          type: string
          description: Symbol
          example: BTC/USDT
        timestamp:
          $ref: '#/components/schemas/millisecond'
      required:
        - exchangeType
        - symbol
        - timestamp
      type: object
    orderbookEntry:
      type: array
      items:
        type: number
      minItems: 2
      maxItems: 2
    orderbook:
      type: object
      properties:
        asks:
          type: array
          items:
            $ref: '#/components/schemas/orderbookEntry'
        bids:
          type: array
          items:
            $ref: '#/components/schemas/orderbookEntry'
        exchangeType:
          type: string
        exchangeAccountId:
          $ref: '#/components/schemas/uuidString'
        symbol:
          type: string
        level:
          type: integer
          description: Order book level
    ohlcv:
      type: object
      properties:
        c:
          type: number
          description: Close price
        h:
          type: number
          description: High price
        l:
          type: number
          description: Low price
        o:
          type: number
          description: Open price
        t:
          type: integer
          description: Start time (in unix milliseconds)
        v:
          type: number
          description: Volume
    candles:
      type: array
      items:
        $ref: '#/components/schemas/ohlcv'
    kline:
      type: object
      properties:
        exchangeAccountId:
          $ref: '#/components/schemas/uuidString'
          description: The unique identifier for the account.
        exchangeType:
          $ref: '#/components/schemas/exchangeType'
        symbol:
          type: string
        interval:
          $ref: '#/components/schemas/interval'
        candles:
          type: array
          items:
            $ref: '#/components/schemas/balanceEntry'
    orderSide:
      type: string
      enum:
        - BUY
        - SELL
      description: Order side
    orderType:
      type: string
      enum:
        - MARKET
        - LIMIT
        - STOP_LOSS
        - STOP_LOSS_LIMIT
        - TAKE_PROFIT
        - TAKE_PROFIT_LIMIT
        - QUOTED
      description: Order type
    orderStatus:
      type: string
      enum:
        - SUBMITTED
        - ACCEPTED
        - OPEN
        - PARTIALLY_FILLED
        - FILLED
        - CANCELED
        - PENDING_CANCEL
        - REJECTED
        - EXPIRED
        - REVOKED
      description: Order status
    timeInForce:
      type: string
      enum:
        - DAY
        - GTC
        - GTX
        - GTD
        - OPG
        - CLS
        - IOC
        - FOK
        - GFA
        - GFS
        - GTM
        - MOO
        - MOC
        - EXT
      description: Time in force
    securityType:
      type: string
      description: Security type
      enum:
        - SPOT
        - CASH
        - STOCK
        - CRYPTO
        - DERIVATIVE
        - OPTION
        - FUTURE
        - FOREX
        - COMMODITY
    routePolicy:
      type: string
      enum:
        - PRIORITY
        - QUOTE
      description: >-
        Route policy. For PRIORITY, the order request will be routed to the
        exchange account with the highest priority. For QUOTE, the system will
        execute the execution plan based on the quote. Order request with route
        policy QUOTE will only accept two parameters, quoteRequestId and
        priceSlippageTolerance
    feeEntry:
      type: object
      properties:
        asset:
          type: string
          description: Asset
        quantity:
          type: number
          description: Quantity
    order:
      type: object
      properties:
        orderId:
          type: string
          format: uuid
        exchangeAccountId:
          type: string
          format: uuid
          description: Exchange account ID
        exchangeType:
          $ref: '#/components/schemas/exchangeType'
        userId:
          type: string
          description: User ID
          format: uuid
        tenantId:
          type: string
          description: Tenant ID
          example: tenantId
        positionId:
          type: string
          description: Position ID
          format: uuid
        quoteId:
          type: string
          description: Quote ID
        symbol:
          type: string
          description: Symbol
          example: BTC/USDT
        baseCurrency:
          type: string
          description: Base currency
          example: BTC
        quoteCurrency:
          type: string
          description: Quote currency
          example: USDT
        orderSide:
          $ref: '#/components/schemas/orderSide'
        orderType:
          $ref: '#/components/schemas/orderType'
        timeInForce:
          $ref: '#/components/schemas/timeInForce'
        status:
          $ref: '#/components/schemas/orderStatus'
        quantity:
          type: number
          description: Quantity
        quoteQuantity:
          type: number
          description: Quote Quantity
        price:
          type: number
          description: Deprecated, should use limitPrice, stopPrice or executedPrice
        limitPrice:
          type: number
          description: Limit price
        stopPrice:
          type: number
          description: Stop price
        executedPrice:
          type: number
          description: Executed price, Null if the order is not filled
          nullable: true
        cost:
          type: number
          description: The total cost of this order.
        filled:
          type: number
          description: The quantity of this order that has been filled.
        fee:
          type: number
          description: Fee
          example: 0
        feeCurrency:
          type: string
          description: Fee currency
          example: USDT
        createdAt:
          type: integer
          description: Created timestamp
          example: 1703052635110
        updatedAt:
          type: integer
          description: Last updated timestamp
          example: 1703052635111
      required:
        - orderSide
        - cost
        - filled
        - status
        - updatedAt
        - createdAt
    quoteRequest:
      type: object
      properties:
        baseCurrency:
          type: string
          description: Base currency is the currency you want to buy or sell
        quoteCurrency:
          type: string
          description: >-
            Quote currency is the currency you want to pay or receive, and the
            price of the base currency is quoted in the quote currency
        orderSide:
          type: string
          description: Order side, BUY or SELL
        quantity:
          type: number
          description: Amount of the base currency
        quoteQuantity:
          type: number
          description: Amount of the quote currency
        exchangeAccountId:
          description: The identifier for the exchange account
          $ref: '#/components/schemas/uuidString'
        exchangeAccountIds:
          type: array
          items:
            $ref: '#/components/schemas/uuidString'
            description: The identifier for the exchange account
        crossCurrency:
          type: string
          description: The intermediary currency used for cross-currency quotes
          example: USD
        disableCrossAccounts:
          type: boolean
          description: >-
            When true, prevents quotes from being sourced across multiple
            accounts
          example: false
        clientOrderId:
          $ref: '#/components/schemas/clientOrderId'
      required:
        - baseCurrency
        - quoteCurrency
        - orderSide
    quote:
      type: object
      properties:
        quoteRequestId:
          description: Quote request ID, internal reference id for client request
          $ref: '#/components/schemas/uuidString'
        quoteId:
          description: Quote ID, internal reference id for quote
          $ref: '#/components/schemas/uuidString'
        baseCurrency:
          type: string
          description: Base currency
          example: BTC
        quoteCurrency:
          type: string
          description: Quote currency
          example: USDT
        quantity:
          type: number
          description: Base currency quantity
          example: 1
        quoteQuantity:
          type: number
          description: Quote currency quantity
          example: 42859.99
        quotePrice:
          type: number
          description: Exchange rate of the base currency to the quote currency
          example: 42859.99
        orderSide:
          $ref: '#/components/schemas/orderSide'
        clientOrderId:
          $ref: '#/components/schemas/clientOrderId'
        askPrice:
          type: number
          description: Ask price
          example: 42859.99
        askQuantity:
          type: number
          description: Ask quantity
          example: 1
        bidPrice:
          type: number
          description: Bid price
          example: 42859.71
        bidQuantity:
          type: number
          description: Bid quantity
          example: 1
        timestamp:
          description: deprecated, alias of createdAt, Create time of the quote
          $ref: '#/components/schemas/millisecond'
        createdAt:
          description: Create time of the quote
          $ref: '#/components/schemas/millisecond'
        validUntil:
          description: deprecated, alias of expiredAtExpiration time of the quote
          $ref: '#/components/schemas/millisecond'
        expireAt:
          description: Expiration time of the quote. alias of validUtil
          $ref: '#/components/schemas/millisecond'
        exchangeAccountId:
          $ref: '#/components/schemas/uuidString'
          description: Exchange Account ID
        exchangeType:
          $ref: '#/components/schemas/exchangeType'
      required:
        - quoteRequestId
        - baseCurrency
        - quoteCurrency
        - timestamp
        - validUntil
    executionReport:
      type: object
      properties:
        id:
          description: Execution Report ID
          $ref: '#/components/schemas/uuidString'
        baseCurrency:
          type: string
          description: Base currency
          example: BTC
        quoteCurrency:
          type: string
          description: Quote currency
          example: USDT
        routePolicy:
          $ref: '#/components/schemas/routePolicy'
        order:
          $ref: '#/components/schemas/order'
        filled:
          type: number
          description: Filled quantity, the quantity of the base currency executed
          example: 1
        cost:
          type: number
          description: Cost, the total cost of the quote
          example: 42859.99
        fees:
          description: Fees
          type: array
          items:
            $ref: '#/components/schemas/feeEntry'
          nullable: true
        status:
          description: >-
            Status of the quote execution, should only have SUBMITTED, ACCEPTED,
            PARTIALLY_FILLED, FILLED, EXPIRED. the final status of the quote
            execution should be either FILLED or EXPIRED
          $ref: '#/components/schemas/orderStatus'
        createdAt:
          description: Create time of the quote
          $ref: '#/components/schemas/millisecond'
        updatedAt:
          description: Last updated time of the quote execution
          $ref: '#/components/schemas/millisecond'
        executions:
          type: array
          description: >-
            List of executions to fulfill the order, the order status should
            only have FILLED, REJECTED, or EXPIRED
          items:
            $ref: '#/components/schemas/order'
          nullable: true
      required:
        - id
        - baseCurrency
        - quoteCurrency
        - routePolicy
        - order
        - filled
        - cost
        - fees
        - status
        - createdAt
        - updatedAt
        - executions
    quoteExecutionReport:
      allOf:
        - $ref: '#/components/schemas/executionReport'
        - type: object
          properties:
            quoteRequestId:
              description: Quote request ID
              $ref: '#/components/schemas/uuidString'
            validUntil:
              description: Expiration time of the quote
              $ref: '#/components/schemas/millisecond'
          required:
            - quoteRequestId
            - validUntil
    exchangeAccountStatus:
      type: string
      enum:
        - ACTIVE
        - API_ERROR
        - INVALID_API
        - API_ISSUE
        - NOT_TRUSTED
        - DELETED
      description: Status of the exchange account
    balanceEntry:
      type: object
      properties:
        asset:
          type: string
          description: Asset
          example: BTC
        free:
          type: number
          description: Free balance
          example: 1
        locked:
          type: number
          description: Locked balance
          example: 0
        borrowed:
          type: number
          description: Borrowed balance from exchange
          example: 3
        net:
          type: number
          description: Net Balance, net = total - borrowed
          example: -2
        total:
          type: number
          description: Total available balance
          example: 1
      required:
        - asset
        - free
        - locked
        - borrowed
        - net
        - total
    exchangeBalance:
      type: object
      properties:
        exchangeAccountId:
          type: string
          description: Exchange account ID
          format: uuid
        balances:
          type: array
          description: List of balances
          items:
            $ref: '#/components/schemas/balanceEntry'
      required:
        - exchangeAccountId
        - balances
    positionEntry:
      type: object
      properties:
        amount:
          type: number
          description: Amount
        cost:
          type: number
          description: Cost
        entryPrice:
          type: number
          description: Entry price
        positionSide:
          type: string
          description: Position side
          enum:
            - LONG
            - SHORT
        status:
          type: string
          description: Status
          enum:
            - OPEN
        symbol:
          type: string
          description: Symbol
          example: BTC/USDT
      required:
        - amount
        - positionSide
        - status
        - symbol
    exchangePosition:
      type: object
      properties:
        exchangeAccountId:
          type: string
          description: Exchange account ID
          format: uuid
        positions:
          type: array
          description: List of positions
          items:
            $ref: '#/components/schemas/positionEntry'
            description: List of positions
    exchangeAccountCredit:
      type: object
      properties:
        exchangeAccountId:
          type: string
          example: 018e41a1-cebc-7b49-a729-ae2c1c41e297
        exchangeType:
          $ref: '#/components/schemas/exchangeType'
        accountType:
          $ref: '#/components/schemas/accountType'
        currency:
          type: string
          example: USDT
        leverage:
          type: integer
          description: The maximum leverage the account have
          example: 1
        credit:
          type: number
          description: >-
            The amount of credit available to the account from the broker or
            exchange
          example: 10000
        margin:
          type: number
          description: >-
            The amount of collateral that the investor has deposited in the
            account to cover potential losses
          example: 5000
        marginLoan:
          type: number
          description: The amount of money borrowed from the broker to purchase securities
          example: 3000
        marginRequirement:
          type: number
          description: The amount of collateral required to maintain the current positions
          example: 1500
        marginUsage:
          type: number
          description: The rate to which the available margin is being utilized
          example: 0.5
        marginLevel:
          type: number
          description: The rate between equity and margin requirement
          example: 0.89
        riskExposure:
          type: number
          description: >-
            The total value of positions held in the account, indicating the
            level of market exposure
          example: 5677517.76
        maxRiskExposure:
          type: number
          description: >-
            The maximum value of risk exposure that the account can handle, set
            to manage risk and avoid excessive exposure to market volatility
          example: 5000000
        riskExposureRate:
          type: number
          description: The rate between risk exposure and max risk exposure
          example: 0.89
      description: Exchange Account Credit Info
    exchangeAccountPortfolio:
      type: object
      properties:
        exchangeAccountId:
          $ref: '#/components/schemas/uuidString'
          description: The unique identifier for the account.
          nullable: true
        exchangeType:
          $ref: '#/components/schemas/exchangeType'
          nullable: true
        balances:
          type: array
          items:
            $ref: '#/components/schemas/balanceEntry'
          nullable: true
        positions:
          type: array
          items:
            $ref: '#/components/schemas/positionEntry'
          nullable: true
        credit:
          $ref: '#/components/schemas/exchangeAccountCredit'
          nullable: true
        updatedAt:
          $ref: '#/components/schemas/millisecond'
          description: The timestamp when the portfolio information was updated.
          nullable: true
      required:
        - exchangeAccountId
        - exchangeType
        - balances
        - positions
        - credit
        - updatedAt
    accountType:
      type: string
      enum:
        - SPOT
        - MARGIN
      example: SPOT
      description: Type of account (SPOT, MARGIN)
    environment:
      type: string
      enum:
        - REAL
        - SANDBOX
        - PAPER
      example: REAL
      description: Environment of the exchange account
    exchangeAccount:
      properties:
        accountType:
          $ref: '#/components/schemas/accountType'
        exchangeType:
          $ref: '#/components/schemas/exchangeType'
        exchangeAccountId:
          type: string
          format: uuid
          description: Exchange account ID
        name:
          type: string
          description: Name of the exchange account
        environment:
          $ref: '#/components/schemas/environment'
        status:
          $ref: '#/components/schemas/exchangeAccountStatus'
      required:
        - exchangeAccountId
        - exchangeType
        - environment
        - status
        - accountType
        - name
    pubSubMessage:
      type: object
      properties:
        message:
          type: object
          properties:
            data:
              type: string
              format: byte
              description: The base64-encoded data.
            id:
              type: string
              description: The unique identifier for the message.
          required:
            - id
        subscription:
          type: string
          description: The subscription name.
      required:
        - message
        - subscription
    EventType:
      type: string
      enum:
        - cadenza.task.quote
        - cadenza.dropCopy.quoteRequestAck
        - cadenza.dropCopy.placeOrderRequestAck
        - cadenza.dropCopy.cancelOrderRequestAck
        - cadenza.dropCopy.quote
        - cadenza.dropCopy.order
        - cadenza.dropCopy.executionReport
        - cadenza.dropCopy.portfolio
        - cadenza.marketData.orderBook
        - cadenza.marketData.kline
      description: Event Type
    MetaEvent:
      type: object
      properties:
        eventId:
          type: string
          description: A unique identifier for the event.
        eventType:
          $ref: '#/components/schemas/EventType'
        source:
          type: string
          description: The source system or module that generated the event.
        timestamp:
          $ref: '#/components/schemas/millisecond'
          description: Unix timestamp in milliseconds when the event was generated.
      required:
        - eventId
        - eventType
        - timestamp
    Event:
      allOf:
        - $ref: '#/components/schemas/MetaEvent'
        - type: object
          properties:
            payload:
              type: object
              description: >-
                The actual data of the event, which varies based on the event
                type.
    TaskQuote:
      allOf:
        - $ref: '#/components/schemas/MetaEvent'
        - type: object
          properties:
            payload:
              $ref: '#/components/schemas/quoteRequest'
    DropCopyQuoteRequestAck:
      allOf:
        - $ref: '#/components/schemas/MetaEvent'
        - type: object
          properties:
            payload:
              $ref: '#/components/schemas/quoteRequest'
    DropCopyPlaceOrderRequestAck:
      allOf:
        - $ref: '#/components/schemas/MetaEvent'
        - type: object
          properties:
            payload:
              $ref: '#/components/schemas/placeOrderRequest'
    DropCopyCancelOrderRequestAck:
      allOf:
        - $ref: '#/components/schemas/MetaEvent'
        - type: object
          properties:
            payload:
              $ref: '#/components/schemas/cancelOrderRequest'
    DropCopyQuote:
      allOf:
        - $ref: '#/components/schemas/MetaEvent'
        - type: object
          properties:
            payload:
              $ref: '#/components/schemas/quote'
    DropCopyOrder:
      allOf:
        - $ref: '#/components/schemas/MetaEvent'
        - type: object
          properties:
            payload:
              $ref: '#/components/schemas/order'
    DropCopyExecutionReport:
      allOf:
        - $ref: '#/components/schemas/MetaEvent'
        - type: object
          properties:
            payload:
              $ref: '#/components/schemas/executionReport'
    DropCopyPortfolio:
      allOf:
        - $ref: '#/components/schemas/MetaEvent'
        - type: object
          properties:
            payload:
              $ref: '#/components/schemas/exchangeAccountPortfolio'
    MarketDataOrderBook:
      allOf:
        - $ref: '#/components/schemas/MetaEvent'
        - type: object
          properties:
            payload:
              $ref: '#/components/schemas/orderbook'
    MarketDataKline:
      allOf:
        - $ref: '#/components/schemas/MetaEvent'
        - type: object
          properties:
            payload:
              $ref: '#/components/schemas/kline'
    clientOrderId:
      type: string
      description: Client-provided order identifier that must be unique
      example: my_order_123
      pattern: ^[a-zA-Z0-9_-]{1,64}$
      minLength: 1
      maxLength: 64
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
