---
openapi: 3.0.1
info:
  title: Trading API v4
  description: APIs related to trading operations
  version: v4
paths:
  /frontoffice/api/v4/positions/executions/list:
    post:
      tags:
        - PositionControllerV
      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.Position.ApiGetCfdExecutions.Request
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/BBP.TradingServer.TradingApi.Models.Position.ApiGetCfdExecutions.Response
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
  /frontoffice/api/v4/positions/{positionId}/executions/list:
    post:
      tags:
        - PositionControllerV
      description: "Required operations: trading-ui"
      parameters:
        - name: positionId
          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.Position.ApiGetCfdExecutions.RequestSingle.BodyModel
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/BBP.TradingServer.TradingApi.Models.Position.ApiGetCfdExecutions.Response
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
  /frontoffice/api/v4/positions/{positionId}/close:
    post:
      tags:
        - PositionControllerV
      description: "Required operations: trading-ui"
      parameters:
        - name: positionId
          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.Position.ApiClosePosition.Request.ClosePositionData
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/BBP.TradingServer.TradingApi.Models.Position.ApiClosePosition.Response
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
  /frontoffice/api/v4/positions/{positionId}/close/calculation:
    post:
      tags:
        - PositionControllerV
      description: "Required operations: trading-ui"
      parameters:
        - name: positionId
          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.Position.ApiCalculationClosePosition.CalculationClosePositionData
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/BBP.TradingServer.TradingApi.Models.Position.ApiCalculationClosePosition.CalculationClosePositionData
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
  /frontoffice/api/v4/positions/{positionId}/triggers:
    put:
      tags:
        - PositionControllerV
      description: "Required operations: trading-ui"
      parameters:
        - name: positionId
          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.Position.ApiSubmitTrigger.Request.BodyModel
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/BBP.TradingServer.TradingApi.Models.Position.ApiSubmitTrigger.Response
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
  /frontoffice/api/v4/positions/{positionId}/trigger-data:
    post:
      tags:
        - PositionControllerV
      description: "Required operations: trading-ui"
      parameters:
        - name: positionId
          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.Position.ApiGetTriggerData.Request.BodyModel
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/BBP.TradingServer.TradingApi.Models.Position.ApiGetTriggerData.Response
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
        '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.ApiOrderSide:
      enum:
        - Buy
        - Sell
      type: string
    BBP.TradingServer.TradingApi.Models.Enums.ApiOrderReason:
      enum:
        - Admin
        - Trader
        - StopOut
        - MarketHalted
        - MarketDisabled
        - UserTerminated
        - TakeProfit
        - StopLoss
      type: string
    BBP.TradingServer.TradingApi.Models.Enums.ApiTriggerType:
      enum:
        - Price
        - Rate
        - Points
        - Pnl
      type: string
    BBP.TradingServer.TradingApi.Models.Position.ApiGetCfdExecutions.Request:
      type: object
      properties:
        positionIds:
          type: array
          items:
            type: string
        limit:
          type: integer
          format: int32
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiGetCfdExecutions.Response:
      type: object
      properties:
        executions:
          type: array
          items:
            $ref: >-
              #/components/schemas/BBP.TradingServer.TradingApi.Models.Position.ApiGetCfdExecutions.Execution
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiGetCfdExecutions.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
        commissionAmountInRAT:
          type: string
        commissions:
          type: array
          items:
            $ref: >-
              #/components/schemas/BBP.TradingServer.TradingApi.Models.Position.ApiGetCfdExecutions.Commission
        comment:
          type: string
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiGetCfdExecutions.Commission:
      type: object
      properties:
        assetId:
          type: string
        amount:
          type: string
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiGetCfdExecutions.RequestSingle.BodyModel:
      type: object
      properties:
        limit:
          type: integer
          format: int32
          nullable: true
        offset:
          type: integer
          format: int32
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiClosePosition.Request.ClosePositionData:
      type: object
      properties:
        closePositionLotAmount:
          type: string
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiClosePosition.Response:
      type: object
      properties:
        positionId:
          type: string
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiCalculationClosePosition.CalculationClosePositionData:
      type: object
      properties:
        closePositionLotAmount:
          type: string
          nullable: true
        closePositionLotAmountInPercent:
          type: string
          nullable: true
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiSubmitTrigger.Request.BodyModel:
      type: object
      properties:
        takeProfit:
          $ref: >-
            #/components/schemas/BBP.TradingServer.TradingApi.Models.Position.ApiSubmitTrigger.Request.TakeProfitRequest
        stopLoss:
          $ref: >-
            #/components/schemas/BBP.TradingServer.TradingApi.Models.Position.ApiSubmitTrigger.Request.StopLossRequest
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiSubmitTrigger.Request.TakeProfitRequest:
      type: object
      properties:
        price:
          type: string
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiSubmitTrigger.Request.StopLossRequest:
      type: object
      properties:
        price:
          type: string
        isTrailing:
          type: boolean
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiSubmitTrigger.Response:
      type: object
      properties:
        positionId:
          type: string
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiGetTriggerData.Request.BodyModel:
      type: object
      properties:
        takeProfit:
          $ref: >-
            #/components/schemas/BBP.TradingServer.TradingApi.Models.Position.ApiGetTriggerData.Request.TakeProfitRequest
        stopLoss:
          $ref: >-
            #/components/schemas/BBP.TradingServer.TradingApi.Models.Position.ApiGetTriggerData.Request.StopLossRequest
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiGetTriggerData.Request.TakeProfitRequest:
      type: object
      properties:
        triggerType:
          $ref: >-
            #/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiTriggerType
        triggerSize:
          type: string
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiGetTriggerData.Request.StopLossRequest:
      type: object
      properties:
        triggerType:
          $ref: >-
            #/components/schemas/BBP.TradingServer.TradingApi.Models.Enums.ApiTriggerType
        triggerSize:
          type: string
        isTrailing:
          type: boolean
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiGetTriggerData.Response:
      type: object
      properties:
        takeProfit:
          $ref: >-
            #/components/schemas/BBP.TradingServer.TradingApi.Models.Position.ApiGetTriggerData.Response.TakeProfitResponse
        stopLoss:
          $ref: >-
            #/components/schemas/BBP.TradingServer.TradingApi.Models.Position.ApiGetTriggerData.Response.StopLossResponse
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiGetTriggerData.Response.TakeProfitResponse:
      type: object
      properties:
        price:
          type: string
        rate:
          type: string
        points:
          type: integer
          format: int64
        pnl:
          type: string
      additionalProperties: false
    BBP.TradingServer.TradingApi.Models.Position.ApiGetTriggerData.Response.StopLossResponse:
      type: object
      properties:
        price:
          type: string
        rate:
          type: string
        points:
          type: integer
          format: int64
        pnl:
          type: string
      additionalProperties: false
