---
openapi: 3.0.1
info:
  title: Trading API v5
  description: APIs related to trading operations
  version: v5
paths:
  /frontoffice/api/v5/markets:
    get:
      tags:
        - MarketControllerV
      description: "Required operations: trading-ui"
      parameters:
        - name: accountId
          in: header
          required: true
          schema:
            type: string
        - name: categoryId
          in: query
          schema:
            type: string
        - name: dynamicCommissionGroupId
          in: query
          schema:
            type: string
        - name: isFavorite
          in: query
          schema:
            type: boolean
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.MarketResponseV5'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
  /frontoffice/api/v5/markets/{marketId}:
    get:
      tags:
        - MarketControllerV
      description: "Required operations: trading-ui"
      parameters:
        - name: accountId
          in: header
          required: true
          schema:
            type: string
        - name: marketId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.Response'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
        '403':
          description: Forbidden
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
  /frontoffice/api/v5/guest/markets:
    get:
      tags:
        - GuestMarketControllerV
      description: >-
        Anonymous counterpart of GET /frontoffice/api/v5/markets. No
        authentication, no required operations, and no accountId header. Lists
        active, well-configured markets ordered by displayName. Mirrors the
        authenticated list item minus isFavorite, since guests have no
        per-account favorites.
      parameters:
        - name: categoryId
          in: query
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Controllers.v5.Guest.ApiGuestMarketListItemV5'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
  /frontoffice/api/v5/guest/markets/{marketId}:
    get:
      tags:
        - GuestMarketControllerV
      description: >-
        Anonymous counterpart of GET /frontoffice/api/v5/markets/{marketId}. No
        authentication, no required operations, and no accountId header. Mirrors
        the authenticated market detail minus the per-account, commission, and
        leverage fields. An unknown, disabled, or misconfigured market returns
        400.
      parameters:
        - name: marketId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Controllers.v5.Guest.ApiGuestMarketV5'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
  /frontoffice/api/v5/markets/favorites/add:
    post:
      tags:
        - MarketControllerV
      description: "Required operations: trading-ui"
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.AddMarketFavoriteRequestV5'
      responses:
        '200':
          description: Added to favorites
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.AddMarketFavoriteResponseV5'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
  /frontoffice/api/v5/markets/favorites/delete:
    post:
      tags:
        - MarketControllerV
      description: "Remove market from favorites. Required operations: trading-ui"
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.DeleteMarketFavoriteRequestV5'
      responses:
        '200':
          description: Removed from favorites
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.DeleteMarketFavoriteResponseV5'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
components:
  schemas:
    BBP.Platform.Http.ErrorData:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        details:
          $ref: '#/components/schemas/BBP.Platform.Http.ErrorData.ErrorDetails'
      additionalProperties: false
    BBP.Platform.Http.ErrorData.ErrorDetails:
      type: object
      properties:
        source:
          type: string
          nullable: true
        message:
          type: string
          nullable: true
        stackTrace:
          type: string
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Enums.ApiMarketType:
      enum:
        - Spot
        - Cfd
        - Perpetual
      type: string
    BBP.TradingServer.TradingApi.Models.Enums.ApiMarketSubtype:
      enum:
        - Cash
        - Crypto
        - CryptoCash
        - Fx
        - Metals
        - Indices
        - Energies
        - Ndf
        - Shares
        - Etf
      type: string
    BBP.TradingServer.TradingApi.Models.Enums.ApiDayOfWeek:
      enum:
        - Monday
        - Tuesday
        - Wednesday
        - Thursday
        - Friday
        - Saturday
        - Sunday
      type: string
    BBP.TradingServer.TradingApi.Models.Enums.ApiLeverageType:
      enum:
        - Fixed
        - Dynamic
      type: string
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiSwapType:
      enum:
        - FixPerLot
        - Percent
        - Points
      type: string
    BBP.TradingServer.TradingApi.Models.CommissionChargeType:
      enum:
        - Percent
        - FixPerLot
      type: string
    BBP.TradingServer.TradingApi.Models.CommissionType:
      enum:
        - Dynamic
        - Fixed
      type: string
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.Response:
      required:
        - baseAssetId
        - displayName
        - marketId
        - quoteAssetId
      type: object
      properties:
        marketId:
          minLength: 1
          type: string
        displayName:
          minLength: 1
          type: string
        fullName:
          type: string
          nullable: true
        baseAssetId:
          minLength: 1
          type: string
        quoteAssetId:
          minLength: 1
          type: string
        minAmount:
          type: string
          nullable: true
        maxBaseAmount:
          type: string
          nullable: true
        priceDeviation:
          type: string
        priceScale:
          type: integer
          format: int32
        amountScale:
          type: integer
          format: int32
          nullable: true
        type:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiMarketType'
        subtype:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiMarketSubtype'
        swapSettings:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiSwapSettings'
        lotSize:
          type: integer
          format: int32
          nullable: true
        minLotAmount:
          type: string
          nullable: true
        maxLotAmount:
          type: integer
          format: int32
          nullable: true
        tickSize:
          type: string
          nullable: true
        lotStep:
          type: string
          nullable: true
        slippageRate:
          type: string
        minQuoteAmount:
          type: string
          nullable: true
        calendar:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiCalendar'
        fundingStartTime:
          type: string
          format: time
          nullable: true
        fundingIntervalInHours:
          type: integer
          format: int32
          nullable: true
        leverageProfile:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.LeverageProfile'
        commissionSettings:
          oneOf:
            - $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.DynamicCommissionSettings'
            - $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.FixedCommissionSettings'
        isFavorite:
          type: boolean
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.DynamicCommissionSettings:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.CommissionType'
        сharge:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.DynamicCommissionSettings.ChargeInfoV5'
        dynamicCommissionGroupId:
          type: string
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.FixedCommissionSettings:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.CommissionType'
        сharge:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.FixedCommissionSettings.ChargeInfoV5'
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.FixedCommissionSettings.ChargeInfoV5:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.CommissionChargeType'
        size:
          type: string
        assetId:
          type: string
          nullable: true
        minCommissionInRAT:
          type: string
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.DynamicCommissionSettings.ChargeInfoV5:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.CommissionChargeType'
        tiers:
          type: array
          items:
            $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.CommissionTier'
          minItems: 2
        minCommissionInRAT:
          type: string
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.CommissionTier:
      type: object
      properties:
        size:
          type: string
        minTradingVolumeInRAT:
          type: string
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.LeverageProfile:
      type: object
      required:
        - leverageType
        - leverage
      properties:
        leverageType:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiLeverageType'
        leverage:
          oneOf:
            - $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.FixedLeverage'
            - $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.DynamicLeverage'
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.FixedLeverage:
      type: object
      required:
        - maxLeverage
        - useOnlyMaxLeverage
      properties:
        useOnlyMaxLeverage:
          type: boolean
        maxLeverage:
          type: integer
          format: int32
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.DynamicLeverage:
      type: object
      required:
        - useOnlyMaxLeverage
        - tiers
      properties:
        useOnlyMaxLeverage:
          type: boolean
        tiers:
          type: array
          items:
            $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.DynamicLeverageTier'
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.DynamicLeverageTier:
      type: object
      required:
        - maxLeverage
        - maxNotionalValueInRAT
      properties:
        maxLeverage:
          type: integer
          format: int32
        maxNotionalValueInRAT:
          type: string
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiSwapSettings:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiSwapType'
        shortPositionSettings:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiSwapPositionSettings'
        longPositionSettings:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiSwapPositionSettings'
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiSwapPositionSettings:
      type: object
      properties:
        size:
          type: string
        assetId:
          type: string
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiCalendar:
      type: object
      properties:
        timeZoneId:
          type: string
        tradingSessions:
          type: array
          items:
            $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiTradingSession'
        sessionOverrides:
          type: array
          items:
            $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiSessionOverride'
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiTradingSession:
      type: object
      properties:
        dayOfWeek:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiDayOfWeek'
        timeIntervals:
          type: array
          items:
            $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiTimeInterval'
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiTimeInterval:
      type: object
      properties:
        start:
          type: string
          format: time
        end:
          type: string
          format: time
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiSessionOverride:
      type: object
      properties:
        date:
          type: string
          format: date
        timeIntervals:
          type: array
          items:
            $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiTimeInterval'
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.MarketResponseV5:
      required:
        - displayName
        - marketId
        - type
      type: object
      properties:
        marketId:
          minLength: 1
          type: string
        displayName:
          minLength: 1
          type: string
        fullName:
          type: string
        type:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiMarketType'
        subtype:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiMarketSubtype'
        isFavorite:
          type: boolean
      additionalProperties: false
    BBP.TradingServer.TradingApi.Controllers.v5.Guest.ApiGuestMarketListItemV5:
      required:
        - displayName
        - marketId
        - type
      type: object
      properties:
        marketId:
          minLength: 1
          type: string
        displayName:
          minLength: 1
          type: string
        fullName:
          type: string
          nullable: true
        type:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiMarketType'
        subtype:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiMarketSubtype'
      additionalProperties: false
    BBP.TradingServer.TradingApi.Controllers.v5.Guest.ApiGuestMarketV5:
      required:
        - baseAssetId
        - displayName
        - marketId
        - priceDeviation
        - priceScale
        - quoteAssetId
        - slippageRate
        - type
      type: object
      properties:
        marketId:
          minLength: 1
          type: string
        displayName:
          minLength: 1
          type: string
        fullName:
          type: string
          nullable: true
        baseAssetId:
          minLength: 1
          type: string
        quoteAssetId:
          minLength: 1
          type: string
        type:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiMarketType'
        subtype:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiMarketSubtype'
        priceScale:
          type: integer
          format: int32
        amountScale:
          type: integer
          format: int32
          nullable: true
        tickSize:
          type: string
          nullable: true
        lotSize:
          type: integer
          format: int32
          nullable: true
        lotStep:
          type: string
          nullable: true
        minAmount:
          type: string
          nullable: true
        minQuoteAmount:
          type: string
          nullable: true
        maxBaseAmount:
          type: string
          nullable: true
        minLotAmount:
          type: string
          nullable: true
        maxLotAmount:
          type: integer
          format: int64
          nullable: true
        calendar:
          $ref: '#/components/schemas/BBP.TradingServer.TradingApi.Models.Market.v5.ApiMarketDetailsV5.ApiCalendar'
        slippageRate:
          type: string
        priceDeviation:
          type: string
        fundingStartTime:
          type: string
          format: time
          nullable: true
        fundingIntervalInHours:
          type: integer
          format: int32
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.AddMarketFavoriteRequestV5:
      type: object
      required:
        - marketId
      properties:
        marketId:
          type: string
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.AddMarketFavoriteResponseV5:
      type: object
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.DeleteMarketFavoriteRequestV5:
      type: object
      required:
        - marketId
      properties:
        marketId:
          type: string
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Market.v5.DeleteMarketFavoriteResponseV5:
      type: object
      additionalProperties: false
