openapi: 3.0.3
info:
  title: Algo724 Cadenza Fermata API
  description: >-
    OpenAPI Specification for Algo724 Cadenza Fermata API


    ## API Resources

    - <a href="/postman-collection.json"
    download="cadenza-postman-collection.json">Download Postman Collection</a>
  version: 3.0.1
  license:
    name: Proprietary
    url: https://algo724.com/terms
servers:
  - url: https://cadenza-api-uat.algo724.com
    description: UAT REST API server
  - url: https://cadenza-api.algo724.com
    description: Production REST API server
  - url: wss://cadenza-ws-uat.algo724.com
    description: UAT WebSocket server
  - url: wss://cadenza-ws.algo724.com
    description: Production WebSocket server
security:
  - SupabaseOAuth2BearerAuth: []
x-common-responses:
  '400':
    description: Bad request
    content: &ref_0
      application/json:
        schema:
          allOf:
            - $ref: '#/components/schemas/baseResponse'
            - type: object
              properties:
                data:
                  type: string
                  nullable: true
                  example: Bad request
  '401':
    description: Unauthorized - Authentication required
    content: &ref_1
      application/json:
        schema:
          allOf:
            - $ref: '#/components/schemas/baseResponse'
            - type: object
              properties:
                data:
                  type: string
                  nullable: true
                  example: Authentication required
  '403':
    description: Forbidden - Insufficient permissions
    content: &ref_2
      application/json:
        schema:
          allOf:
            - $ref: '#/components/schemas/baseResponse'
            - type: object
              properties:
                data:
                  type: string
                  nullable: true
                  example: Insufficient permissions
  '404':
    description: Not found
    content: &ref_3
      application/json:
        schema:
          allOf:
            - $ref: '#/components/schemas/baseResponse'
            - type: object
              properties:
                data:
                  type: string
                  nullable: true
                  example: Not found
  '500':
    description: Internal server error
    content: &ref_4
      application/json:
        schema:
          allOf:
            - $ref: '#/components/schemas/baseResponse'
            - type: object
              properties:
                data:
                  type: string
                  nullable: true
                  example: Internal server error
tags:
  - name: Utility
    description: Utility endpoints
  - name: Authentication
    description: Authentication endpoints (Supabase GoTrue proxy)
  - name: Trade Order
    description: Trade Order Management
  - name: Trading Account
    description: Trading Account Management
  - name: Trading Account Credential
    description: Trading Account Credential Management
  - name: Trading Account Subscription
    description: Trading Account Subscription Management
  - name: Trading Account Portfolio
    description: Trading Account Portfolio Management
  - name: Market
    description: Market data and instruments
  - name: Market Subscription
    description: Market data subscription management
  - name: WebSocket
    description: WebSocket message specifications
