---
openapi: 3.1.0
info:
  title: CfdStopOrders
  version: '4.0'
  contact: {}
  description: Cfd Stop Orders in TradingApi
servers:
  - url: '[ts-host]'
tags:
  - name: CFDStopOrderController
    description: CFD Stop Orders operations
paths:
  /frontoffice/api/cfd/v4/stop-orders:
    post:
      tags:
        - CFDStopOrderController
      summary: Stop Order data
      description: '<p><b>Required operations:</b><br/>frontoffice-ui</p>'
      operationId: stopOrder
      requestBody:
        description: Create StopOrder
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiCreateCfdStopOrderV4.Request'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiCreateCfdStopOrderV4.Response'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
components:
  schemas:
    ApiCreateCfdStopOrderV4.Request:
      type: object
      properties:
        order:
          $ref: '#/components/schemas/ApiCreateCfdStopOrderV4.CfdStopOrderModelV4'
    ApiCreateCfdStopOrderV4.CfdStopOrderModelV4:
      type: object
      properties:
        marketId:
          type: string
        orderType:
          $ref: '#/components/schemas/ApiOrderType'
        side:
          $ref: '#/components/schemas/ApiOrderSide'
        requestedPrice:
          $ref: '#/components/schemas/StringDecimalNullable'
        activationPrice:
          $ref: '#/components/schemas/StringDecimalNullable'
        requestedLotAmount:
          $ref: '#/components/schemas/StringDecimal'
        timeInForce:
          $ref: '#/components/schemas/ApiOrderTimeInForce'
        cancellationDate:
          type: string
          format: date-time
        leverage:
          type: integer
        takeProfit:
          $ref: '#/components/schemas/ApiCreateCfdStopOrderV4.TakeProfitPlaceOrderRequest'
        stopLoss:
          $ref: '#/components/schemas/ApiCreateCfdStopOrderV4.StopLossPlaceOrderRequest'
    ApiCreateCfdStopOrderV4.Response:
      type: object
      properties:
        orderId:
          type: string
        status:
          $ref: '#/components/schemas/ApiOrderStatus'
    ErrorData:
      type: object
      properties:
        code:
          type: string
          pattern: '^TR\d{4}$'
        message:
          type: string
      required:
        - code
      details:
        $ref: '#/components/schemas/ErrorData.ErrorDetails'
    ErrorData.ErrorDetails:
      type: object
      properties:
        source:
          type: string
        message:
          type: string
        stackTrace:
          type: string
    StringDecimal:
      title: StringDecimal
      type: string
      pattern: '^\d+(\.\d+){0,1}'
      examples:
        - '0.002'
        - '10.015'
        - '0.000001'
    StringDecimalNullable:
      title: StringDecimalNullable
      type:
        - string
        - 'null'
      pattern: '^\d+(\.\d+){0,1}'
      examples:
        - '0.002'
        - '10.015'
        - '0.000001'
        - null
    ApiOrderType:
      title: ApiOrderType
      type: string
      enum:
        - Market
        - Limit
    ApiOrderSide:
      title: ApiOrderSide
      type: string
      enum:
        - Buy
        - Sell
    ApiOrderTimeInForce:
      title: ApiOrderTimeInForce
      type: string
      enum:
        - gtc
        - ioc
        - fok
        - gtd
        - day
    ApiOrderStatus:
      title: ApiOrderTimeInForce
      type: string
      enum:
        - started
        - pending
        - working
        - completed
        - cancelled
        - expired
        - rejected
    ApiCreateCfdStopOrderV4.TakeProfitPlaceOrderRequest:
      type: object
      properties:
        price:
          type: string
    ApiCreateCfdStopOrderV4.StopLossPlaceOrderRequest:
      type: object
      properties:
        price:
          type: string
        isTrailing:
          type: boolean
