---
openapi: 3.0.1
info:
  title: Trading API v5
  description: APIs related to trading operations
  version: v5
paths:
  /frontoffice/api/v5/orders/executions/list:
    post:
      tags:
        - OrderControllerV
      description: "Required operations: trading-ui"
      parameters:
        - name: accountId
          in: header
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsv5.Request
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsv5.Response
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
  /frontoffice/api/v5/orders/{orderId}/executions/list:
    post:
      tags:
        - OrderControllerV
      description: "Required operations: trading-ui"
      parameters:
        - name: orderId
          in: path
          required: true
          schema:
            type: string
        - name: accountId
          in: header
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsV5.RequestSingle.BodyModel
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsV5.ResponseSingle
        '400':
          description: Bad Request
          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.ApiOrderReason:
      enum:
        - Admin
        - Trader
        - StopOut
        - MarketHalted
        - MarketDisabled
        - UserTerminated
        - TakeProfit
        - StopLoss
      type: string
    BBP.TradingServer.TradingApi.Models.Enums.ApiOrderSide:
      enum:
        - Buy
        - Sell
      type: string
    BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsv5.Request:
      type: object
      properties:
        orderPositionPairs:
          type: array
          minItems: 1
          items:
            type: object
            required:
              - orderId
              - positionId
            properties:
              orderId:
                type: string
                example: 01K31APDKZCVGWZA3XTF5JPAMD
              positionId:
                type: string
                example: 01K31APDWF2EBHRKHH15VGB1ST
        limit:
          type: integer
          format: int32
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsv5.Response:
      type: object
      properties:
        executions:
          type: array
          items:
            $ref: >-
              #/components/schemas/BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsv5.Execution
        isExceeded:
          type: boolean
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsv5.Execution:
      type: object
      properties:
        positionId:
          type: string
        orderId:
          type: string
        side:
          $ref: >-
            #/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiOrderSide
        reason:
          $ref: >-
            #/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiOrderReason
        createdAt:
          type: string
          format: date-time
        executionId:
          type: string
        baseAmount:
          type: string
        executionPrice:
          type: string
        realizedPnlInRAT:
          type: string
        commissionAmountInRAT:
          type: string
        commissions:
          type: array
          items:
            $ref: >-
              #/components/schemas/BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsv5.Commission
        positionSizeIncreased:
          type: boolean
        comment:
          type: string
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsv5.Commission:
      type: object
      properties:
        assetId:
          type: string
        amount:
          type: string
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsV5.RequestSingle.BodyModel:
      type: object
      properties:
        limit:
          type: integer
          format: int32
          nullable: true
        lastExecutionId:
          type: string
          nullable: true
        positionId:
          type: string
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsV5.ResponseSingle:
      type: object
      properties:
        executions:
          type: array
          items:
            $ref: >-
              #/components/schemas/BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsV5.Execution
        isExceeded:
          type: boolean
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsV5.Execution:
      type: object
      properties:
        positionId:
          type: string
        orderId:
          type: string
        side:
          $ref: >-
            #/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiOrderSide
        reason:
          $ref: >-
            #/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiOrderReason
        createdAt:
          type: string
          format: date-time
        executionId:
          type: string
        baseAmount:
          type: string
        executionPrice:
          type: string
        realizedPnlInRAT:
          type: string
        commissionAmountInRAT:
          type: string
        commissions:
          type: array
          items:
            $ref: >-
              #/components/schemas/BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsV5.Commission
        positionSizeIncreased:
          type: boolean
        comment:
          type: string
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Order.v5.ApiGetClosedPositionOrderExecutionsV5.Commission:
      type: object
      properties:
        assetId:
          type: string
        amount:
          type: string
      additionalProperties: false