paths:
  /api/v3:
    get:
      operationId: root
      summary: Root, Information about the API
      description: >-
        Root endpoint providing API metadata, version information, and available
        endpoints
      tags:
        - Utility
      responses:
        '200':
          $ref: '#/components/responses/rootResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/health:
    get:
      operationId: health
      summary: Health check
      description: >-
        Health check endpoint for monitoring service status and dependencies. No
        authentication required - designed for load balancers, Kubernetes
        probes, and monitoring systems.
      tags:
        - Utility
      security: []
      responses:
        '200':
          $ref: '#/components/responses/healthResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '503':
          $ref: '#/components/responses/healthResponse'
  /api/v3/auth/signup:
    post:
      operationId: authSignup
      summary: Sign up new user
      description: Create a new user account with email and password
      tags:
        - Authentication
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/authSignupRequest'
      responses:
        '200':
          $ref: '#/components/responses/authUserResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '429':
          $ref: '#/components/responses/rateLimitedResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/auth/login:
    post:
      operationId: authLogin
      summary: Login with email and password
      description: Authenticate user and return access/refresh tokens
      tags:
        - Authentication
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/authLoginRequest'
      responses:
        '200':
          $ref: '#/components/responses/authSessionResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '429':
          $ref: '#/components/responses/rateLimitedResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/auth/logout:
    post:
      operationId: authLogout
      summary: Logout user
      description: Invalidate the current session
      tags:
        - Authentication
      responses:
        '200':
          $ref: '#/components/responses/authSimpleResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/auth/token/refresh:
    post:
      operationId: authRefreshToken
      summary: Refresh access token
      description: Get new access token using refresh token
      tags:
        - Authentication
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/authRefreshTokenRequest'
      responses:
        '200':
          $ref: '#/components/responses/authSessionResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/auth/user:
    get:
      operationId: authGetUser
      summary: Get current user
      description: Get the currently authenticated user's information
      tags:
        - Authentication
      responses:
        '200':
          $ref: '#/components/responses/authUserResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
    put:
      operationId: authUpdateUser
      summary: Update current user
      description: Update the currently authenticated user's information
      tags:
        - Authentication
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/authUpdateUserRequest'
      responses:
        '200':
          $ref: '#/components/responses/authUserResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/auth/recover:
    post:
      operationId: authRecover
      summary: Request password recovery
      description: Send password recovery email to user
      tags:
        - Authentication
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/authRecoverRequest'
      responses:
        '200':
          $ref: '#/components/responses/authSimpleResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '429':
          $ref: '#/components/responses/rateLimitedResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/tradeOrder/submit:
    post:
      operationId: submitTradeOrder
      summary: Submit trade order
      description: Submit a new trade order
      tags:
        - Trade Order
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/submitTradeOrderRequest'
      responses:
        '200':
          $ref: '#/components/responses/submitTradeOrderResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/tradeOrder/cancel:
    post:
      operationId: cancelTradeOrder
      summary: Cancel trade order
      description: Cancel an existing trade order
      tags:
        - Trade Order
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/cancelTradeOrderRequest'
      responses:
        '200':
          $ref: '#/components/responses/cancelTradeOrderResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/tradeOrder/list:
    get:
      operationId: listTradeOrders
      summary: List trade orders
      description: List trade orders with filtering options
      tags:
        - Trade Order
      parameters:
        - $ref: '#/components/parameters/tradeOrderId'
        - $ref: '#/components/parameters/orderStatus'
        - $ref: '#/components/parameters/tradingAccountId'
        - $ref: '#/components/parameters/instrumentId'
        - $ref: '#/components/parameters/startTime'
        - $ref: '#/components/parameters/endTime'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/cursor'
        - $ref: '#/components/parameters/ascending'
      responses:
        '200':
          $ref: '#/components/responses/listTradeOrdersResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/credential/list:
    get:
      operationId: listTradingAccountCredentials
      summary: List trading account credentials
      description: List all credentials for a trading account
      tags:
        - Trading Account Credential
      parameters:
        - $ref: '#/components/parameters/credentialType'
        - $ref: '#/components/parameters/credentialStatus'
        - $ref: '#/components/parameters/credentialIds'
      responses:
        '200':
          $ref: '#/components/responses/listTradingAccountCredentialsResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
  /api/v3/credential/create:
    post:
      operationId: createTradingAccountCredential
      summary: Create trading account credential
      description: Create credentials for a trading account
      tags:
        - Trading Account Credential
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/createTradingAccountCredentialRequest'
      responses:
        '200':
          $ref: '#/components/responses/tradingAccountCredentialResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/credential/revoke:
    post:
      operationId: revokeTradingAccountCredential
      summary: Revoke trading account credential
      description: Revoke credentials for a trading account.
      tags:
        - Trading Account Credential
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/revokeTradingAccountCredentialRequest'
      responses:
        '200':
          $ref: '#/components/responses/tradingAccountCredentialResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/credential/rotate:
    post:
      operationId: rotateTradingAccountCredential
      summary: Rotate trading account credential
      description: >-
        Rotate credentials for a trading account, the credential will be rotated
        to the new api key, api secret and api passphrase, other fields are not
        editable.
      tags:
        - Trading Account Credential
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/rotateTradingAccountCredentialRequest'
      responses:
        '200':
          $ref: '#/components/responses/tradingAccountCredentialResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/credential/verify:
    post:
      operationId: verifyTradingAccountCredential
      summary: Verify trading account credential
      description: >-
        Verify credentials and list all supported trading accounts that the
        credential have permissions to access
      tags:
        - Trading Account Credential
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/verifyTradingAccountCredentialRequest'
      responses:
        '200':
          $ref: '#/components/responses/verifyTradingAccountCredentialResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/tradingAccount/connect:
    post:
      operationId: connectTradingAccount
      summary: Connect trading account
      description: Connect to a trading account
      tags:
        - Trading Account
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/connectTradingAccountRequest'
      responses:
        '200':
          $ref: '#/components/responses/tradingAccountResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/tradingAccount/disconnect:
    post:
      operationId: disconnectTradingAccount
      summary: Disconnect trading account
      description: >-
        Disconnect from a trading account, all trading functions and the event
        stream notification will be stopped. The trading account will be
        archived and no longer available for trading. If the same trading
        account need to be connected again, please use the connect trading
        account API to create another new trading account.
      tags:
        - Trading Account
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/disconnectTradingAccountRequest'
      responses:
        '200':
          $ref: '#/components/responses/tradingAccountResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/tradingAccount/update:
    post:
      operationId: updateTradingAccount
      summary: Update trading account
      description: Update trading account information
      tags:
        - Trading Account
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/updateTradingAccountRequest'
      responses:
        '200':
          $ref: '#/components/responses/tradingAccountResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/tradingAccount/list:
    get:
      operationId: listTradingAccounts
      summary: List trading accounts
      description: List all trading accounts
      tags:
        - Trading Account
      parameters:
        - $ref: '#/components/parameters/tradingAccountId'
        - $ref: '#/components/parameters/venue'
        - $ref: '#/components/parameters/accountStatus'
        - $ref: '#/components/parameters/userId'
        - $ref: '#/components/parameters/tenantId'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/offset'
      responses:
        '200':
          $ref: '#/components/responses/listTradingAccountsResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/tradingAccount/disable:
    post:
      operationId: disableTradingAccount
      summary: Disable trading account
      description: >-
        Disable a trading account, the trading account will be disabled and no
        longer available for trading.
      tags:
        - Trading Account
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/disableTradingAccountRequest'
      responses:
        '200':
          $ref: '#/components/responses/tradingAccountResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/tradingAccount/enable:
    post:
      operationId: enableTradingAccount
      summary: Enable trading account
      description: >-
        Enable a trading account, the trading account will be enabled and
        available for trading.
      tags:
        - Trading Account
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/enableTradingAccountRequest'
      responses:
        '200':
          $ref: '#/components/responses/tradingAccountResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/tradingAccount/operation/list:
    get:
      operationId: listTradingAccountOperations
      summary: List trading account operations
      description: List operations history for trading accounts
      tags:
        - Trading Account
      parameters:
        - $ref: '#/components/parameters/tradingAccountId'
        - $ref: '#/components/parameters/operationType'
        - $ref: '#/components/parameters/startTime'
        - $ref: '#/components/parameters/endTime'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/cursor'
      responses:
        '200':
          $ref: '#/components/responses/listTradingAccountOperationsResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/tradingAccount/subscription/subscribe:
    post:
      operationId: subscribeTradingAccount
      summary: Subscribe to trading account updates
      description: Subscribe to real-time trading account updates
      tags:
        - Trading Account Subscription
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/subscribeTradingAccountRequest'
      responses:
        '200':
          $ref: '#/components/responses/subscriptionResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/tradingAccount/subscription/unsubscribe:
    post:
      operationId: unsubscribeTradingAccount
      summary: Unsubscribe from trading account updates
      description: Unsubscribe from real-time trading account updates
      tags:
        - Trading Account Subscription
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/unsubscribeRequest'
      responses:
        '200':
          $ref: '#/components/responses/subscriptionResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
  /api/v3/tradingAccount/subscription/list:
    get:
      operationId: listTradingAccountSubscriptions
      summary: List trading account subscriptions
      description: List active trading account subscriptions
      tags:
        - Trading Account Subscription
      parameters:
        - $ref: '#/components/parameters/tradingAccountId'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/cursor'
      responses:
        '200':
          $ref: '#/components/responses/listSubscriptionsResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
  /api/v3/tradingAccount/portfolio/list:
    get:
      operationId: listTradingAccountPortfolios
      summary: List trading account portfolios
      description: List portfolios across all trading accounts
      tags:
        - Trading Account Portfolio
      parameters:
        - $ref: '#/components/parameters/tradingAccountId'
        - $ref: '#/components/parameters/venue'
        - $ref: '#/components/parameters/currency'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/offset'
      responses:
        '200':
          $ref: '#/components/responses/listTradingAccountPortfoliosResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/market/subscription/orderBook/subscribe:
    post:
      operationId: subscribeMarketOrderBook
      summary: Subscribe to order book updates
      description: Subscribe to real-time order book updates
      tags:
        - Market Subscription
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/subscribeMarketOrderBookRequest'
      responses:
        '200':
          $ref: '#/components/responses/subscriptionResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/market/subscription/orderBook/unsubscribe:
    post:
      operationId: unsubscribeMarketOrderBook
      summary: Unsubscribe from order book updates
      description: Unsubscribe from real-time order book updates
      tags:
        - Market Subscription
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/unsubscribeRequest'
      responses:
        '200':
          $ref: '#/components/responses/subscriptionResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/market/subscription/orderBook/list:
    get:
      operationId: listMarketOrderBookSubscriptions
      summary: List order book subscriptions
      description: List active order book subscriptions
      tags:
        - Market Subscription
      parameters:
        - $ref: '#/components/parameters/instrumentId'
      responses:
        '200':
          $ref: '#/components/responses/listSubscriptionsResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/market/venue/list:
    get:
      operationId: listMarketVenues
      summary: List market venues
      description: List available market venues/exchanges
      tags:
        - Market
      responses:
        '200':
          $ref: '#/components/responses/listMarketVenuesResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/market/instrument/sync:
    post:
      operationId: syncMarketInstruments
      summary: Sync market instruments
      description: Synchronize market instruments from exchanges
      tags:
        - Market
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/syncMarketInstrumentsRequest'
      responses:
        '200':
          $ref: '#/components/responses/syncInstrumentsResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/market/instrument/delete:
    delete:
      operationId: deleteMarketInstrument
      summary: Delete market instrument
      description: Delete a market instrument
      tags:
        - Market
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/deleteMarketInstrumentRequest'
      responses:
        '200':
          $ref: '#/components/responses/simpleResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/market/instrument/enable:
    post:
      operationId: enableMarketInstrument
      summary: Enable market instrument
      description: Enable a market instrument for trading
      tags:
        - Market
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/enableMarketInstrumentRequest'
      responses:
        '200':
          $ref: '#/components/responses/instrumentResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/market/instrument/disable:
    post:
      operationId: disableMarketInstrument
      summary: Disable market instrument
      description: Disable a market instrument for trading
      tags:
        - Market
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/disableMarketInstrumentRequest'
      responses:
        '200':
          $ref: '#/components/responses/instrumentResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/market/instrument/list:
    get:
      operationId: listMarketInstruments
      summary: List market instruments
      description: List available market instruments
      tags:
        - Market
      parameters:
        - $ref: '#/components/parameters/venue'
        - $ref: '#/components/parameters/instrumentSymbols'
        - $ref: '#/components/parameters/securityType'
        - $ref: '#/components/parameters/instrumentStatus'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/offset'
      responses:
        '200':
          $ref: '#/components/responses/listMarketInstrumentsResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/market/security/sync:
    post:
      operationId: syncMarketSecurities
      summary: Sync market securities
      description: Synchronize financial securities from exchanges
      tags:
        - Market
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/syncMarketSecuritiesRequest'
      responses:
        '200':
          $ref: '#/components/responses/simpleResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/market/security/delete:
    delete:
      operationId: deleteMarketSecurity
      summary: Delete market security
      description: Delete a financial security
      tags:
        - Market
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/deleteMarketSecurityRequest'
      responses:
        '200':
          $ref: '#/components/responses/securityResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/market/security/list:
    get:
      operationId: listMarketSecurities
      summary: List market securities
      description: List available financial securities
      tags:
        - Market
      parameters:
        - $ref: '#/components/parameters/venue'
        - $ref: '#/components/parameters/securityId'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/offset'
      responses:
        '200':
          $ref: '#/components/responses/listMarketSecuritiesResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/market/orderBook/get:
    get:
      operationId: getMarketOrderBook
      summary: Get market order book
      description: Get order book for a specific instrument. instrumentId or venue+symbol
      tags:
        - Market
      parameters:
        - $ref: '#/components/parameters/instrumentId'
        - $ref: '#/components/parameters/venue'
        - $ref: '#/components/parameters/instrumentSymbol'
        - $ref: '#/components/parameters/depth'
      responses:
        '200':
          $ref: '#/components/responses/orderBookResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /api/v3/market/orderBook/list:
    get:
      operationId: listMarketOrderBooks
      summary: List market order books
      description: List order books for multiple instruments
      tags:
        - Market
      parameters:
        - in: query
          name: instrumentIds
          schema:
            type: array
            items:
              type: string
              description: Instrument ID
              example: BINANCE:BTC/USDT
        - $ref: '#/components/parameters/venue'
        - $ref: '#/components/parameters/instrumentSymbols'
        - $ref: '#/components/parameters/depth'
      responses:
        '200':
          $ref: '#/components/responses/listMarketOrderBooksResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '404':
          $ref: '#/components/responses/notFoundResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
  /connection/websocket:
    post:
      operationId: websocketConnect
      summary: WebSocket Connection
      description: >-
        **This endpoint documents the WebSocket API protocol, not a REST
        endpoint.**


        Connect to the Cadenza WebSocket API using the Centrifugo protocol.

        Use the WebSocket servers listed above
        (`wss://cadenza-ws.algo724.com/connection/websocket` for production

        or `wss://cadenza-ws-uat.algo724.com/connection/websocket` for UAT).


        ## Connection Flow


        1. **Establish WebSocket connection** to the server URL

        2. **Send connect command** with authentication token

        3. **Receive connect result** with client ID and session info

        4. **Subscribe to channels** for real-time updates

        5. **Receive push messages** with data updates


        ## Authentication


        Include your JWT token in the connect command:

        ```json

        {
          "connect": {
            "token": "your-jwt-token",
            "name": "your-client-name"
          },
          "id": 1
        }

        ```


        ## Available Channels


        Subscribe to channels for real-time updates:


        | Channel Pattern | Description |

        |-----------------|-------------|

        | `tradingAccount:{accountId}` | Trading account updates (orders,
        portfolio, balances) |

        | `market:orderBook:{instrumentId}` | Order book updates for an
        instrument |

        | `market:trade:{instrumentId}` | Trade updates for an instrument |


        ## Message Format


        All WebSocket messages follow the Centrifugo JSON protocol format.

        See the WebSocket schemas section for detailed message structures.


        For complete protocol documentation, refer to:

        - [Centrifugo Client
        Protocol](https://centrifugal.dev/docs/transports/client_protocol)

        - [Protocol Definitions
        (Protobuf)](https://github.com/centrifugal/protocol/blob/master/definitions/client.proto)
      tags:
        - WebSocket
      security: []
      requestBody:
        description: WebSocket command (sent after WebSocket connection is established)
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/wsCommand'
            examples:
              connect:
                summary: Connect command
                value:
                  id: 1
                  connect:
                    token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
                    name: my-trading-client
                    version: 1.0.0
              subscribe:
                summary: Subscribe command
                value:
                  id: 2
                  subscribe:
                    channel: tradingAccount:acc-123
              unsubscribe:
                summary: Unsubscribe command
                value:
                  id: 3
                  unsubscribe:
                    channel: tradingAccount:acc-123
              rpc:
                summary: RPC command
                value:
                  id: 4
                  rpc:
                    method: query.trade_order.list
                    data:
                      tradingAccountId: 550e8400-e29b-41d4-a716-446655440000
              ping:
                summary: Ping command
                value:
                  id: 5
                  ping: {}
      responses:
        '101':
          description: >-
            WebSocket connection upgraded successfully. Server replies with
            wsReply messages.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/wsReply'
              examples:
                connectResult:
                  summary: Connect result
                  value:
                    id: 1
                    connect:
                      client: c7a8b9d0-1234-5678-9abc-def012345678
                      version: 5.0.0
                      expires: false
                      ttl: 0
                      ping: 25
                      pong: true
                      time: 1703052635110
                subscribeResult:
                  summary: Subscribe result
                  value:
                    id: 2
                    subscribe:
                      recoverable: true
                      epoch: epoch-123
                      offset: 100
                pushPublication:
                  summary: Push publication (server-initiated)
                  value:
                    id: 0
                    push:
                      channel: tradingAccount:acc-123
                      pub:
                        data:
                          type: orderUpdate
                          order:
                            orderId: order-456
                            status: FILLED
                        offset: 101
                        time: 1703052635200
                error:
                  summary: Error response
                  value:
                    id: 1
                    error:
                      code: 100
                      message: invalid token
                      temporary: false
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
components:
  parameters:
    idempotencyKeyHeader:
      in: header
      name: X-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
    tradeOrderId:
      in: query
      name: tradeOrderId
      schema:
        $ref: '#/components/schemas/uuidString'
      description: Trade order ID
    venue:
      in: query
      name: venue
      description: Exchange type
      schema:
        $ref: '#/components/schemas/venue'
    securityId:
      in: query
      name: securityId
      schema:
        $ref: '#/components/schemas/securityId'
      description: Security ID
    tradingAccountId:
      in: query
      name: tradingAccountId
      schema:
        $ref: '#/components/schemas/uuidString'
      description: Trading account ID
    subscriptionStatus:
      in: query
      name: subscriptionStatus
      schema:
        $ref: '#/components/schemas/subscriptionStatus'
      description: Subscription status
    credentialType:
      in: query
      name: credentialType
      schema:
        $ref: '#/components/schemas/credentialType'
      description: Credential type
    credentialStatus:
      in: query
      name: credentialStatus
      schema:
        $ref: '#/components/schemas/tradingAccountStatus'
      description: Credential status
    credentialId:
      in: query
      name: credentialId
      schema:
        $ref: '#/components/schemas/uuidString'
      description: Credential ID
    instrumentId:
      in: query
      name: instrumentId
      schema:
        $ref: '#/components/schemas/instrumentId'
      description: Instrument ID
    orderStatus:
      in: query
      name: orderStatus
      description: Order status
      schema:
        $ref: '#/components/schemas/orderStatus'
    accountStatus:
      in: query
      name: accountStatus
      description: Account status
      schema:
        $ref: '#/components/schemas/tradingAccountStatus'
    instrumentStatus:
      in: query
      name: instrumentStatus
      description: Instrument status
      schema:
        $ref: '#/components/schemas/instrumentStatus'
    instrumentSymbols:
      in: query
      name: symbols
      schema:
        type: array
        items:
          type: string
          example: BTC/USDT
      description: Instrument Symbols array
    credentialIds:
      in: query
      name: credentialIds
      schema:
        type: array
        items:
          type: string
      description: credentialId array
    instrumentSymbol:
      in: query
      name: symbol
      schema:
        type: string
        example: BTC/USDT
      description: Instrument Symbol
    currency:
      in: query
      name: currency
      schema:
        type: string
        example: USDT
      description: Currency
    securityType:
      in: query
      name: securityType
      description: Security type
      schema:
        $ref: '#/components/schemas/securityType'
    operationType:
      in: query
      name: operationType
      description: Operation type
      schema:
        $ref: '#/components/schemas/operationType'
    depth:
      in: query
      name: depth
      schema:
        type: integer
        default: 10
        minimum: 1
        maximum: 1000
      description: Order book depth
    startTime:
      in: query
      name: startTime
      schema:
        type: integer
        example: 1622505600000
      description: Start time (in unix milliseconds), of the created at field
    endTime:
      in: query
      name: endTime
      schema:
        type: integer
      description: End time (in unix milliseconds), of the created at field
    limit:
      in: query
      name: limit
      schema:
        type: integer
        example: 100
        default: 50
        minimum: 1
        maximum: 1000
      description: Limit the number of returned results
    offset:
      in: query
      name: offset
      schema:
        type: integer
        example: 0
        default: 0
        minimum: 0
      description: Offset of the returned results
    cursor:
      in: query
      name: cursor
      schema:
        type: string
        description: Cursor for next page
    ascending:
      in: query
      name: ascending
      schema:
        type: boolean
        default: false
      description: Return records in ascending order
    userId:
      in: query
      name: userId
      schema:
        type: string
        format: uuid
      description: Filter by user ID
    tenantId:
      in: query
      name: tenantId
      schema:
        type: string
      description: Filter by tenant ID
  responses:
    simpleResponse:
      description: Simple successful response
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                description: Indicates if the operation was successful
              errno:
                type: integer
                description: Error code (0 for success, negative for errors)
                example: 0
              error:
                type: string
                nullable: true
                description: Error message (null for successful operations)
              data:
                type: string
                example: ok
            required:
              - success
              - errno
              - error
    rootResponse:
      description: Root endpoint response with API information
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: object
                    properties:
                      name:
                        type: string
                        example: Algo724 Cadenza Fermata API
                      version:
                        type: string
                        example: 3.0.1
                      description:
                        type: string
                        example: >-
                          Unified trading platform for connecting to multiple
                          venues, executing orders, and accessing real-time
                          market data
                      documentation:
                        type: string
                        example: https://docs.algo724.com/api/v3
    healthResponse:
      description: >-
        Health check response with system status (200 = healthy, 503 =
        unhealthy)
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                $ref: '#/components/schemas/healthStatus'
              timestamp:
                type: integer
                format: int64
                example: 1632933600000
                description: Health check timestamp in milliseconds
              isoDateTime:
                type: string
                format: date-time
                example: '2023-09-29T12:00:00.000Z'
                description: Health check timestamp in ISO 8601 format
              version:
                type: string
                example: 3.0.1
                description: API version
              checks:
                type: object
                description: Health status of individual components
                properties:
                  database:
                    $ref: '#/components/schemas/healthCheckComponent'
                  temporal:
                    $ref: '#/components/schemas/healthCheckComponent'
                  redis:
                    $ref: '#/components/schemas/healthCheckComponent'
            required:
              - status
              - timestamp
              - version
    badRequestResponse:
      description: Bad request
      content: *ref_0
    unauthorizedResponse:
      description: Unauthorized - Authentication required
      content: *ref_1
    forbiddenResponse:
      description: Forbidden - Insufficient permissions
      content: *ref_2
    notFoundResponse:
      description: Not found
      content: *ref_3
    internalServerErrorResponse:
      description: Internal server error
      content: *ref_4
    rateLimitedResponse:
      description: Too many requests - Rate limited
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: string
                    nullable: true
                    example: Too many requests
    authUserResponse:
      description: Authentication user response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    $ref: '#/components/schemas/authUser'
    authSessionResponse:
      description: Authentication session response with tokens
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    $ref: '#/components/schemas/authSession'
    authSimpleResponse:
      description: Simple authentication response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: string
                    example: ok
    submitTradeOrderResponse:
      description: Submit trade order response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/tradeOrder'
    cancelTradeOrderResponse:
      description: Cancel trade order response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    $ref: '#/components/schemas/tradeOrder'
    getTradeOrderResponse:
      description: Get trade order response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    $ref: '#/components/schemas/tradeOrder'
    listTradeOrdersResponse:
      description: List trade orders response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/tradeOrder'
                  pagination:
                    $ref: '#/components/schemas/pagination'
    tradingAccountCredentialResponse:
      description: Save trading account credential response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    $ref: '#/components/schemas/tradingAccountCredential'
    listTradingAccountCredentialsResponse:
      description: List trading account credentials response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/tradingAccountCredential'
                  pagination:
                    $ref: '#/components/schemas/pagination'
    tradingAccountResponse:
      description: Connect trading account response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    $ref: '#/components/schemas/tradingAccount'
    listTradingAccountsResponse:
      description: List trading accounts response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/tradingAccount'
                  pagination:
                    $ref: '#/components/schemas/pagination'
    verifyTradingAccountCredentialResponse:
      description: Verify trading account credential response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/tradingAccount'
    listTradingAccountOperationsResponse:
      description: List trading account operations response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/accountOperation'
                  pagination:
                    $ref: '#/components/schemas/pagination'
    tradingAccountPortfolioResponse:
      description: Get trading account portfolio response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    $ref: '#/components/schemas/portfolio'
    listTradingAccountPortfoliosResponse:
      description: List trading account portfolios response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/portfolio'
                  pagination:
                    $ref: '#/components/schemas/pagination'
    subscriptionResponse:
      description: Subscription response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    $ref: '#/components/schemas/subscription'
    listSubscriptionsResponse:
      description: List subscriptions response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/subscription'
    listMarketVenuesResponse:
      description: List market venues response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/marketVenue'
    instrumentResponse:
      description: Instrument response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    $ref: '#/components/schemas/instrument'
    listMarketInstrumentsResponse:
      description: List market instruments response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/instrument'
                  pagination:
                    $ref: '#/components/schemas/pagination'
    syncInstrumentsResponse:
      description: Sync market instruments response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    $ref: '#/components/schemas/syncMarketInstrumentsResponseData'
    orderBookResponse:
      description: Get market order book response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    $ref: '#/components/schemas/orderbook'
    listMarketOrderBooksResponse:
      description: List market order books response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/orderbook'
    securityResponse:
      description: Security response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    $ref: '#/components/schemas/financialSecurity'
    listMarketSecuritiesResponse:
      description: List market securities response
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/baseResponse'
              - type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/financialSecurity'
                  pagination:
                    $ref: '#/components/schemas/pagination'
  schemas:
    baseResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Indicates if the operation was successful
        errno:
          type: integer
          description: Error code (0 for success, negative for errors)
          example: 0
        error:
          type: string
          nullable: true
          description: Error message (null for successful operations)
        details:
          type: object
          nullable: true
          description: Additional error details (optional, only present in error responses)
          properties:
            code:
              type: string
              description: Error code identifier (e.g., INVALID_TOKEN, ACCESS_DENIED)
              example: INVALID_TOKEN
            resource:
              type: string
              description: Resource that was being accessed
              example: /api/v3/tradingAccount
            action:
              type: string
              description: Action that was being attempted
              example: create
            required:
              type: array
              items:
                type: string
              description: Required permissions or roles
              example:
                - admin
                - write
            provided:
              type: array
              items:
                type: string
              description: Provided permissions or roles
              example:
                - read
            tenant_id:
              type: string
              description: Tenant ID if relevant to the error
              example: tenant-123
            request_id:
              type: string
              description: Request ID for tracking and debugging
              example: req-456-789
            metadata:
              type: object
              description: Additional metadata as key-value pairs
              additionalProperties: true
      required:
        - success
        - errno
        - error
    millisecond:
      type: integer
      format: int64
      example: 1632933600000
      description: Unix timestamp in milliseconds
    isoTimestamp:
      type: string
      format: date-time
      description: >-
        Timestamp in ISO 8601 format (RFC3339). This is the native format used
        by Go's time.Time.
      example: '2023-09-29T12:00:00.000Z'
    decimal:
      type: string
      description: Decimal value as string to preserve precision
      pattern: ^-?\d+(\.\d+)?$
      example: '1234.56789000'
    positiveDecimal:
      type: string
      description: Positive decimal value as string
      pattern: ^\d+(\.\d+)?$
      example: '100.50'
    timestamp:
      type: integer
      format: int64
      description: Unix timestamp in milliseconds
      example: 1703052635110
    uuidString:
      type: string
      format: uuid
      description: UUID string
    authSignupRequest:
      type: object
      required:
        - email
        - password
      properties:
        email:
          type: string
          format: email
          description: User email address
          example: user@example.com
        password:
          type: string
          minLength: 8
          description: User password (minimum 8 characters)
          example: securepassword123
        metadata:
          type: object
          description: Optional user metadata
          additionalProperties: true
    authLoginRequest:
      type: object
      required:
        - email
        - password
      properties:
        email:
          type: string
          format: email
          description: User email address
          example: user@example.com
        password:
          type: string
          description: User password
          example: securepassword123
    authRefreshTokenRequest:
      type: object
      required:
        - refreshToken
      properties:
        refreshToken:
          type: string
          description: Refresh token from previous login
    authUpdateUserRequest:
      type: object
      properties:
        email:
          type: string
          format: email
          description: New email address
        password:
          type: string
          minLength: 8
          description: New password (minimum 8 characters)
        metadata:
          type: object
          description: User metadata to update
          additionalProperties: true
    authRecoverRequest:
      type: object
      required:
        - email
      properties:
        email:
          type: string
          format: email
          description: Email address to send recovery link
          example: user@example.com
    authUser:
      type: object
      description: Authenticated user information
      properties:
        id:
          type: string
          format: uuid
          description: User ID
        email:
          type: string
          format: email
          description: User email address
        phone:
          type: string
          nullable: true
          description: User phone number
        emailConfirmedAt:
          type: string
          format: date-time
          nullable: true
          description: Email confirmation timestamp
        phoneConfirmedAt:
          type: string
          format: date-time
          nullable: true
          description: Phone confirmation timestamp
        lastSignInAt:
          type: string
          format: date-time
          nullable: true
          description: Last sign in timestamp
        role:
          type: string
          description: User role
          example: authenticated
        createdAt:
          type: string
          format: date-time
          description: Account creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Account last update timestamp
        appMetadata:
          type: object
          description: Application metadata
          properties:
            tenantId:
              type: string
              nullable: true
              description: Tenant ID
            environments:
              type: array
              items:
                type: string
              description: Allowed environments
        userMetadata:
          type: object
          description: User-defined metadata
          additionalProperties: true
    authSession:
      type: object
      description: Authentication session with tokens
      properties:
        accessToken:
          type: string
          description: JWT access token
        refreshToken:
          type: string
          description: Refresh token for obtaining new access tokens
        tokenType:
          type: string
          description: Token type
          example: bearer
        expiresIn:
          type: integer
          description: Token expiry in seconds
          example: 3600
        expiresAt:
          type: integer
          format: int64
          description: Token expiry timestamp (Unix seconds)
        user:
          $ref: '#/components/schemas/authUser'
    venue:
      type: string
      description: >
        Trading venue identifier. UAT/sandbox environments are treated as
        separate venues.

        Note: _SANDBOX and _PAPER suffixes are deprecated. Use _UAT suffix for
        new integrations.
      enum:
        - ''
        - BINANCE
        - B2C2
        - WINTERMUTE
        - BLOCKFILLS
        - STONEX
        - CUMBERLAND
        - IBKR
        - DERIBIT
        - BITFINEX
        - OKX
        - BINANCE_UAT
        - B2C2_UAT
        - WINTERMUTE_UAT
        - BLOCKFILLS_UAT
        - STONEX_UAT
        - CUMBERLAND_UAT
        - IBKR_UAT
        - DERIBIT_UAT
        - BITFINEX_UAT
        - OKX_UAT
        - BINANCE_SANDBOX
        - B2C2_SANDBOX
        - IBKR_PAPER
        - MOCK
        - PAPER
      example: BINANCE
    credentialType:
      type: string
      description: Type of API credential
      enum:
        - ''
        - API_KEY
        - HMAC
        - OAUTH
        - RSA
        - ED25519
      example: API_KEY
    credentialStatus:
      type: string
      description: Status of the credential
      enum:
        - CREATED
        - VALIDATED
        - INACTIVE
        - REVOKED
        - ERROR
        - UNKNOWN
      example: VALIDATED
    orderSide:
      type: string
      description: Order side (buy or sell)
      enum:
        - BUY
        - SELL
        - UNKNOWN
      example: BUY
    orderType:
      type: string
      description: Order type
      enum:
        - ''
        - MARKET
        - LIMIT
        - STOP
        - STOP_LIMIT
        - STOP_LOSS
        - STOP_LOSS_LIMIT
        - TAKE_PROFIT
        - TAKE_PROFIT_LIMIT
        - TRAILING_STOP
        - QUOTED
        - UNKNOWN
      example: LIMIT
    orderStatus:
      type: string
      description: Order status
      enum:
        - ''
        - CREATED
        - SUBMITTED
        - ACCEPTED
        - PARTIALLY_FILLED
        - FILLED
        - CANCELLED
        - PENDING_CANCEL
        - REPLACED
        - PENDING_REPLACE
        - REJECTED
        - EXPIRED
        - REVOKED
        - UNKNOWN
      example: FILLED
    rejectReason:
      type: string
      description: Reason for order rejection
    cancelReason:
      type: string
      description: Reason for order cancellation
    timeInForce:
      type: string
      description: Time in force - specifies how long an order remains active
      enum:
        - ''
        - GTC
        - IOC
        - FOK
        - GTD
        - DAY
        - GTX
        - OPG
        - CLS
        - GFA
        - GFS
        - GTM
        - MOO
        - MOC
        - EXT
        - UNKNOWN
      example: GTC
    quantityType:
      type: string
      description: How order quantity is specified
      enum:
        - BASE
        - QUOTE
        - POSITION_RATIO
        - POSITION_PERCENTAGE
      example: BASE
    orderQuantityType:
      type: string
      description: How order quantity is specified
      enum:
        - BASE
        - QUOTE
        - POSITION_RATIO
        - POSITION_PERCENTAGE
      example: BASE
    quantityRounding:
      type: string
      description: >-
        Quantity rounding strategy to meet lot size requirements. Empty string
        means no rounding.
      enum:
        - ''
        - UP
        - DOWN
        - NEAREST
        - CEIL
        - FLOOR
        - HALF_UP
        - HALF_DOWN
        - HALF_EVEN
      default: ''
      example: DOWN
    instrumentId:
      type: string
      description: Instrument ID in format {VENUE}:{BASE}/{QUOTE}
      example: BINANCE:BTC/USDT
    idempotencyKey:
      type: string
      description: Idempotency key to prevent duplicate request processing
      example: my_unique_request_id
    clientOrderId:
      type: string
      description: Client-provided order ID, used as idempotency key
      example: client_order_12345
    securityId:
      type: string
      description: Security ID in format {VENUE}:{SYMBOL}
      example: BINANCE:BTC
    healthStatus:
      type: string
      description: Health status of a component or system
      enum:
        - healthy
        - degraded
        - unhealthy
      example: healthy
    healthCheckComponent:
      type: object
      properties:
        status:
          $ref: '#/components/schemas/healthStatus'
      required:
        - status
    tradingAccountStatus:
      type: string
      description: Status of the trading account
      enum:
        - SETUP
        - ACTIVE
        - INACTIVE
        - LOCKED
        - DISCONNECTED
        - SUSPENDED
        - DELETED
        - UNKNOWN
      example: ACTIVE
    tradingAccountType:
      type: string
      description: Type of trading account
      enum:
        - SPOT
        - MARGIN
        - FUTURES
        - OPTIONS
      example: SPOT
    tradingAccountOperationType:
      type: string
      description: Type of trading account operation
      enum:
        - CONNECT
        - CONNECTED
        - DISCONNECT
        - DISCONNECTED
        - ENABLE
        - ENABLED
        - DISABLE
        - DISABLED
        - DELETED
      example: CONNECTED
    tradingAccountCredentialStatus:
      type: string
      enum:
        - CREATED
        - REVOKED
      description: Status of the trading account credential
    accountType:
      type: string
      description: Type of trading account
      enum:
        - SPOT
        - MARGIN
        - FUTURES
        - OPTIONS
      example: SPOT
    positionMode:
      type: string
      description: Position mode setting - how positions are handled
      enum:
        - ''
        - HEDGE
        - NETTING
      example: NETTING
    collateralMode:
      type: string
      description: Collateral mode - how margin is shared across positions
      enum:
        - ''
        - CROSS
        - ISOLATED
      example: CROSS
    marginMode:
      type: string
      description: Margin mode - account-level margin calculation type
      enum:
        - ''
        - STANDARD
        - PORTFOLIO
      example: STANDARD
    instrumentType:
      type: string
      description: Type of financial instrument
      enum:
        - SPOT
        - FUTURES
        - OPTION
        - PERPETUAL
        - DERIVATIVE
      example: SPOT
    securityType:
      type: string
      description: Type of security (base asset)
      enum:
        - ''
        - CASH
        - STOCK
        - CRYPTO
        - CURRENCY
        - COMMODITY
        - INDEX
        - BOND
        - DERIVATIVE
        - OPTION
        - FUTURE
        - FUTURES
        - PERPETUAL
        - FOREX
      example: CRYPTO
    operationType:
      type: string
      enum:
        - CONNECT
        - DISCONNECT
        - ENABLE
        - DISABLE
        - UPDATE
        - CREDENTIAL_REVOKE
        - CREDENTIAL_ROTATE
      description: Operation type
    operationStatus:
      type: string
      enum:
        - PENDING
        - SUCCESS
        - FAILED
      description: Operation status
    instrumentStatus:
      type: string
      enum:
        - ACTIVE
        - INACTIVE
        - DISABLED
        - DELISTED
      description: Instrument status
    venueStatus:
      type: string
      enum:
        - ONLINE
        - OFFLINE
        - MAINTENANCE
      description: Venue status
    balanceStatus:
      type: string
      description: Balance entry status
      enum:
        - ACTIVE
        - INACTIVE
        - FROZEN
      example: ACTIVE
    positionStatus:
      type: string
      description: Position entry status
      enum:
        - OPEN
        - CLOSED
        - LIQUIDATED
      example: OPEN
    updateMode:
      type: string
      description: Portfolio update mode
      enum:
        - DELTA
        - SNAPSHOT
      example: SNAPSHOT
    subscriptionType:
      type: string
      description: Type of data subscription
      enum:
        - MARKET.SUBSCRIPTION.ORDERBOOK
        - MARKET.SUBSCRIPTION.TRADE
        - MARKET.SUBSCRIPTION.TICKER
        - MARKET.SUBSCRIPTION.KLINE
        - TRADING_ACCOUNT.SUBSCRIPTION.USER_DATA
        - TRADING_ACCOUNT.SUBSCRIPTION.PORTFOLIO
        - TRADING_ACCOUNT.SUBSCRIPTION.EXECUTION_REPORT
        - TRADING_ACCOUNT.SUBSCRIPTION.TRADING_ACCOUNT
      example: MARKET.SUBSCRIPTION.ORDERBOOK
    subscriptionStatus:
      type: string
      description: Status of a subscription
      enum:
        - INACTIVE
        - ACTIVE
        - PAUSED
        - TERMINATED
      example: ACTIVE
    pagination:
      type: object
      description: Pagination parameters and metadata
      properties:
        offset:
          type: integer
          description: Number of items to skip
          example: 0
        limit:
          type: integer
          description: Maximum number of items to return
          example: 20
        total:
          type: integer
          description: Total number of items available
          example: 100
        cursor:
          type: string
          description: Cursor for next page (optional)
        hasNext:
          type: boolean
          description: Whether there are more items
          example: true
    securityQuantity:
      type: object
      properties:
        security:
          type: string
          description: Security ID in format venue:symbol (e.g., BINANCE:BTC)
          example: BINANCE:BTC
        asset:
          type: string
          description: Asset symbol (e.g., BTC, USDT, BNB)
          example: BTC
        venue:
          $ref: '#/components/schemas/venue'
          description: Trading venue/exchange
        quantity:
          $ref: '#/components/schemas/decimal'
          description: Quantity of the asset
      required:
        - security
        - asset
        - venue
        - quantity
    tradeExecution:
      type: object
      properties:
        executionId:
          $ref: '#/components/schemas/uuidString'
          description: Unique execution identifier
        externalTradeId:
          type: string
          description: Exchange's execution identifier
          example: binance-exec-12345
        venue:
          $ref: '#/components/schemas/venue'
          description: Exchange where this execution occurred
        instrumentId:
          $ref: '#/components/schemas/instrumentId'
          description: Instrument executed at this venue (e.g., BINANCE:BTC/USDT)
        orderSide:
          $ref: '#/components/schemas/orderSide'
        executedQuantity:
          $ref: '#/components/schemas/decimal'
          description: Quantity executed in this venue (base asset)
        executedPrice:
          $ref: '#/components/schemas/decimal'
          description: Average execution price at this venue
        executedCost:
          $ref: '#/components/schemas/decimal'
          description: Total cost for this execution (quote asset)
        fees:
          type: array
          items:
            $ref: '#/components/schemas/securityQuantity'
          description: Fees charged for this execution
        executedAt:
          $ref: '#/components/schemas/millisecond'
          description: Execution timestamp in milliseconds
        executedAtDateTime:
          type: string
          format: date-time
          description: Execution timestamp in ISO 8601 format
      required:
        - executionId
        - venue
        - instrumentId
        - executedQuantity
        - executedPrice
        - executedCost
        - executedAt
    responseError:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: INVALID_PARAMETER
        message:
          type: string
          description: Error message
          example: Invalid order quantity
      required:
        - code
        - message
    serviceName:
      type: string
      enum:
        - TRADE_ORDER_SERVICE
        - TRADING_ACCOUNT_SERVICE
        - MARKET_SERVICE
        - PORTFOLIO_SERVICE
        - EXECUTION_ENGINE
        - HTTP_SERVER
        - MARKET_QUERY
        - MARKET_REALTIME
      description: Service name identifier
    eventType:
      type: string
      pattern: ^(command|query|response|event)\.[a-zA-Z]+\.[a-zA-Z]+$
      description: 'Event type in format: {category}.{resource}.{action}'
      example: command.tradeOrder.submit
    tradeOrder:
      type: object
      properties:
        tradeOrderId:
          $ref: '#/components/schemas/uuidString'
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
        venue:
          $ref: '#/components/schemas/venue'
        positionId:
          $ref: '#/components/schemas/uuidString'
        instrumentId:
          $ref: '#/components/schemas/instrumentId'
        quoteId:
          $ref: '#/components/schemas/uuidString'
        baseAsset:
          type: string
          example: BTC
          description: Base asset in the trading pair
        quoteAsset:
          type: string
          example: USDT
          description: Quote asset in the trading pair
        orderSide:
          $ref: '#/components/schemas/orderSide'
        orderType:
          $ref: '#/components/schemas/orderType'
        timeInForce:
          $ref: '#/components/schemas/timeInForce'
        status:
          $ref: '#/components/schemas/orderStatus'
        rejectReason:
          $ref: '#/components/schemas/rejectReason'
        cancelReason:
          $ref: '#/components/schemas/cancelReason'
        limitPrice:
          $ref: '#/components/schemas/decimal'
        stopPrice:
          $ref: '#/components/schemas/decimal'
        quantity:
          $ref: '#/components/schemas/decimal'
          description: Requested order quantity in base asset
        orderQuantityType:
          $ref: '#/components/schemas/orderQuantityType'
        quantityRounding:
          $ref: '#/components/schemas/quantityRounding'
        executedPrice:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: Weighted average executed price across all venues
        executedQuantity:
          $ref: '#/components/schemas/decimal'
          description: Total executed quantity across all venues (base asset)
        executedCost:
          $ref: '#/components/schemas/decimal'
          description: Total cost across all venues (quote asset)
        fees:
          type: array
          items:
            $ref: '#/components/schemas/securityQuantity'
          description: Aggregated fees across all executions
        executions:
          type: array
          items:
            $ref: '#/components/schemas/tradeExecution'
          description: Detailed breakdown of executions across different venues
        createdAt:
          $ref: '#/components/schemas/millisecond'
          description: Creation timestamp in milliseconds
        createdAtDateTime:
          type: string
          format: date-time
          description: Creation timestamp in ISO 8601 format
        updatedAt:
          $ref: '#/components/schemas/millisecond'
          description: Last update timestamp in milliseconds
        updatedAtDateTime:
          type: string
          format: date-time
          description: Last update timestamp in ISO 8601 format
        expireAt:
          $ref: '#/components/schemas/millisecond'
          description: Expiration timestamp in milliseconds
        expireAtDateTime:
          type: string
          format: date-time
          description: Expiration timestamp in ISO 8601 format
        canceledAt:
          $ref: '#/components/schemas/millisecond'
          description: Cancellation timestamp in milliseconds
        canceledAtDateTime:
          type: string
          format: date-time
          description: Cancellation timestamp in ISO 8601 format
      required:
        - tradeOrderId
        - tradingAccountId
        - venue
        - instrumentId
        - baseAsset
        - quoteAsset
        - orderSide
        - orderType
        - timeInForce
        - status
        - quantity
        - orderQuantityType
        - executedPrice
        - executedQuantity
        - executedCost
        - cost
        - filled
        - fees
        - createdAt
        - updatedAt
    financialSecurity:
      type: object
      properties:
        securityId:
          type: string
          description: Security ID, id in the format of venue:symbol
          example: BINANCE:BTC
        symbol:
          type: string
          description: Symbol
          example: BTC
        venue:
          $ref: '#/components/schemas/venue'
        securityType:
          $ref: '#/components/schemas/securityType'
        precision:
          type: integer
          description: Precision
          example: 8
        scale:
          type: integer
          description: Scale
          example: 10
        minQuantity:
          $ref: '#/components/schemas/decimal'
          description: Minimum quantity
        lotSize:
          $ref: '#/components/schemas/decimal'
          description: Round lot
    instrument:
      type: object
      properties:
        instrumentId:
          $ref: '#/components/schemas/instrumentId'
        venue:
          $ref: '#/components/schemas/venue'
        symbol:
          type: string
          example: BTC/USD
          description: Human-readable symbol format
        externalSymbol:
          type: string
          example: BTCUSDT
          description: Symbol format used by the exchange
        description:
          type: string
          description: Symbol description, human readable description of the instrument
        instrumentType:
          $ref: '#/components/schemas/instrumentType'
        status:
          $ref: '#/components/schemas/instrumentStatus'
        baseAsset:
          type: string
          example: BTC
        quoteAsset:
          type: string
          example: USD
        baseSecurityType:
          $ref: '#/components/schemas/securityType'
          description: Base asset security type
        quoteSecurityType:
          $ref: '#/components/schemas/securityType'
          description: Quote asset security type
        basePrecision:
          type: integer
          description: Base asset precision
        quotePrecision:
          type: integer
          description: Quote asset precision
        baseMaxSignificant:
          type: integer
          description: Maximum significant digits for base asset
          nullable: true
        quoteMaxSignificant:
          type: integer
          description: Maximum significant digits for quote asset
          nullable: true
        lotSize:
          $ref: '#/components/schemas/decimal'
          description: Minimum quantity increment
          nullable: true
        pipSize:
          $ref: '#/components/schemas/decimal'
          description: Minimum price increment
          nullable: true
        baseScale:
          type: integer
          description: Base asset scale factor
          nullable: true
        quoteScale:
          type: integer
          description: Quote asset scale factor
          nullable: true
        minQuantity:
          $ref: '#/components/schemas/decimal'
          nullable: true
        maxQuantity:
          $ref: '#/components/schemas/decimal'
          nullable: true
        minNotional:
          $ref: '#/components/schemas/decimal'
          description: Minimum notional value for orders
          nullable: true
        maxNotional:
          $ref: '#/components/schemas/decimal'
          description: Maximum notional value for orders
          nullable: true
        orderFilters:
          type: object
          description: Exchange-specific order filters
        orderTypes:
          type: array
          items:
            $ref: '#/components/schemas/orderType'
        timeInForceOptions:
          type: array
          items:
            $ref: '#/components/schemas/timeInForce'
        tradingHours:
          type: object
          description: Trading hours and schedule information
        isIcebergAllowed:
          type: boolean
          description: Whether iceberg orders are allowed
        icebergMinQuantity:
          $ref: '#/components/schemas/decimal'
          description: Minimum quantity for iceberg orders
        deliveryDate:
          $ref: '#/components/schemas/millisecond'
          description: Delivery date timestamp in milliseconds for derivatives
        deliveryDateTime:
          type: string
          format: date-time
          description: Delivery date in ISO 8601 format for derivatives
        exerciseStyle:
          type: string
          enum:
            - EUROPEAN
            - AMERICAN
          description: Exercise style for options
        strikePrice:
          $ref: '#/components/schemas/decimal'
          description: Strike price for options
      required:
        - instrumentId
        - venue
        - symbol
        - externalSymbol
        - instrumentType
        - status
        - baseAsset
        - quoteAsset
        - baseSecurityType
        - quoteSecurityType
        - basePrecision
        - quotePrecision
        - baseMaxSignificant
        - quoteMaxSignificant
        - lotSize
        - pipSize
        - baseScale
        - quoteScale
        - minQuantity
        - maxQuantity
        - minNotional
        - orderTypes
        - timeInForceOptions
    tradingAccountCredential:
      type: object
      properties:
        credentialId:
          $ref: '#/components/schemas/uuidString'
        venue:
          $ref: '#/components/schemas/venue'
        credentialType:
          $ref: '#/components/schemas/credentialType'
        nickname:
          type: string
          example: api_key_for_binance
        status:
          $ref: '#/components/schemas/tradingAccountCredentialStatus'
        createdAt:
          $ref: '#/components/schemas/millisecond'
          description: Creation timestamp in milliseconds
        createdAtDateTime:
          type: string
          format: date-time
          description: Creation timestamp in ISO 8601 format
        updatedAt:
          $ref: '#/components/schemas/millisecond'
          description: Last update timestamp in milliseconds
        updatedAtDateTime:
          type: string
          format: date-time
          description: Last update timestamp in ISO 8601 format
        revokedAt:
          $ref: '#/components/schemas/millisecond'
          description: Revocation timestamp in milliseconds
        revokedAtDateTime:
          type: string
          format: date-time
          description: Revocation timestamp in ISO 8601 format
      required:
        - credentialId
        - venue
        - credentialType
        - status
        - createdAt
        - updatedAt
    tradingAccount:
      type: object
      properties:
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
        externalTradingAccountId:
          type: string
          description: External trading account ID
        venue:
          $ref: '#/components/schemas/venue'
        nickname:
          type: string
          description: Nickname of the trading account
        accountType:
          $ref: '#/components/schemas/accountType'
        externalAccountType:
          type: string
          description: Type of account on the exchange (set by market connector)
        positionMode:
          $ref: '#/components/schemas/positionMode'
        collateralMode:
          $ref: '#/components/schemas/collateralMode'
        marginMode:
          $ref: '#/components/schemas/marginMode'
        credentials:
          type: array
          items:
            $ref: '#/components/schemas/tradingAccountCredential'
        status:
          $ref: '#/components/schemas/tradingAccountStatus'
        createdAt:
          $ref: '#/components/schemas/millisecond'
          description: Creation timestamp in milliseconds
        createdAtDateTime:
          type: string
          format: date-time
          description: Creation timestamp in ISO 8601 format
        updatedAt:
          $ref: '#/components/schemas/millisecond'
          description: Last update timestamp in milliseconds
        updatedAtDateTime:
          type: string
          format: date-time
          description: Last update timestamp in ISO 8601 format
      required:
        - tradingAccountId
        - externalTradingAccountId
        - venue
        - nickname
        - accountType
        - externalAccountType
        - credentials
        - status
        - createdAt
        - updatedAt
    portfolio:
      type: object
      properties:
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
        venue:
          $ref: '#/components/schemas/venue'
        positions:
          type: array
          items:
            $ref: '#/components/schemas/positionEntry'
        balances:
          type: array
          items:
            $ref: '#/components/schemas/balanceEntry'
        summary:
          $ref: '#/components/schemas/portfolioSummary'
        updatedAt:
          $ref: '#/components/schemas/millisecond'
          description: Last update timestamp in milliseconds
        updatedAtDateTime:
          type: string
          format: date-time
          description: Last update timestamp in ISO 8601 format
      required:
        - tradingAccountId
        - venue
        - positions
        - balances
        - summary
        - updatedAt
    positionEntry:
      type: object
      properties:
        positionId:
          $ref: '#/components/schemas/uuidString'
        securitySymbol:
          type: string
          example: BTC
          description: Security symbol
        externalPositionId:
          type: string
          nullable: true
          description: External position ID from the exchange
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
        instrumentId:
          $ref: '#/components/schemas/instrumentId'
          nullable: true
          description: Associated instrument ID, for calculating market price
        securityType:
          $ref: '#/components/schemas/securityType'
        status:
          $ref: '#/components/schemas/positionStatus'
        quantity:
          $ref: '#/components/schemas/decimal'
        entryPrice:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: Entry price
        exitPrice:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: Exit price
        currentPrice:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: Current market price
        unrealizedPnl:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: Unrealized profit and loss
        realizedPnl:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: Realized profit and loss
        createdAt:
          $ref: '#/components/schemas/millisecond'
          description: Creation timestamp in milliseconds
        createdAtDateTime:
          type: string
          format: date-time
          description: Creation timestamp in ISO 8601 format
        updatedAt:
          $ref: '#/components/schemas/millisecond'
          description: Last update timestamp in milliseconds
        updatedAtDateTime:
          type: string
          format: date-time
          description: Last update timestamp in ISO 8601 format
        closedAt:
          $ref: '#/components/schemas/millisecond'
          nullable: true
          description: Position closure timestamp in milliseconds
        closedAtDateTime:
          type: string
          format: date-time
          nullable: true
          description: Position closure timestamp in ISO 8601 format
      required:
        - positionId
        - securitySymbol
        - tradingAccountId
        - securityType
        - status
        - quantity
        - createdAt
        - updatedAt
    balanceEntry:
      type: object
      properties:
        securitySymbol:
          type: string
          example: USDT
          description: Security symbol
        securityType:
          $ref: '#/components/schemas/securityType'
        externalBalanceId:
          type: string
          nullable: true
          description: External balance ID from the exchange
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
        status:
          $ref: '#/components/schemas/balanceStatus'
        positionId:
          $ref: '#/components/schemas/uuidString'
          nullable: true
          description: Linked position ID
        free:
          $ref: '#/components/schemas/decimal'
          description: Free balance available for trading
        locked:
          $ref: '#/components/schemas/decimal'
          description: Locked balance in open orders
        borrowed:
          $ref: '#/components/schemas/decimal'
          description: Borrowed amount
        total:
          $ref: '#/components/schemas/decimal'
          description: Total balance. total = free + locked
        net:
          $ref: '#/components/schemas/decimal'
          description: Net equity balance. net = free + locked - borrowed
        updatedAt:
          $ref: '#/components/schemas/millisecond'
          description: Last update timestamp in milliseconds
        updatedAtDateTime:
          type: string
          format: date-time
          description: Last update timestamp in ISO 8601 format
      required:
        - tradingAccountId
        - securitySymbol
        - securityType
        - status
        - free
        - locked
        - borrowed
        - total
        - net
        - updatedAt
    portfolioSummary:
      type: object
      properties:
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
        currency:
          type: string
          description: Base currency for the portfolio summary
          example: USDT
        leverage:
          type: integer
          nullable: true
          description: Leverage multiplier
        equity:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: The amount of equity held in the account
        margin:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: The amount of collateral in the account
        marginLoan:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: The amount of credit borrowed
        marginUsage:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: The rate of margin requirement / margin
        marginRequirement:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: The amount of collateral required to maintain the current positions
        marginLevel:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: The rate of total equity / margin requirement
        credit:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: The amount of credit available
        riskExposure:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: Total value of positions
        maxRiskExposure:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: Maximum value of risk exposure
        riskExposureRate:
          $ref: '#/components/schemas/decimal'
          nullable: true
          description: RiskExposure / MaxRiskExposure
      required:
        - tradingAccountId
        - currency
        - leverage
        - equity
        - margin
        - marginLoan
        - marginUsage
        - marginRequirement
        - marginLevel
        - credit
        - riskExposure
    accountOperation:
      type: object
      properties:
        operationId:
          $ref: '#/components/schemas/uuidString'
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
        operationType:
          $ref: '#/components/schemas/operationType'
        status:
          $ref: '#/components/schemas/operationStatus'
        createdAt:
          $ref: '#/components/schemas/millisecond'
          description: Creation timestamp in milliseconds
        createdAtDateTime:
          type: string
          format: date-time
          description: Creation timestamp in ISO 8601 format
      required:
        - operationId
        - tradingAccountId
        - operationType
        - status
        - createdAt
    subscription:
      type: object
      properties:
        subscriptionId:
          $ref: '#/components/schemas/uuidString'
        venue:
          $ref: '#/components/schemas/venue'
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
        instrumentId:
          $ref: '#/components/schemas/instrumentId'
        subscriptionType:
          $ref: '#/components/schemas/subscriptionType'
        status:
          $ref: '#/components/schemas/subscriptionStatus'
        createdAt:
          $ref: '#/components/schemas/millisecond'
          description: Creation timestamp in milliseconds
        createdAtDateTime:
          type: string
          format: date-time
          description: Creation timestamp in ISO 8601 format
        updatedAt:
          $ref: '#/components/schemas/millisecond'
          description: Last update timestamp in milliseconds
        updatedAtDateTime:
          type: string
          format: date-time
          description: Last update timestamp in ISO 8601 format
        lastEventTimestamp:
          $ref: '#/components/schemas/millisecond'
      required:
        - subscriptionId
        - subscriptionType
        - venue
        - status
        - createdAt
        - updatedAt
    marketVenue:
      type: object
      properties:
        venue:
          $ref: '#/components/schemas/venue'
        status:
          $ref: '#/components/schemas/venueStatus'
      required:
        - venue
        - status
    orderbookEntry:
      type: array
      items:
        $ref: '#/components/schemas/decimal'
      minItems: 2
      maxItems: 2
      description: '[price, quantity]'
    orderbook:
      type: object
      properties:
        instrumentId:
          $ref: '#/components/schemas/instrumentId'
        venue:
          $ref: '#/components/schemas/venue'
        symbol:
          type: string
          example: BTC/USDT
        asks:
          type: array
          items:
            $ref: '#/components/schemas/orderbookEntry'
        bids:
          type: array
          items:
            $ref: '#/components/schemas/orderbookEntry'
        timestamp:
          $ref: '#/components/schemas/millisecond'
          description: Orderbook timestamp in milliseconds
      required:
        - venue
        - symbol
        - asks
        - bids
        - timestamp
    submitTradeOrderRequest:
      type: object
      properties:
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
        instrumentId:
          $ref: '#/components/schemas/instrumentId'
        idempotencyKey:
          $ref: '#/components/schemas/idempotencyKey'
        clientOrderId:
          $ref: '#/components/schemas/clientOrderId'
        orderSide:
          $ref: '#/components/schemas/orderSide'
        orderType:
          $ref: '#/components/schemas/orderType'
        limitPrice:
          $ref: '#/components/schemas/decimal'
        stopPrice:
          $ref: '#/components/schemas/decimal'
        quantity:
          $ref: '#/components/schemas/decimal'
        quantityType:
          $ref: '#/components/schemas/orderQuantityType'
        quantityRounding:
          $ref: '#/components/schemas/quantityRounding'
        positionId:
          $ref: '#/components/schemas/uuidString'
        timeInForce:
          $ref: '#/components/schemas/timeInForce'
        expireAt:
          $ref: '#/components/schemas/millisecond'
          description: Expire at, for GTD time in force
        quoteId:
          $ref: '#/components/schemas/uuidString'
        leverage:
          type: integer
          description: Leverage
        awaitClosed:
          type: boolean
          description: >
            If true, the API will wait up to 1 second for the order to reach a

            closed/finalized state (FILLED, REJECTED, EXPIRED, CANCELLED) before
            responding.

            If false or omitted, returns immediately with the initial order
            state.

            Useful for market orders that typically fill immediately.
          default: false
          example: true
      required:
        - tradingAccountId
        - instrumentId
        - orderSide
        - orderType
        - quantity
    cancelTradeOrderRequest:
      type: object
      properties:
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
          description: Trading account ID that owns the order (required for authorization)
        tradeOrderId:
          $ref: '#/components/schemas/uuidString'
      required:
        - tradingAccountId
        - tradeOrderId
    connectTradingAccountRequest:
      type: object
      properties:
        credentialIds:
          type: array
          items:
            $ref: '#/components/schemas/uuidString'
          description: A list of credential IDs to be used to connect the trading account
        externalTradingAccountId:
          type: string
          description: External trading account ID
        nickname:
          type: string
          description: Nickname of the trading account
      required:
        - credentialIds
        - externalTradingAccountId
    disconnectTradingAccountRequest:
      type: object
      properties:
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
      required:
        - tradingAccountId
    updateTradingAccountRequest:
      type: object
      properties:
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
        nickname:
          type: string
          description: New nickname for the trading account
      required:
        - tradingAccountId
    enableTradingAccountRequest:
      type: object
      properties:
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
      required:
        - tradingAccountId
    disableTradingAccountRequest:
      type: object
      properties:
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
      required:
        - tradingAccountId
    createTradingAccountCredentialRequest:
      type: object
      properties:
        venue:
          $ref: '#/components/schemas/venue'
        nickname:
          type: string
          description: Nickname of the credential
        credentialType:
          $ref: '#/components/schemas/credentialType'
        apiKey:
          type: string
          example: my_api_key
        apiSecret:
          type: string
          example: my_api_secret
        apiPassphrase:
          type: string
          example: my_api_passphrase
      required:
        - venue
        - credentialType
    revokeTradingAccountCredentialRequest:
      type: object
      properties:
        credentialId:
          $ref: '#/components/schemas/uuidString'
      required:
        - credentialId
    rotateTradingAccountCredentialRequest:
      type: object
      properties:
        credentialId:
          $ref: '#/components/schemas/uuidString'
        apiKey:
          type: string
          example: my_api_key
        apiSecret:
          type: string
          example: my_api_secret
        apiPassphrase:
          type: string
          example: my_api_passphrase
      required:
        - credentialId
        - apiKey
    verifyTradingAccountCredentialRequest:
      type: object
      properties:
        credentialIds:
          type: array
          items:
            $ref: '#/components/schemas/uuidString'
      required:
        - credentialIds
    subscribeTradingAccountRequest:
      type: object
      properties:
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
      required:
        - tradingAccountId
    subscribeMarketOrderBookRequest:
      type: object
      properties:
        instrumentId:
          $ref: '#/components/schemas/instrumentId'
      required:
        - instrumentId
    unsubscribeRequest:
      type: object
      properties:
        subscriptionId:
          $ref: '#/components/schemas/uuidString'
        tradingAccountId:
          $ref: '#/components/schemas/uuidString'
        instrumentId:
          $ref: '#/components/schemas/instrumentId'
    syncMarketInstrumentsRequest:
      type: object
      properties:
        venue:
          $ref: '#/components/schemas/venue'
        symbols:
          type: array
          items:
            type: string
          description: symbol list, example \["BTC/ETH","BTC/USDT"\]
      required:
        - venue
        - symbols
    syncMarketInstrumentsResponseData:
      type: object
      properties:
        total:
          type: integer
          description: Total number of instruments synced
          example: 100
      required:
        - total
    deleteMarketInstrumentRequest:
      type: object
      properties:
        instrumentId:
          $ref: '#/components/schemas/instrumentId'
      required:
        - instrumentId
    enableMarketInstrumentRequest:
      type: object
      properties:
        instrumentId:
          $ref: '#/components/schemas/instrumentId'
      required:
        - instrumentId
    disableMarketInstrumentRequest:
      type: object
      properties:
        instrumentId:
          $ref: '#/components/schemas/instrumentId'
      required:
        - instrumentId
    syncMarketSecuritiesRequest:
      type: object
      properties:
        venue:
          $ref: '#/components/schemas/venue'
      required:
        - venue
    deleteMarketSecurityRequest:
      type: object
      properties:
        securityId:
          type: string
          description: Security ID in the format of venue:symbol
          example: BINANCE:BTC
      required:
        - securityId
    wsMarketOrderBookSubscribe:
      type: object
      properties:
        action:
          type: string
          enum:
            - subscribe
        channel:
          type: string
          enum:
            - market.orderBook
        params:
          type: object
          properties:
            venue:
              $ref: '#/components/schemas/venue'
            symbol:
              type: string
              example: BTC/USDT
            depth:
              type: integer
              default: 20
          required:
            - venue
            - symbol
      required:
        - action
        - channel
        - params
    wsMarketOrderBookUnsubscribe:
      type: object
      properties:
        action:
          type: string
          enum:
            - unsubscribe
        channel:
          type: string
          enum:
            - market.orderBook
        params:
          type: object
          properties:
            subscriptionId:
              $ref: '#/components/schemas/uuidString'
          required:
            - subscriptionId
      required:
        - action
        - channel
        - params
    wsMarketOrderBookUpdate:
      type: object
      properties:
        channel:
          type: string
          enum:
            - market.orderBook
        data:
          $ref: '#/components/schemas/orderbook'
        subscriptionId:
          $ref: '#/components/schemas/uuidString'
        timestamp:
          $ref: '#/components/schemas/millisecond'
      required:
        - channel
        - data
        - subscriptionId
        - timestamp
    wsError:
      type: object
      description: WebSocket error object returned when a command fails
      properties:
        code:
          type: integer
          description: Error code
          example: 100
        message:
          type: string
          description: Error message
          example: invalid token
        temporary:
          type: boolean
          description: Whether the error is temporary and the command can be retried
          example: false
      required:
        - code
        - message
    wsClientInfo:
      type: object
      description: Information about a connected client
      properties:
        user:
          type: string
          description: User ID
          example: user-123
        client:
          type: string
          description: Client connection ID
          example: c7a8b9d0-1234-5678-9abc-def012345678
        connInfo:
          type: object
          description: Connection info set during authentication
          additionalProperties: true
        chanInfo:
          type: object
          description: Channel info set during subscription
          additionalProperties: true
    rpcMethod:
      type: string
      description: |
        RPC method name corresponding to event types in the system.
        Format: `{category}.{resource}.{action}`
        - `command.*` - Actions that modify state
        - `query.*` - Actions that read state
        - `response.*` - Server responses (used internally)
        - `event.*` - Push notifications for state changes
      enum:
        - query.system.info
        - response.system.info
        - query.system.check
        - response.system.check
        - command.trading_account.create
        - response.trading_account.create
        - command.trading_account.save
        - response.trading_account.save
        - command.trading_account.delete
        - response.trading_account.delete
        - command.trading_account.update
        - response.trading_account.update
        - command.trading_account.validate
        - response.trading_account.validate
        - command.trading_account.connect
        - response.trading_account.connect
        - command.trading_account.disconnect
        - response.trading_account.disconnect
        - command.trading_account.enable
        - response.trading_account.enable
        - command.trading_account.disable
        - response.trading_account.disable
        - query.trading_account.list
        - response.trading_account.list
        - query.trading_account.operation.list
        - response.trading_account.operation.list
        - event.trading_account.updated
        - event.trading_account.subscription.updated
        - command.trading_account.subscribe
        - response.trading_account.subscribe
        - command.trading_account.unsubscribe
        - response.trading_account.unsubscribe
        - query.trading_account.subscription.list
        - response.trading_account.subscription.list
        - command.credential.create
        - response.credential.create
        - command.credential.save
        - response.credential.save
        - query.credential.list
        - response.credential.list
        - command.credential.revoke
        - response.credential.revoke
        - command.credential.rotate
        - response.credential.rotate
        - command.credential.verify
        - response.credential.verify
        - event.credential.updated
        - command.trade_order.submit
        - response.trade_order.submit
        - command.trade_order.cancel
        - response.trade_order.cancel
        - command.trade_order.save
        - response.trade_order.save
        - query.trade_order.get
        - response.trade_order.get
        - query.trade_order.get_by_id
        - response.trade_order.get_by_id
        - query.trade_order.list
        - response.trade_order.list
        - event.trade_order.updated
        - query.portfolio.get
        - response.portfolio.get
        - query.portfolio.list
        - response.portfolio.list
        - command.portfolio.save
        - response.portfolio.save
        - event.portfolio.updated
        - command.instrument.sync
        - response.instrument.sync
        - command.instrument.save
        - response.instrument.save
        - query.instrument.list
        - response.instrument.list
        - command.instrument.delete
        - response.instrument.delete
        - command.instrument.enable
        - response.instrument.enable
        - command.instrument.disable
        - response.instrument.disable
        - event.instrument.updated
        - command.security.sync
        - response.security.sync
        - command.security.save
        - response.security.save
        - command.security.delete
        - response.security.delete
        - query.security.list
        - response.security.list
        - event.security.updated
        - query.venue.list
        - response.venue.list
        - query.orderbook.get
        - response.orderbook.get
        - query.orderbook.list
        - response.orderbook.list
        - command.orderbook.save
        - response.orderbook.save
        - event.orderbook.updated
        - command.kline.save
        - response.kline.save
        - query.kline.list
        - response.kline.list
        - command.ticker.save
        - response.ticker.save
        - query.ticker.list
        - response.ticker.list
        - command.market.subscription.orderbook.subscribe
        - response.market.subscription.orderbook.subscribe
        - command.market.subscription.orderbook.unsubscribe
        - response.market.subscription.orderbook.unsubscribe
        - query.market.subscription.orderbook.list
        - response.market.subscription.orderbook.list
        - command.subscription.create
        - response.subscription.create
        - query.subscription.list
        - response.subscription.list
        - event.subscription.updated
        - command.subscription.mc.create
        - response.subscription.mc.create
      example: command.trade_order.submit
    wsCommand:
      type: object
      description: >-
        WebSocket command sent from client to server. Only one command field
        should be set per message.
      properties:
        id:
          type: integer
          description: Unique command ID for request-response correlation
          example: 1
        connect:
          $ref: '#/components/schemas/wsConnectRequest'
        subscribe:
          $ref: '#/components/schemas/wsSubscribeRequest'
        unsubscribe:
          $ref: '#/components/schemas/wsUnsubscribeRequest'
        publish:
          $ref: '#/components/schemas/wsPublishRequest'
        presence:
          $ref: '#/components/schemas/wsPresenceRequest'
        presenceStats:
          $ref: '#/components/schemas/wsPresenceStatsRequest'
        history:
          $ref: '#/components/schemas/wsHistoryRequest'
        ping:
          $ref: '#/components/schemas/wsPingRequest'
        send:
          $ref: '#/components/schemas/wsSendRequest'
        rpc:
          $ref: '#/components/schemas/wsRPCRequest'
        refresh:
          $ref: '#/components/schemas/wsRefreshRequest'
        subRefresh:
          $ref: '#/components/schemas/wsSubRefreshRequest'
      required:
        - id
    wsReply:
      type: object
      description: >-
        WebSocket reply sent from server to client. The id field is zero for
        server-initiated pushes.
      properties:
        id:
          type: integer
          description: Command ID matching the request (0 for pushes)
          example: 1
        error:
          $ref: '#/components/schemas/wsError'
        push:
          $ref: '#/components/schemas/wsPush'
        connect:
          $ref: '#/components/schemas/wsConnectResult'
        subscribe:
          $ref: '#/components/schemas/wsSubscribeResult'
        unsubscribe:
          $ref: '#/components/schemas/wsUnsubscribeResult'
        publish:
          $ref: '#/components/schemas/wsPublishResult'
        presence:
          $ref: '#/components/schemas/wsPresenceResult'
        presenceStats:
          $ref: '#/components/schemas/wsPresenceStatsResult'
        history:
          $ref: '#/components/schemas/wsHistoryResult'
        ping:
          $ref: '#/components/schemas/wsPingResult'
        rpc:
          $ref: '#/components/schemas/wsRPCResult'
        refresh:
          $ref: '#/components/schemas/wsRefreshResult'
        subRefresh:
          $ref: '#/components/schemas/wsSubRefreshResult'
    wsConnectRequest:
      type: object
      description: Connect request sent after WebSocket connection is established
      properties:
        token:
          type: string
          description: JWT authentication token
          example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
        data:
          type: object
          description: Custom data to send with connect
          additionalProperties: true
        subs:
          type: object
          description: Initial subscriptions to establish on connect
          additionalProperties:
            $ref: '#/components/schemas/wsSubscribeRequest'
        name:
          type: string
          description: Client name for identification
          example: my-trading-client
        version:
          type: string
          description: Client version
          example: 1.0.0
      required:
        - token
    wsConnectResult:
      type: object
      description: Connect result from server
      properties:
        client:
          type: string
          description: Unique client ID assigned by server
          example: c7a8b9d0-1234-5678-9abc-def012345678
        version:
          type: string
          description: Server version
          example: 5.0.0
        expires:
          type: boolean
          description: Whether the connection expires
          example: false
        ttl:
          type: integer
          description: Time to live in seconds (0 = no expiry)
          example: 0
        data:
          type: object
          description: Custom data from server
          additionalProperties: true
        subs:
          type: object
          description: Results of initial subscriptions
          additionalProperties:
            $ref: '#/components/schemas/wsSubscribeResult'
        ping:
          type: integer
          description: Server ping interval in seconds
          example: 25
        pong:
          type: boolean
          description: Whether client should send pong responses
          example: true
        session:
          type: string
          description: Session ID
          example: session-xyz
        node:
          type: string
          description: Server node ID
          example: node-1
        time:
          type: integer
          format: int64
          description: Server time in milliseconds
          example: 1703052635110
    wsSubscribeRequest:
      type: object
      description: Subscribe to a channel for real-time updates
      properties:
        channel:
          type: string
          description: Channel name to subscribe to
          example: tradingAccount:acc-123
        token:
          type: string
          description: Subscription token (for private channels)
        recover:
          type: boolean
          description: Whether to recover missed messages
          example: false
        epoch:
          type: string
          description: Stream epoch for recovery
        offset:
          type: integer
          format: int64
          description: Stream offset for recovery
        data:
          type: object
          description: Custom subscription data
          additionalProperties: true
        positioned:
          type: boolean
          description: Whether to receive position info in publications
        recoverable:
          type: boolean
          description: Whether the subscription should be recoverable
        joinLeave:
          type: boolean
          description: Whether to receive join/leave messages
        delta:
          type: string
          description: Delta compression mode
      required:
        - channel
    wsSubscribeResult:
      type: object
      description: Subscribe result from server
      properties:
        expires:
          type: boolean
          description: Whether the subscription expires
        ttl:
          type: integer
          description: Time to live in seconds
        recoverable:
          type: boolean
          description: Whether missed messages can be recovered
        epoch:
          type: string
          description: Stream epoch
        publications:
          type: array
          description: Recovered publications (if recovery was requested)
          items:
            $ref: '#/components/schemas/wsPublication'
        recovered:
          type: boolean
          description: Whether recovery was successful
        offset:
          type: integer
          format: int64
          description: Current stream offset
        positioned:
          type: boolean
          description: Whether position info is enabled
        data:
          type: object
          description: Custom data from server
          additionalProperties: true
        delta:
          type: boolean
          description: Whether delta compression is enabled
    wsUnsubscribeRequest:
      type: object
      description: Unsubscribe from a channel
      properties:
        channel:
          type: string
          description: Channel name to unsubscribe from
          example: tradingAccount:acc-123
      required:
        - channel
    wsUnsubscribeResult:
      type: object
      description: Unsubscribe result (empty on success)
    wsPublishRequest:
      type: object
      description: Publish a message to a channel
      properties:
        channel:
          type: string
          description: Channel to publish to
          example: tradingAccount:acc-123
        data:
          type: object
          description: Message data to publish
          additionalProperties: true
      required:
        - channel
        - data
    wsPublishResult:
      type: object
      description: Publish result (empty on success)
    wsRPCRequest:
      type: object
      description: Remote procedure call request
      properties:
        method:
          $ref: '#/components/schemas/rpcMethod'
        data:
          description: RPC request payload. Schema depends on the method being called.
          oneOf:
            - $ref: '#/components/schemas/rpcGetSystemInfoParams'
            - $ref: '#/components/schemas/rpcHealthCheckParams'
            - $ref: '#/components/schemas/rpcSubmitTradeOrderParams'
            - $ref: '#/components/schemas/rpcCancelTradeOrderParams'
            - $ref: '#/components/schemas/rpcGetTradeOrderParams'
            - $ref: '#/components/schemas/rpcGetTradeOrderByIdParams'
            - $ref: '#/components/schemas/rpcListTradeOrdersParams'
            - $ref: '#/components/schemas/rpcSaveTradeOrderParams'
            - $ref: '#/components/schemas/rpcCreateTradingAccountParams'
            - $ref: '#/components/schemas/rpcSaveTradingAccountsParams'
            - $ref: '#/components/schemas/rpcUpdateTradingAccountParams'
            - $ref: '#/components/schemas/rpcDeleteTradingAccountParams'
            - $ref: '#/components/schemas/rpcValidateTradingAccountParams'
            - $ref: '#/components/schemas/rpcConnectTradingAccountParams'
            - $ref: '#/components/schemas/rpcDisconnectTradingAccountParams'
            - $ref: '#/components/schemas/rpcEnableTradingAccountParams'
            - $ref: '#/components/schemas/rpcDisableTradingAccountParams'
            - $ref: '#/components/schemas/rpcListTradingAccountsParams'
            - $ref: '#/components/schemas/rpcListTradingAccountOperationsParams'
            - $ref: '#/components/schemas/rpcSubscribeTradingAccountStreamParams'
            - $ref: '#/components/schemas/rpcUnsubscribeTradingAccountStreamParams'
            - $ref: '#/components/schemas/rpcListTradingAccountSubscriptionsParams'
            - $ref: '#/components/schemas/rpcCreateCredentialParams'
            - $ref: '#/components/schemas/rpcSaveCredentialParams'
            - $ref: '#/components/schemas/rpcListCredentialsParams'
            - $ref: '#/components/schemas/rpcVerifyCredentialParams'
            - $ref: '#/components/schemas/rpcRevokeCredentialParams'
            - $ref: '#/components/schemas/rpcRotateCredentialParams'
            - $ref: '#/components/schemas/rpcGetPortfolioParams'
            - $ref: '#/components/schemas/rpcListPortfoliosParams'
            - $ref: '#/components/schemas/rpcSavePortfolioParams'
            - $ref: '#/components/schemas/rpcSyncInstrumentsParams'
            - $ref: '#/components/schemas/rpcSaveInstrumentsParams'
            - $ref: '#/components/schemas/rpcListInstrumentsParams'
            - $ref: '#/components/schemas/rpcDeleteInstrumentParams'
            - $ref: '#/components/schemas/rpcEnableInstrumentParams'
            - $ref: '#/components/schemas/rpcDisableInstrumentParams'
            - $ref: '#/components/schemas/rpcSyncSecuritiesParams'
            - $ref: '#/components/schemas/rpcSaveSecuritiesParams'
            - $ref: '#/components/schemas/rpcDeleteSecuritiesParams'
            - $ref: '#/components/schemas/rpcListSecuritiesParams'
            - $ref: '#/components/schemas/rpcListVenuesParams'
            - $ref: '#/components/schemas/rpcGetOrderBookParams'
            - $ref: '#/components/schemas/rpcListOrderBooksParams'
            - $ref: '#/components/schemas/rpcSaveOrderBooksParams'
            - $ref: '#/components/schemas/rpcSubscribeOrderBookParams'
            - $ref: '#/components/schemas/rpcUnsubscribeOrderBookParams'
            - $ref: '#/components/schemas/rpcListOrderBookSubscriptionsParams'
            - $ref: '#/components/schemas/rpcSaveKlinesParams'
            - $ref: '#/components/schemas/rpcListKlinesParams'
            - $ref: '#/components/schemas/rpcSaveTickersParams'
            - $ref: '#/components/schemas/rpcListTickersParams'
            - $ref: '#/components/schemas/rpcCreateSubscriptionParams'
            - $ref: '#/components/schemas/rpcListSubscriptionsParams'
      required:
        - method
    wsRPCResult:
      type: object
      description: RPC result from server
      properties:
        data:
          description: RPC response payload. Schema depends on the method that was called.
          oneOf:
            - $ref: '#/components/schemas/rpcGetSystemInfoResult'
            - $ref: '#/components/schemas/rpcHealthCheckResult'
            - $ref: '#/components/schemas/rpcSubmitTradeOrderResult'
            - $ref: '#/components/schemas/rpcCancelTradeOrderResult'
            - $ref: '#/components/schemas/rpcGetTradeOrderResult'
            - $ref: '#/components/schemas/rpcGetTradeOrderByIdResult'
            - $ref: '#/components/schemas/rpcListTradeOrdersResult'
            - $ref: '#/components/schemas/rpcSaveTradeOrderResult'
            - $ref: '#/components/schemas/rpcCreateTradingAccountResult'
            - $ref: '#/components/schemas/rpcSaveTradingAccountsResult'
            - $ref: '#/components/schemas/rpcUpdateTradingAccountResult'
            - $ref: '#/components/schemas/rpcDeleteTradingAccountResult'
            - $ref: '#/components/schemas/rpcValidateTradingAccountResult'
            - $ref: '#/components/schemas/rpcConnectTradingAccountResult'
            - $ref: '#/components/schemas/rpcDisconnectTradingAccountResult'
            - $ref: '#/components/schemas/rpcEnableTradingAccountResult'
            - $ref: '#/components/schemas/rpcDisableTradingAccountResult'
            - $ref: '#/components/schemas/rpcListTradingAccountsResult'
            - $ref: '#/components/schemas/rpcListTradingAccountOperationsResult'
            - $ref: '#/components/schemas/rpcSubscribeTradingAccountStreamResult'
            - $ref: '#/components/schemas/rpcUnsubscribeTradingAccountStreamResult'
            - $ref: '#/components/schemas/rpcListTradingAccountSubscriptionsResult'
            - $ref: '#/components/schemas/rpcCreateCredentialResult'
            - $ref: '#/components/schemas/rpcSaveCredentialResult'
            - $ref: '#/components/schemas/rpcListCredentialsResult'
            - $ref: '#/components/schemas/rpcVerifyCredentialResult'
            - $ref: '#/components/schemas/rpcRevokeCredentialResult'
            - $ref: '#/components/schemas/rpcRotateCredentialResult'
            - $ref: '#/components/schemas/rpcGetPortfolioResult'
            - $ref: '#/components/schemas/rpcListPortfoliosResult'
            - $ref: '#/components/schemas/rpcSavePortfolioResult'
            - $ref: '#/components/schemas/rpcSyncInstrumentsResult'
            - $ref: '#/components/schemas/rpcSaveInstrumentsResult'
            - $ref: '#/components/schemas/rpcListInstrumentsResult'
            - $ref: '#/components/schemas/rpcDeleteInstrumentResult'
            - $ref: '#/components/schemas/rpcEnableInstrumentResult'
            - $ref: '#/components/schemas/rpcDisableInstrumentResult'
            - $ref: '#/components/schemas/rpcSyncSecuritiesResult'
            - $ref: '#/components/schemas/rpcSaveSecuritiesResult'
            - $ref: '#/components/schemas/rpcDeleteSecuritiesResult'
            - $ref: '#/components/schemas/rpcListSecuritiesResult'
            - $ref: '#/components/schemas/rpcListVenuesResult'
            - $ref: '#/components/schemas/rpcGetOrderBookResult'
            - $ref: '#/components/schemas/rpcListOrderBooksResult'
            - $ref: '#/components/schemas/rpcSaveOrderBooksResult'
            - $ref: '#/components/schemas/rpcSubscribeOrderBookResult'
            - $ref: '#/components/schemas/rpcUnsubscribeOrderBookResult'
            - $ref: '#/components/schemas/rpcListOrderBookSubscriptionsResult'
            - $ref: '#/components/schemas/rpcSaveKlinesResult'
            - $ref: '#/components/schemas/rpcListKlinesResult'
            - $ref: '#/components/schemas/rpcSaveTickersResult'
            - $ref: '#/components/schemas/rpcListTickersResult'
            - $ref: '#/components/schemas/rpcCreateSubscriptionResult'
            - $ref: '#/components/schemas/rpcListSubscriptionsResult'
    wsPresenceRequest:
      type: object
      description: Request presence information for a channel
      properties:
        channel:
          type: string
          description: Channel name
          example: tradingAccount:acc-123
      required:
        - channel
    wsPresenceResult:
      type: object
      description: Presence result containing connected clients
      properties:
        presence:
          type: object
          description: Map of client ID to client info
          additionalProperties:
            $ref: '#/components/schemas/wsClientInfo'
    wsPresenceStatsRequest:
      type: object
      description: Request presence statistics for a channel
      properties:
        channel:
          type: string
          description: Channel name
          example: tradingAccount:acc-123
      required:
        - channel
    wsPresenceStatsResult:
      type: object
      description: Presence statistics result
      properties:
        numClients:
          type: integer
          description: Number of connected clients
          example: 5
        numUsers:
          type: integer
          description: Number of unique users
          example: 3
    wsHistoryRequest:
      type: object
      description: Request publication history for a channel
      properties:
        channel:
          type: string
          description: Channel name
          example: market:orderBook:BINANCE:BTC/USDT
        limit:
          type: integer
          description: Maximum number of publications to return
          example: 100
        since:
          $ref: '#/components/schemas/wsStreamPosition'
        reverse:
          type: boolean
          description: Whether to return publications in reverse order
      required:
        - channel
    wsHistoryResult:
      type: object
      description: History result containing publications
      properties:
        publications:
          type: array
          items:
            $ref: '#/components/schemas/wsPublication'
        epoch:
          type: string
          description: Stream epoch
        offset:
          type: integer
          format: int64
          description: Current stream offset
    wsStreamPosition:
      type: object
      description: Stream position for history recovery
      properties:
        offset:
          type: integer
          format: int64
          description: Stream offset
        epoch:
          type: string
          description: Stream epoch
    wsPingRequest:
      type: object
      description: Ping request to keep connection alive
    wsPingResult:
      type: object
      description: Pong response
    wsSendRequest:
      type: object
      description: Send asynchronous message (no reply expected)
      properties:
        data:
          type: object
          description: Message data
          additionalProperties: true
    wsRefreshRequest:
      type: object
      description: Refresh connection credentials
      properties:
        token:
          type: string
          description: New JWT token
      required:
        - token
    wsRefreshResult:
      type: object
      description: Refresh result
      properties:
        client:
          type: string
          description: Client ID
        version:
          type: string
          description: Server version
        expires:
          type: boolean
          description: Whether connection expires
        ttl:
          type: integer
          description: New TTL in seconds
    wsSubRefreshRequest:
      type: object
      description: Refresh subscription credentials
      properties:
        channel:
          type: string
          description: Channel to refresh
        token:
          type: string
          description: New subscription token
      required:
        - channel
        - token
    wsSubRefreshResult:
      type: object
      description: Subscription refresh result
      properties:
        expires:
          type: boolean
          description: Whether subscription expires
        ttl:
          type: integer
          description: New TTL in seconds
    wsPush:
      type: object
      description: Server push message (asynchronous, id=0 in reply)
      properties:
        channel:
          type: string
          description: Channel the push is for
          example: tradingAccount:acc-123
        pub:
          $ref: '#/components/schemas/wsPublication'
        join:
          $ref: '#/components/schemas/wsJoin'
        leave:
          $ref: '#/components/schemas/wsLeave'
        unsubscribe:
          $ref: '#/components/schemas/wsUnsubscribePush'
        message:
          $ref: '#/components/schemas/wsMessage'
        subscribe:
          $ref: '#/components/schemas/wsSubscribePush'
        connect:
          $ref: '#/components/schemas/wsConnectPush'
        disconnect:
          $ref: '#/components/schemas/wsDisconnect'
        refresh:
          $ref: '#/components/schemas/wsRefreshPush'
    wsPublication:
      type: object
      description: Publication message containing channel data
      properties:
        data:
          type: object
          description: Publication payload
          additionalProperties: true
        info:
          $ref: '#/components/schemas/wsClientInfo'
        offset:
          type: integer
          format: int64
          description: Stream offset for recovery
        tags:
          type: object
          description: Publication tags
          additionalProperties:
            type: string
        delta:
          type: boolean
          description: Whether this is a delta update
        time:
          type: integer
          format: int64
          description: Publication time in milliseconds
        channel:
          type: string
          description: Channel name (for wildcard subscriptions)
    wsJoin:
      type: object
      description: Client join notification
      properties:
        info:
          $ref: '#/components/schemas/wsClientInfo'
    wsLeave:
      type: object
      description: Client leave notification
      properties:
        info:
          $ref: '#/components/schemas/wsClientInfo'
    wsUnsubscribePush:
      type: object
      description: Server-initiated unsubscribe notification
      properties:
        code:
          type: integer
          description: Unsubscribe reason code
        reason:
          type: string
          description: Unsubscribe reason message
    wsMessage:
      type: object
      description: Server message (not tied to a channel)
      properties:
        data:
          type: object
          description: Message data
          additionalProperties: true
    wsSubscribePush:
      type: object
      description: Server-initiated subscribe notification
      properties:
        recoverable:
          type: boolean
        epoch:
          type: string
        offset:
          type: integer
          format: int64
        positioned:
          type: boolean
        data:
          type: object
          additionalProperties: true
    wsConnectPush:
      type: object
      description: Server-initiated connect notification
      properties:
        client:
          type: string
        version:
          type: string
        data:
          type: object
          additionalProperties: true
    wsDisconnect:
      type: object
      description: Server-initiated disconnect notification
      properties:
        code:
          type: integer
          description: Disconnect reason code
          example: 3000
        reason:
          type: string
          description: Disconnect reason message
          example: connection expired
        reconnect:
          type: boolean
          description: Whether client should attempt to reconnect
          example: true
    wsRefreshPush:
      type: object
      description: Server-initiated refresh notification
      properties:
        expires:
          type: boolean
        ttl:
          type: integer
    rpcError:
      type: object
      description: RPC error response
      properties:
        code:
          type: integer
          description: Error code
          example: -111000
        message:
          type: string
          description: Error message
          example: Invalid order parameters
        temporary:
          type: boolean
          description: Whether the error is temporary and retryable
          example: false
      required:
        - code
        - message
    rpcPagination:
      type: object
      description: Pagination parameters and metadata
      properties:
        offset:
          type: integer
          description: Offset for pagination
          example: 0
        limit:
          type: integer
          description: Limit for pagination
          example: 50
        total:
          type: integer
          description: Total number of items
          example: 100
        cursor:
          type: string
          description: Cursor for next page
        hasNext:
          type: boolean
          description: Whether there are more items
          example: true
    rpcSubmitTradeOrderParams:
      type: object
      description: Request to submit a new trade order
      properties:
        tradeOrder:
          $ref: '#/components/schemas/rpcTradeOrder'
        tradingAccountId:
          type: string
          format: uuid
          description: Trading account ID to place order on
        idempotencyKey:
          type: string
          description: Idempotency key to prevent duplicate orders
        awaitClosed:
          type: boolean
          description: Wait for order to reach terminal state before responding
          default: false
      required:
        - tradeOrder
        - tradingAccountId
    rpcSubmitTradeOrderResult:
      type: object
      description: Response from submitting a trade order
      properties:
        data:
          $ref: '#/components/schemas/rpcTradeOrder'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcCancelTradeOrderParams:
      type: object
      description: Request to cancel an existing trade order
      properties:
        tradeOrderId:
          type: string
          format: uuid
          description: Trade order ID to cancel
        tradingAccountId:
          type: string
          format: uuid
          description: Trading account ID
        clientOrderId:
          type: string
          description: Client order ID (alternative to tradeOrderId)
        externalOrderId:
          type: string
          description: External order ID from venue
      required:
        - tradingAccountId
    rpcCancelTradeOrderResult:
      type: object
      description: Response from canceling a trade order
      properties:
        data:
          $ref: '#/components/schemas/rpcTradeOrder'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcGetTradeOrderParams:
      type: object
      description: Request to get a specific trade order
      properties:
        tradeOrderId:
          type: string
          format: uuid
          description: Trade order ID
        tradingAccountId:
          type: string
          format: uuid
          description: Trading account ID
        clientOrderId:
          type: string
          description: Client order ID
        externalOrderId:
          type: string
          description: External order ID
    rpcGetTradeOrderResult:
      type: object
      description: Response containing trade order details
      properties:
        data:
          $ref: '#/components/schemas/rpcTradeOrder'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcListTradeOrdersParams:
      type: object
      description: Request to list trade orders with filters
      properties:
        tradeOrderId:
          type: string
          format: uuid
          description: Filter by specific trade order ID
        tradingAccountId:
          type: string
          format: uuid
          description: Filter by trading account ID
        instrumentId:
          type: string
          description: Filter by instrument ID (e.g., BINANCE:BTC/USDT)
        side:
          $ref: '#/components/schemas/orderSide'
        orderType:
          $ref: '#/components/schemas/orderType'
        status:
          $ref: '#/components/schemas/orderStatus'
        startTime:
          type: string
          format: date-time
          description: Filter orders created after this time
        endTime:
          type: string
          format: date-time
          description: Filter orders created before this time
        pagination:
          $ref: '#/components/schemas/rpcPagination'
    rpcListTradeOrdersResult:
      type: object
      description: Response containing list of trade orders
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcTradeOrder'
        pagination:
          $ref: '#/components/schemas/rpcPagination'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcTradeOrder:
      type: object
      description: Trade order model
      properties:
        tradeOrderId:
          type: string
          format: uuid
          description: Unique trade order ID
        clientOrderId:
          type: string
          description: Client-assigned order ID
        originalClientOrderId:
          type: string
          description: Original client order ID (for cancel/replace)
        externalOrderId:
          type: string
          description: Order ID from external venue
        idempotencyKey:
          type: string
          description: Idempotency key
        venue:
          type: string
          description: Trading venue
          example: BINANCE
        tradingAccountId:
          type: string
          format: uuid
          description: Trading account ID
        externalTradingAccountId:
          type: string
          description: External account ID at venue
        instrumentId:
          type: string
          description: Instrument ID (VENUE:BASE/QUOTE)
          example: BINANCE:BTC/USDT
        externalSymbol:
          type: string
          description: Symbol at external venue
          example: BTCUSDT
        baseAsset:
          type: string
          description: Base asset
          example: BTC
        quoteAsset:
          type: string
          description: Quote asset
          example: USDT
        orderType:
          $ref: '#/components/schemas/orderType'
        orderSide:
          $ref: '#/components/schemas/orderSide'
        quantityType:
          $ref: '#/components/schemas/quantityType'
        quantity:
          type: string
          description: Order quantity (decimal string)
          example: '1.5'
        quoteCurrencyQuantity:
          type: string
          description: Quantity in quote currency
        positionPercentage:
          type: string
          description: Quantity as position percentage
        quantityRounding:
          $ref: '#/components/schemas/quantityRounding'
        limitPrice:
          type: string
          description: Limit price (decimal string)
          example: '50000.00'
        stopPrice:
          type: string
          description: Stop price (decimal string)
        timeInForce:
          $ref: '#/components/schemas/timeInForce'
        status:
          $ref: '#/components/schemas/orderStatus'
        executedPrice:
          type: string
          description: Average executed price
        executedPercentage:
          type: string
          description: Percentage of order filled
        executedQuantity:
          type: string
          description: Quantity executed
        executedCost:
          type: string
          description: Total cost in quote currency
        fees:
          type: array
          description: Fees charged
          items:
            $ref: '#/components/schemas/rpcSecurityQuantity'
        cancelReason:
          type: string
          description: Reason for cancellation
        rejectReason:
          type: string
          description: Reason for rejection
        createdAt:
          type: string
          format: date-time
          description: Order creation time
        updatedAt:
          type: string
          format: date-time
          description: Last update time
        expireAt:
          type: string
          format: date-time
          description: Order expiration time (for GTD)
        lastExecutionAt:
          type: string
          format: date-time
          description: Time of last execution
        canceledAt:
          type: string
          format: date-time
          description: Time of cancellation
    rpcSecurityQuantity:
      type: object
      description: Asset quantity pair
      properties:
        asset:
          type: string
          description: Asset symbol
          example: BTC
        quantity:
          type: string
          description: Quantity (decimal string)
          example: '0.001'
    rpcListTradingAccountsParams:
      type: object
      description: Request to list trading accounts
      properties:
        tradingAccountId:
          type: string
          format: uuid
          description: Filter by specific account ID
        venue:
          type: string
          description: Filter by venue
        status:
          $ref: '#/components/schemas/tradingAccountStatus'
        pagination:
          $ref: '#/components/schemas/rpcPagination'
    rpcListTradingAccountsResult:
      type: object
      description: Response containing list of trading accounts
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcTradingAccount'
        pagination:
          $ref: '#/components/schemas/rpcPagination'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcConnectTradingAccountParams:
      type: object
      description: Request to connect a trading account
      properties:
        tradingAccount:
          $ref: '#/components/schemas/rpcTradingAccount'
      required:
        - tradingAccount
    rpcConnectTradingAccountResult:
      type: object
      description: Response from connecting a trading account
      properties:
        data:
          $ref: '#/components/schemas/rpcTradingAccount'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcDisconnectTradingAccountParams:
      type: object
      description: Request to disconnect a trading account
      properties:
        tradingAccountId:
          type: string
          format: uuid
          description: Trading account ID to disconnect
      required:
        - tradingAccountId
    rpcDisconnectTradingAccountResult:
      type: object
      description: Response from disconnecting a trading account
      properties:
        data:
          $ref: '#/components/schemas/rpcTradingAccount'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcEnableTradingAccountParams:
      type: object
      description: Request to enable a trading account
      properties:
        tradingAccountId:
          type: string
          format: uuid
      required:
        - tradingAccountId
    rpcEnableTradingAccountResult:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/rpcTradingAccount'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcDisableTradingAccountParams:
      type: object
      description: Request to disable a trading account
      properties:
        tradingAccountId:
          type: string
          format: uuid
      required:
        - tradingAccountId
    rpcDisableTradingAccountResult:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/rpcTradingAccount'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcTradingAccount:
      type: object
      description: Trading account model
      properties:
        tradingAccountId:
          type: string
          format: uuid
          description: Unique trading account ID
        userId:
          type: string
          format: uuid
          description: User ID
        tenantId:
          type: string
          description: Tenant identifier for multi-tenancy
        nickname:
          type: string
          description: Account nickname
          example: My Binance Account
        externalAccountId:
          type: string
          description: External account ID at venue
        venue:
          $ref: '#/components/schemas/venue'
        status:
          $ref: '#/components/schemas/tradingAccountStatus'
        accountType:
          $ref: '#/components/schemas/tradingAccountType'
        externalAccountType:
          type: string
          description: Type of account on the exchange (set by market connector)
        positionMode:
          $ref: '#/components/schemas/positionMode'
        collateralMode:
          $ref: '#/components/schemas/collateralMode'
        marginMode:
          $ref: '#/components/schemas/marginMode'
        credentials:
          type: array
          description: Account credentials
          items:
            $ref: '#/components/schemas/rpcTradingAccountCredential'
        config:
          $ref: '#/components/schemas/rpcTradingAccountConfig'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    rpcTradingAccountCredential:
      type: object
      description: Trading account credential
      properties:
        credentialId:
          type: string
          format: uuid
        nickname:
          type: string
        credentialType:
          $ref: '#/components/schemas/credentialType'
        status:
          $ref: '#/components/schemas/credentialStatus'
        venue:
          $ref: '#/components/schemas/venue'
        apiKey:
          type: string
          description: API key (only in responses where withSecret=true)
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        revokedAt:
          type: string
          format: date-time
        withInfo:
          type: boolean
          description: Whether metadata fields are populated
        withSecret:
          type: boolean
          description: Whether secret fields are populated
    rpcTradingAccountConfig:
      type: object
      description: Trading account configuration
      properties:
        leverage:
          type: integer
          description: Account leverage
    rpcGetPortfolioParams:
      type: object
      description: Request to get portfolio for a trading account
      properties:
        tradingAccountId:
          type: string
          format: uuid
          description: Trading account ID
      required:
        - tradingAccountId
    rpcGetPortfolioResult:
      type: object
      description: Response containing portfolio
      properties:
        data:
          $ref: '#/components/schemas/rpcPortfolio'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcListPortfoliosParams:
      type: object
      description: Request to list portfolios
      properties:
        tradingAccountId:
          type: string
          format: uuid
          description: Filter by trading account ID
        venue:
          type: string
          description: Filter by venue
        currency:
          type: string
          description: Filter by currency
        pagination:
          $ref: '#/components/schemas/rpcPagination'
    rpcListPortfoliosResult:
      type: object
      description: Response containing list of portfolios
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcPortfolio'
        pagination:
          $ref: '#/components/schemas/rpcPagination'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcPortfolio:
      type: object
      description: Portfolio model containing balances and positions
      properties:
        tradingAccountId:
          type: string
          format: uuid
        accountInfo:
          $ref: '#/components/schemas/rpcTradingAccount'
        balances:
          type: array
          items:
            $ref: '#/components/schemas/rpcBalanceEntry'
        positions:
          type: array
          items:
            $ref: '#/components/schemas/rpcPositionEntry'
        summary:
          $ref: '#/components/schemas/rpcPortfolioSummary'
        updateMode:
          $ref: '#/components/schemas/updateMode'
        updatedAt:
          type: string
          format: date-time
    rpcBalanceEntry:
      type: object
      description: Balance entry for an asset
      properties:
        balanceId:
          type: string
          format: uuid
        externalBalanceId:
          type: string
        tradingAccountId:
          type: string
          format: uuid
        securitySymbol:
          type: string
          description: Asset symbol
          example: BTC
        securityType:
          $ref: '#/components/schemas/securityType'
        status:
          $ref: '#/components/schemas/balanceStatus'
        free:
          type: string
          description: Available balance
        locked:
          type: string
          description: Locked balance
        frozen:
          type: string
          description: Frozen balance
        borrowed:
          type: string
          description: Borrowed amount
        interestOwed:
          type: string
          description: Interest owed
        total:
          type: string
          description: Total balance
        net:
          type: string
          description: Net equity
        collateralWeight:
          type: string
        collateralValue:
          type: string
        collateralEnabled:
          type: boolean
        crossMargin:
          type: string
        isolatedMargin:
          type: string
        marginRatio:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    rpcPositionEntry:
      type: object
      description: Position entry for an instrument
      properties:
        positionId:
          type: string
          format: uuid
        externalPositionId:
          type: string
        tradingAccountId:
          type: string
          format: uuid
        securitySymbol:
          type: string
        instrumentId:
          type: string
          description: Instrument ID
        securityType:
          $ref: '#/components/schemas/securityType'
        status:
          $ref: '#/components/schemas/positionStatus'
        quantity:
          type: string
          description: Position quantity
        entryPrice:
          type: string
        exitPrice:
          type: string
        currentPrice:
          type: string
        unrealizedPnl:
          type: string
        realizedPnl:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    rpcPortfolioSummary:
      type: object
      description: Portfolio summary with aggregated metrics
      properties:
        portfolioSummaryId:
          type: string
          format: uuid
        tradingAccountId:
          type: string
          format: uuid
        currency:
          type: string
          description: Summary currency
          example: USDT
        leverage:
          type: integer
        equity:
          type: string
          description: Total equity
        margin:
          type: string
          description: Margin collateral
        marginLoan:
          type: string
          description: Borrowed margin
        marginUsage:
          type: string
          description: Margin usage rate
        marginRequirement:
          type: string
          description: Required margin
        marginLevel:
          type: string
          description: Margin level
        credit:
          type: string
          description: Available credit
        riskExposure:
          type: string
          description: Total risk exposure
        maxRiskExposure:
          type: string
          description: Maximum risk exposure
        riskExposureRate:
          type: string
          description: Risk exposure rate
    rpcGetOrderBookParams:
      type: object
      description: Request to get order book for an instrument
      properties:
        instrumentId:
          type: string
          description: Instrument ID (e.g., BINANCE:BTC/USDT)
        venue:
          type: string
          description: Venue (alternative to instrumentId)
        symbol:
          type: string
          description: Symbol (alternative to instrumentId)
        depth:
          type: integer
          description: Order book depth
          default: 10
    rpcGetOrderBookResult:
      type: object
      description: Response containing order book
      properties:
        data:
          $ref: '#/components/schemas/rpcOrderBook'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcListOrderBooksParams:
      type: object
      description: Request to list order books for multiple instruments
      properties:
        instrumentIds:
          type: array
          items:
            type: string
          description: List of instrument IDs
        venue:
          type: string
          description: Filter by venue
        symbols:
          type: array
          items:
            type: string
          description: List of symbols
        depth:
          type: integer
          description: Order book depth
          default: 10
    rpcListOrderBooksResult:
      type: object
      description: Response containing list of order books
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcOrderBook'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcSubscribeOrderBookParams:
      type: object
      description: Request to subscribe to order book updates
      properties:
        instrumentIds:
          type: array
          items:
            type: string
          description: List of instrument IDs to subscribe
        venue:
          type: string
          description: Venue for symbols
        symbols:
          type: array
          items:
            type: string
          description: List of symbols to subscribe
    rpcSubscribeOrderBookResult:
      type: object
      description: Response from order book subscription
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcSubscription'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcUnsubscribeOrderBookParams:
      type: object
      description: Request to unsubscribe from order book updates
      properties:
        subscriptionId:
          type: string
          format: uuid
          description: Subscription ID to cancel
        instrumentId:
          type: string
          description: Instrument ID to unsubscribe
    rpcUnsubscribeOrderBookResult:
      type: object
      description: Response from order book unsubscription
      properties:
        data:
          $ref: '#/components/schemas/rpcSubscription'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcOrderBook:
      type: object
      description: Order book model
      properties:
        instrumentId:
          type: string
          description: Instrument ID
          example: BINANCE:BTC/USDT
        venue:
          type: string
          description: Venue
        symbol:
          type: string
          description: Trading pair symbol
        bids:
          type: array
          description: Bid orders (sorted by price descending)
          items:
            $ref: '#/components/schemas/rpcOrderBookLevel'
        asks:
          type: array
          description: Ask orders (sorted by price ascending)
          items:
            $ref: '#/components/schemas/rpcOrderBookLevel'
        timestamp:
          $ref: '#/components/schemas/isoTimestamp'
          description: Order book timestamp in ISO 8601 format
        sequenceNumber:
          type: integer
          format: int64
          description: Sequence number for ordering updates
    rpcOrderBookLevel:
      type: object
      description: Single price level in order book
      properties:
        price:
          type: string
          description: Price level
          example: '50000.00'
        quantity:
          type: string
          description: Quantity at this price
          example: '1.5'
    rpcSubscription:
      type: object
      description: Subscription model
      properties:
        subscriptionId:
          type: string
          format: uuid
        instrumentId:
          type: string
        venue:
          $ref: '#/components/schemas/venue'
        subscriptionType:
          $ref: '#/components/schemas/subscriptionType'
        status:
          $ref: '#/components/schemas/subscriptionStatus'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    rpcTradeOrderUpdatedEvent:
      type: object
      description: Trade order update event (pushed via WebSocket)
      properties:
        data:
          $ref: '#/components/schemas/rpcTradeOrder'
    rpcPortfolioUpdatedEvent:
      type: object
      description: Portfolio update event (pushed via WebSocket)
      properties:
        data:
          $ref: '#/components/schemas/rpcPortfolio'
    rpcOrderBookUpdatedEvent:
      type: object
      description: Order book update event (pushed via WebSocket)
      properties:
        data:
          $ref: '#/components/schemas/rpcOrderBook'
    rpcGetSystemInfoParams:
      type: object
      description: Request to get system information
      properties: {}
    rpcGetSystemInfoResult:
      type: object
      description: System information response
      properties:
        data:
          $ref: '#/components/schemas/rpcSystemInfo'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcSystemInfo:
      type: object
      description: System information (same as REST /api/v3 root endpoint)
      properties:
        name:
          type: string
          description: API name
          example: Algo724 Cadenza Fermata API
        version:
          type: string
          description: API version
          example: 3.0.1
        description:
          type: string
          description: API description
          example: >-
            Unified trading platform for connecting to multiple venues,
            executing orders, and accessing real-time market data
        documentation:
          type: string
          description: API documentation URL
          example: https://docs.algo724.com/api/v3
    rpcHealthCheckParams:
      type: object
      description: Request to check system health
      properties: {}
    rpcHealthCheckResult:
      type: object
      description: Health check response
      properties:
        data:
          $ref: '#/components/schemas/rpcHealthCheck'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcHealthCheck:
      type: object
      description: Health check data
      properties:
        status:
          $ref: '#/components/schemas/healthStatus'
        timestamp:
          $ref: '#/components/schemas/isoTimestamp'
          description: Health check timestamp in ISO 8601 format
        version:
          type: string
          description: API version
          example: 3.0.1
        checks:
          type: object
          description: Health status of individual components
          properties:
            database:
              $ref: '#/components/schemas/healthCheckComponent'
            temporal:
              $ref: '#/components/schemas/healthCheckComponent'
            redis:
              $ref: '#/components/schemas/healthCheckComponent'
      required:
        - status
        - timestamp
        - version
    rpcCreateTradingAccountParams:
      type: object
      description: Request to create a trading account
      properties:
        tradingAccount:
          $ref: '#/components/schemas/rpcTradingAccount'
      required:
        - tradingAccount
    rpcCreateTradingAccountResult:
      type: object
      description: Response for trading account creation
      properties:
        data:
          $ref: '#/components/schemas/rpcTradingAccount'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcSaveTradingAccountsParams:
      type: object
      description: Request to save multiple trading accounts
      properties:
        tradingAccounts:
          type: array
          items:
            $ref: '#/components/schemas/rpcTradingAccount'
      required:
        - tradingAccounts
    rpcSaveTradingAccountsResult:
      type: object
      description: Response for saving trading accounts
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcTradingAccount'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcUpdateTradingAccountParams:
      type: object
      description: Request to update a trading account
      properties:
        tradingAccount:
          $ref: '#/components/schemas/rpcTradingAccount'
      required:
        - tradingAccount
    rpcUpdateTradingAccountResult:
      type: object
      description: Response for trading account update
      properties:
        data:
          $ref: '#/components/schemas/rpcTradingAccount'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcDeleteTradingAccountParams:
      type: object
      description: Request to delete a trading account
      properties:
        tradingAccountId:
          type: string
          format: uuid
      required:
        - tradingAccountId
    rpcDeleteTradingAccountResult:
      type: object
      description: Response for trading account deletion
      properties:
        data:
          $ref: '#/components/schemas/rpcTradingAccount'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcValidateTradingAccountParams:
      type: object
      description: Request to validate a trading account
      properties:
        tradingAccount:
          $ref: '#/components/schemas/rpcTradingAccount'
      required:
        - tradingAccount
    rpcValidateTradingAccountResult:
      type: object
      description: Response for trading account validation
      properties:
        data:
          type: object
          properties:
            isValid:
              type: boolean
        error:
          $ref: '#/components/schemas/rpcError'
    rpcListTradingAccountOperationsParams:
      type: object
      description: Request to list trading account operations
      properties:
        tradingAccountId:
          type: string
          format: uuid
        pagination:
          $ref: '#/components/schemas/rpcPagination'
      required:
        - tradingAccountId
    rpcListTradingAccountOperationsResult:
      type: object
      description: Response for listing trading account operations
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcTradingAccountOperationHistory'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcTradingAccountOperationHistory:
      type: object
      description: Trading account operation history entry
      properties:
        tradingAccountHistoryId:
          type: string
          format: uuid
        tradingAccountId:
          type: string
          format: uuid
        timestamp:
          type: string
          format: date-time
        operationType:
          $ref: '#/components/schemas/tradingAccountOperationType'
        operateBy:
          type: string
        tags:
          type: array
          items:
            type: string
        previousValues:
          type: object
        newValues:
          type: object
    rpcSubscribeTradingAccountStreamParams:
      type: object
      description: Request to subscribe to trading account stream
      properties:
        tradingAccount:
          $ref: '#/components/schemas/rpcTradingAccount'
        subscriptionType:
          $ref: '#/components/schemas/subscriptionType'
      required:
        - tradingAccount
        - subscriptionType
    rpcSubscribeTradingAccountStreamResult:
      type: object
      description: Response for trading account stream subscription
      properties:
        data:
          $ref: '#/components/schemas/rpcSubscription'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcUnsubscribeTradingAccountStreamParams:
      type: object
      description: Request to unsubscribe from trading account stream
      properties:
        subscriptionId:
          type: string
          format: uuid
        tradingAccountId:
          type: string
          format: uuid
      required:
        - tradingAccountId
    rpcUnsubscribeTradingAccountStreamResult:
      type: object
      description: Response for trading account stream unsubscription
      properties:
        data:
          $ref: '#/components/schemas/rpcSubscription'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcListTradingAccountSubscriptionsParams:
      type: object
      description: Request to list trading account subscriptions
      properties:
        tradingAccountId:
          type: string
          format: uuid
        subscriptionType:
          $ref: '#/components/schemas/subscriptionType'
        status:
          $ref: '#/components/schemas/subscriptionStatus'
        pagination:
          $ref: '#/components/schemas/rpcPagination'
      required:
        - tradingAccountId
    rpcListTradingAccountSubscriptionsResult:
      type: object
      description: Response for listing trading account subscriptions
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcSubscription'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcTradingAccountUpdatedEvent:
      type: object
      description: Trading account update event (pushed via WebSocket)
      properties:
        data:
          $ref: '#/components/schemas/rpcTradingAccount'
    rpcTradingAccountSubscriptionUpdatedEvent:
      type: object
      description: Trading account subscription update event (pushed via WebSocket)
      properties:
        data:
          $ref: '#/components/schemas/rpcSubscription'
    rpcCreateCredentialParams:
      type: object
      description: Request to create a credential
      properties:
        tradingAccountId:
          type: string
          format: uuid
        venue:
          $ref: '#/components/schemas/venue'
        credentialType:
          $ref: '#/components/schemas/credentialType'
        apiKey:
          type: string
        secretKey:
          type: string
        secretPassphrase:
          type: string
        nickname:
          type: string
      required:
        - tradingAccountId
        - venue
        - credentialType
    rpcCreateCredentialResult:
      type: object
      description: Response for credential creation
      properties:
        data:
          $ref: '#/components/schemas/rpcTradingAccountCredential'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcSaveCredentialParams:
      type: object
      description: Request to save a credential
      properties:
        credential:
          $ref: '#/components/schemas/rpcTradingAccountCredential'
      required:
        - credential
    rpcSaveCredentialResult:
      type: object
      description: Response for credential save
      properties:
        data:
          $ref: '#/components/schemas/rpcTradingAccountCredential'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcListCredentialsParams:
      type: object
      description: Request to list credentials
      properties:
        credentialIds:
          type: array
          items:
            type: string
            format: uuid
        venue:
          $ref: '#/components/schemas/venue'
        credentialType:
          $ref: '#/components/schemas/credentialType'
        status:
          $ref: '#/components/schemas/credentialStatus'
        pagination:
          $ref: '#/components/schemas/rpcPagination'
    rpcListCredentialsResult:
      type: object
      description: Response for listing credentials
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcTradingAccountCredential'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcVerifyCredentialParams:
      type: object
      description: Request to verify credentials
      properties:
        credentialIds:
          type: array
          items:
            type: string
            format: uuid
        credentials:
          type: array
          items:
            $ref: '#/components/schemas/rpcTradingAccountCredential'
    rpcVerifyCredentialResult:
      type: object
      description: Response for credential verification
      properties:
        data:
          type: object
          properties:
            tradingAccounts:
              type: array
              items:
                $ref: '#/components/schemas/rpcTradingAccount'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcRevokeCredentialParams:
      type: object
      description: Request to revoke a credential
      properties:
        credentialId:
          type: string
          format: uuid
      required:
        - credentialId
    rpcRevokeCredentialResult:
      type: object
      description: Response for credential revocation
      properties:
        data:
          $ref: '#/components/schemas/rpcTradingAccountCredential'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcRotateCredentialParams:
      type: object
      description: Request to rotate a credential
      properties:
        credentialId:
          type: string
          format: uuid
        credentialType:
          $ref: '#/components/schemas/credentialType'
        apiKey:
          type: string
        secretKey:
          type: string
        secretPassphrase:
          type: string
      required:
        - credentialId
        - credentialType
    rpcRotateCredentialResult:
      type: object
      description: Response for credential rotation
      properties:
        data:
          $ref: '#/components/schemas/rpcTradingAccountCredential'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcCredentialUpdatedEvent:
      type: object
      description: Credential update event (pushed via WebSocket)
      properties:
        data:
          $ref: '#/components/schemas/rpcTradingAccountCredential'
    rpcSaveTradeOrderParams:
      type: object
      description: Request to save a trade order
      properties:
        tradeOrder:
          $ref: '#/components/schemas/rpcTradeOrder'
      required:
        - tradeOrder
    rpcSaveTradeOrderResult:
      type: object
      description: Response for saving trade order
      properties:
        data:
          $ref: '#/components/schemas/rpcTradeOrder'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcGetTradeOrderByIdParams:
      type: object
      description: Request to get a trade order by ID
      properties:
        tradeOrderId:
          type: string
          format: uuid
      required:
        - tradeOrderId
    rpcGetTradeOrderByIdResult:
      type: object
      description: Response for getting trade order by ID
      properties:
        data:
          $ref: '#/components/schemas/rpcTradeOrder'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcSavePortfolioParams:
      type: object
      description: Request to save a portfolio
      properties:
        portfolio:
          $ref: '#/components/schemas/rpcPortfolio'
      required:
        - portfolio
    rpcSavePortfolioResult:
      type: object
      description: Response for saving portfolio
      properties:
        data:
          $ref: '#/components/schemas/rpcPortfolio'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcSyncInstrumentsParams:
      type: object
      description: Request to sync instruments from venue
      properties:
        venue:
          $ref: '#/components/schemas/venue'
        symbols:
          type: array
          items:
            type: string
      required:
        - venue
    rpcSyncInstrumentsResult:
      type: object
      description: Response for instrument sync
      properties:
        data:
          type: object
          properties:
            total:
              type: integer
        error:
          $ref: '#/components/schemas/rpcError'
    rpcSaveInstrumentsParams:
      type: object
      description: Request to save instruments
      properties:
        instruments:
          type: array
          items:
            $ref: '#/components/schemas/rpcInstrument'
      required:
        - instruments
    rpcSaveInstrumentsResult:
      type: object
      description: Response for saving instruments
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcInstrument'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcListInstrumentsParams:
      type: object
      description: Request to list instruments
      properties:
        venue:
          $ref: '#/components/schemas/venue'
        symbols:
          type: array
          items:
            type: string
        securityType:
          type: string
        instrumentStatus:
          type: string
        limit:
          type: integer
        offset:
          type: integer
    rpcListInstrumentsResult:
      type: object
      description: Response for listing instruments
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcInstrument'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcDeleteInstrumentParams:
      type: object
      description: Request to delete an instrument
      properties:
        instrumentId:
          type: string
          description: 'Instrument ID (format: VENUE:BASE/QUOTE)'
          example: BINANCE:BTC/USDT
      required:
        - instrumentId
    rpcDeleteInstrumentResult:
      type: object
      description: Response for instrument deletion
      properties:
        data:
          $ref: '#/components/schemas/rpcInstrument'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcEnableInstrumentParams:
      type: object
      description: Request to enable an instrument
      properties:
        instrumentId:
          type: string
          example: BINANCE:BTC/USDT
      required:
        - instrumentId
    rpcEnableInstrumentResult:
      type: object
      description: Response for enabling instrument
      properties:
        data:
          $ref: '#/components/schemas/rpcInstrument'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcDisableInstrumentParams:
      type: object
      description: Request to disable an instrument
      properties:
        instrumentId:
          type: string
          example: BINANCE:BTC/USDT
      required:
        - instrumentId
    rpcDisableInstrumentResult:
      type: object
      description: Response for disabling instrument
      properties:
        data:
          $ref: '#/components/schemas/rpcInstrument'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcInstrument:
      type: object
      description: Financial instrument
      properties:
        instrumentId:
          type: string
          description: 'Unique instrument identifier (format: VENUE:BASE/QUOTE)'
          example: BINANCE:BTC/USDT
        venue:
          $ref: '#/components/schemas/venue'
        symbol:
          type: string
          example: BTC/USDT
        externalSymbol:
          type: string
          example: BTCUSDT
        description:
          type: string
        instrumentType:
          $ref: '#/components/schemas/instrumentType'
        status:
          $ref: '#/components/schemas/instrumentStatus'
        baseAsset:
          type: string
          example: BTC
        quoteAsset:
          type: string
          example: USDT
        baseSecurityType:
          $ref: '#/components/schemas/securityType'
        quoteSecurityType:
          $ref: '#/components/schemas/securityType'
        basePrecision:
          type: integer
        quotePrecision:
          type: integer
        lotSize:
          type: string
          description: Decimal value as string
        pipSize:
          type: string
          description: Decimal value as string
        minQuantity:
          type: string
          description: Decimal value as string
        maxQuantity:
          type: string
          description: Decimal value as string
        minNotional:
          type: string
          description: Decimal value as string
        maxNotional:
          type: string
          description: Decimal value as string
        orderTypes:
          type: array
          items:
            type: string
        timeInForceOptions:
          type: array
          items:
            type: string
        fee:
          type: string
          description: Decimal value as string
        isIcebergAllowed:
          type: boolean
        contractSize:
          type: string
          description: Decimal value as string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    rpcInstrumentUpdatedEvent:
      type: object
      description: Instrument update event (pushed via WebSocket)
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcInstrument'
    rpcSyncSecuritiesParams:
      type: object
      description: Request to sync securities from venue
      properties:
        venue:
          $ref: '#/components/schemas/venue'
        securities:
          type: array
          items:
            type: string
      required:
        - venue
    rpcSyncSecuritiesResult:
      type: object
      description: Response for security sync
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcSecurity'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcSaveSecuritiesParams:
      type: object
      description: Request to save securities
      properties:
        securities:
          type: array
          items:
            $ref: '#/components/schemas/rpcSecurity'
      required:
        - securities
    rpcSaveSecuritiesResult:
      type: object
      description: Response for saving securities
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcSecurity'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcDeleteSecuritiesParams:
      type: object
      description: Request to delete securities
      properties:
        securityIds:
          type: array
          items:
            type: string
            format: uuid
      required:
        - securityIds
    rpcDeleteSecuritiesResult:
      type: object
      description: Response for security deletion
      properties:
        error:
          $ref: '#/components/schemas/rpcError'
    rpcListSecuritiesParams:
      type: object
      description: Request to list securities
      properties:
        venue:
          $ref: '#/components/schemas/venue'
        securities:
          type: array
          items:
            type: string
        externalSymbols:
          type: array
          items:
            type: string
    rpcListSecuritiesResult:
      type: object
      description: Response for listing securities
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcSecurity'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcSecurity:
      type: object
      description: Security (base asset)
      properties:
        securityId:
          type: string
        symbol:
          type: string
          example: BTC
        externalSymbol:
          type: string
        venue:
          $ref: '#/components/schemas/venue'
    rpcSecurityUpdatedEvent:
      type: object
      description: Security update event (pushed via WebSocket)
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcSecurity'
    rpcListVenuesParams:
      type: object
      description: Request to list available venues
      properties: {}
    rpcListVenuesResult:
      type: object
      description: Response for listing venues
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/venue'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcSaveOrderBooksParams:
      type: object
      description: Request to save order books
      properties:
        orderBooks:
          type: array
          items:
            $ref: '#/components/schemas/rpcOrderBook'
      required:
        - orderBooks
    rpcSaveOrderBooksResult:
      type: object
      description: Response for saving order books
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcOrderBook'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcListOrderBookSubscriptionsParams:
      type: object
      description: Request to list order book subscriptions
      properties:
        instrumentIds:
          type: array
          items:
            type: string
        venue:
          $ref: '#/components/schemas/venue'
        symbols:
          type: array
          items:
            type: string
    rpcListOrderBookSubscriptionsResult:
      type: object
      description: Response for listing order book subscriptions
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcSubscription'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcSaveKlinesParams:
      type: object
      description: Request to save klines (candlestick data)
      properties:
        klines:
          type: array
          items:
            $ref: '#/components/schemas/rpcKline'
      required:
        - klines
    rpcSaveKlinesResult:
      type: object
      description: Response for saving klines
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcKline'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcListKlinesParams:
      type: object
      description: Request to list klines
      properties:
        instrumentIds:
          type: array
          items:
            type: string
        venue:
          $ref: '#/components/schemas/venue'
        symbols:
          type: array
          items:
            type: string
        interval:
          type: string
          example: 1h
    rpcListKlinesResult:
      type: object
      description: Response for listing klines
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcKline'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcKline:
      type: object
      description: Kline (candlestick) data
      properties:
        instrumentId:
          type: string
          example: BINANCE:BTC/USDT
        symbol:
          type: string
        interval:
          type: string
          example: 1h
        candles:
          type: array
          items:
            $ref: '#/components/schemas/rpcOhlcv'
    rpcOhlcv:
      type: object
      description: OHLCV candlestick data
      properties:
        t:
          type: string
          format: date-time
          description: Open time
        interval:
          type: string
        o:
          type: string
          description: Open price (decimal)
        h:
          type: string
          description: High price (decimal)
        l:
          type: string
          description: Low price (decimal)
        c:
          type: string
          description: Close price (decimal)
        v:
          type: string
          description: Volume (decimal)
    rpcSaveTickersParams:
      type: object
      description: Request to save tickers
      properties:
        tickers:
          type: array
          items:
            $ref: '#/components/schemas/rpcTicker'
      required:
        - tickers
    rpcSaveTickersResult:
      type: object
      description: Response for saving tickers
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcTicker'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcListTickersParams:
      type: object
      description: Request to list tickers
      properties:
        instrumentIds:
          type: array
          items:
            type: string
        venue:
          $ref: '#/components/schemas/venue'
        symbols:
          type: array
          items:
            type: string
    rpcListTickersResult:
      type: object
      description: Response for listing tickers
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcTicker'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcTicker:
      type: object
      description: Market ticker data
      properties:
        instrumentId:
          type: string
          example: BINANCE:BTC/USDT
        symbol:
          type: string
        exchange:
          type: string
        exchangeTime:
          type: string
          format: date-time
        time:
          type: string
          format: date-time
        ask:
          type: string
          description: Ask price (decimal)
        askQuantity:
          type: string
          description: Ask quantity (decimal)
        bid:
          type: string
          description: Bid price (decimal)
        bidQuantity:
          type: string
          description: Bid quantity (decimal)
        last:
          type: string
          description: Last price (decimal)
        lastQuantity:
          type: string
          description: Last quantity (decimal)
    rpcCreateSubscriptionParams:
      type: object
      description: Request to create a market data subscription
      properties:
        venue:
          $ref: '#/components/schemas/venue'
        instruments:
          type: array
          items:
            type: string
        subscriptionType:
          $ref: '#/components/schemas/subscriptionType'
      required:
        - venue
        - subscriptionType
    rpcCreateSubscriptionResult:
      type: object
      description: Response for subscription creation
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcSubscription'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcListSubscriptionsParams:
      type: object
      description: Request to list subscriptions
      properties:
        instrumentId:
          type: array
          items:
            type: string
        subscriptionType:
          $ref: '#/components/schemas/subscriptionType'
        venue:
          $ref: '#/components/schemas/venue'
    rpcListSubscriptionsResult:
      type: object
      description: Response for listing subscriptions
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcSubscription'
        error:
          $ref: '#/components/schemas/rpcError'
    rpcSubscriptionUpdatedEvent:
      type: object
      description: Subscription update event (pushed via WebSocket)
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/rpcSubscription'
  securitySchemes:
    SupabaseOAuth2BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
x-websocket-endpoints:
  market.orderBook:
    description: Real-time market order book updates
    subscribe:
      $ref: '#/components/schemas/wsMarketOrderBookSubscribe'
    unsubscribe:
      $ref: '#/components/schemas/wsMarketOrderBookUnsubscribe'
    message:
      $ref: '#/components/schemas/wsMarketOrderBookUpdate'
