openapi: 3.0.0
info:
  version: 0.1.0
  title: Trading API
servers:
  - url: https://gateway.staging.wintrado.com
    description: >-
      API which is used directly by the customer applications (WebTrader etc.)
      to make trades and receive trading information.
security:
  - StandardAuth: []
tags:
  - name: Accounts
  - name: Instruments
  - name: Orders
  - name: Positions
  - name: Trades
  - name: Prop Trading
  - name: History
  - name: Signals
paths:
  /trading/account:
    get:
      summary: Fetch account information
      operationId: getAccount
      tags:
        - Accounts
      responses:
        '200':
          description: Account information
          content:
            application/json:
              schema:
                properties:
                  account:
                    oneOf:
                      - $ref: '#/components/schemas/Account'
                      - $ref: '#/components/schemas/FundedAccount'
                      - $ref: '#/components/schemas/ChallengeAccount'
        '404':
          description: Account not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error404'
  /trading/positions:
    get:
      summary: Fetches all active positions (status open, new, in-closing etc.)
      operationId: findPositions
      tags:
        - Positions
      responses:
        '200':
          description: Active positions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Positions'
  /trading/positions/{positionId}:
    patch:
      summary: Modify an active position
      operationId: modifyPosition
      tags:
        - Positions
      parameters:
        - name: positionId
          in: path
          required: true
          description: The position id to modify
          schema:
            type: integer
            example: 1000
      requestBody:
        required: true
        description: Pass only the parameters you would like to modify
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ModifyPosition'
      responses:
        '201':
          description: Modification request accepted
          content:
            application/json:
              schema:
                properties:
                  ok:
                    type: boolean
                    example: true
                  position:
                    $ref: '#/components/schemas/Position'
        '400':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error400'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error404'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error422'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
    delete:
      tags:
        - Positions
      summary: Close a position
      description: Close an open position by its ID
      operationId: closePosition
      parameters:
        - name: id
          in: path
          required: true
          description: The ID of the position to close
          schema:
            type: integer
            format: int64
            example: 183
      responses:
        '200':
          description: Position closed successfully
          content:
            application/json:
              schema:
                properties:
                  ok:
                    type: boolean
                    example: true
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error400'
        '404':
          description: Position not found or not open
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error404'
  /trading/margin/calculate:
    get:
      tags:
        - Positions
      summary: Calculate margin requirement
      description: >
        Calculates the margin that would be locked for a hypothetical order and
        tells you whether the free margin would be exceeded or a margin-call
        would be triggered.
      operationId: calculateMarginRequirement
      parameters:
        - name: size
          in: query
          required: true
          description: Order size in lots/units (decimal).
          schema:
            type: string
            pattern: ^\d+(\.\d+)?$
            example: '0.1'
        - name: symbol
          in: query
          required: true
          description: Trading symbol / instrument code (e.g. `EURUSD`).
          schema:
            type: string
            example: EURUSD
        - name: side
          in: query
          required: true
          description: Order side.
          schema:
            type: string
            enum:
              - buy
              - sell
            example: buy
        - name: stopOrLimitPrice
          in: query
          required: false
          description: >
            Stop-loss or limit price that accompanies the order. Optional.
            Provide when the margin depends on a protective order.
          schema:
            type: string
            pattern: ^\d+(\.\d+)?$
            example: '1.2050'
      responses:
        '200':
          description: Margin calculation result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MarginCalculationResponse'
        '400':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error400'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error422'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
  /trading/orders:
    get:
      summary: Fetches all pending orders for the authorized trading account
      operationId: findOrders
      tags:
        - Orders
      responses:
        '200':
          description: Pending orders
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Orders'
    post:
      summary: Create a new order
      operationId: createOrder
      tags:
        - Orders
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOrder'
      responses:
        '201':
          description: Order accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
        '400':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error400'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error422'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
  /trading/orders/{orderId}:
    patch:
      summary: Modify a pending order
      operationId: modifyOrder
      tags:
        - Orders
      parameters:
        - name: orderId
          in: path
          required: true
          description: The order id to modify
          schema:
            type: integer
            example: 100
      requestBody:
        required: true
        description: Pass only the parameters you would like to modify
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ModifyOrder'
      responses:
        '201':
          description: Modification request accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error400'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error404'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error422'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
    delete:
      summary: Cancel a pending order
      operationId: cancelOrder
      tags:
        - Orders
      parameters:
        - name: orderId
          in: path
          required: true
          description: The order id to cancel
          schema:
            type: integer
            example: 100
      responses:
        '202':
          description: Cancellation request accepted
          content:
            application/json:
              schema:
                properties:
                  ok:
                    type: boolean
                    example: true
        '404':
          description: Invalid order id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error404'
        '422':
          description: Unprocessable entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error422'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
  /public/instruments:
    get:
      summary: Fetch instrument information
      operationId: findInstruments
      tags:
        - Instruments
      parameters:
        - name: search
          in: query
          required: false
          description: Search query to filter instruments by symbol
          schema:
            type: string
            example: EURUSD
        - name: type
          in: query
          required: false
          description: Filter instruments by type
          schema:
            type: string
            example: currencies
      responses:
        '200':
          description: Instruments
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Instruments'
  /public/instruments/{symbol}:
    get:
      summary: Fetch instrument information by symbol
      operationId: getInstrumentBySymbol
      tags:
        - Instruments
      parameters:
        - name: symbol
          in: path
          required: true
          description: The symbol of the instrument to retrieve
          schema:
            type: string
            example: EURUSD
      responses:
        '200':
          description: Instrument information
          content:
            application/json:
              schema:
                properties:
                  ok:
                    type: boolean
                    example: true
                  instrument:
                    $ref: '#/components/schemas/TradingViewInstrumentFull'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error400'
  /public/instruments_info:
    get:
      summary: Fetch detailed instruments information
      operationId: getInstrumentsInfo
      tags:
        - Instruments
      responses:
        '200':
          description: Instruments information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InstrumentsInfo'
  /trading/trades:
    get:
      summary: Fetch all trades for the authorized trading account
      operationId: getTrades
      tags:
        - Trades
      parameters:
        - name: limit
          in: query
          description: The number of items to return
          schema:
            type: integer
            example: 100
          required: false
        - name: offset
          in: query
          description: >-
            The number of items to skip before starting to collect the result
            set
          schema:
            type: integer
            example: 0
          required: false
        - name: side
          in: query
          description: Filter by trade side
          schema:
            $ref: '#/components/schemas/TradeSideEnum'
          required: false
        - name: symbols
          in: query
          description: Filter by symbols
          schema:
            type: array
            items:
              type: string
          required: false
        - name: from
          in: query
          description: Filter by start date (RFC3339 format)
          schema:
            type: string
            format: date-time
          required: false
        - name: to
          in: query
          description: Filter by end date (RFC3339 format)
          schema:
            type: string
            format: date-time
          required: false
      responses:
        '200':
          description: Trades information
          content:
            application/json:
              schema:
                properties:
                  trade:
                    $ref: '#/components/schemas/Trade'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
  /history/performance/{symbol}:
    get:
      summary: Fetch historical performances for symbol
      operationId: findPerformanceBySymbol
      tags:
        - History
      parameters:
        - name: symbol
          in: path
          required: true
          description: The symbol for which to receive the performance data
          schema:
            type: string
            example: EURUSD
      responses:
        '200':
          description: >-
            Performance data. Values can be null when no market data has been
            collected for the given period, yet.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InstrumentPerformance'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
  /history/performance/all/{interval}:
    get:
      summary: Fetch performance data for all symbols
      operationId: getPerformanceForAllSymbols
      tags:
        - History
      parameters:
        - name: interval
          in: path
          required: true
          description: The interval for performance data
          schema:
            type: string
            enum:
              - 1H
              - 4H
              - 1D
              - 1W
              - 1M
              - 3M
              - 6M
              - 1Y
              - YTD
            example: 1D
      responses:
        '200':
          description: Performance data for all symbols
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PerformanceData'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error400'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
  /history/candles/{symbol}:
    get:
      summary: Fetch instrument candles
      operationId: findCandlesBySymbol
      tags:
        - History
      parameters:
        - name: symbol
          in: path
          required: true
          description: The symbol for which to receive the candles
          schema:
            type: string
            example: EURUSD
        - name: start
          in: query
          required: true
          description: The start time
          schema:
            type: string
            example: '2023-05-12T13:55:00Z'
        - name: end
          in: query
          required: false
          description: The end time
          schema:
            type: string
            example: '2023-05-13T13:55:00Z'
        - name: resolution
          in: query
          required: false
          description: >-
            The size of each candle where 0 means no aggregation (raw quotes
            delivered in candle format)
          schema:
            type: string
            enum:
              - '0'
              - '1'
              - '5'
              - '15'
              - '30'
              - '60'
              - 1D
      responses:
        '200':
          description: Candles
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InstrumentCandles'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
  /signals/price_alerts:
    get:
      summary: Fetch all active price alerts for user
      operationId: findActivePriceAlerts
      tags:
        - Signals
      responses:
        '200':
          description: Price alerts
          content:
            application/json:
              schema:
                properties:
                  priceAlerts:
                    type: array
                    items:
                      $ref: '#/components/schemas/PriceAlert'
    post:
      summary: Create a price alert
      operationId: createPriceAlert
      tags:
        - Signals
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePriceAlertRequest'
      responses:
        '200':
          description: Price alert created
          content:
            application/json:
              schema:
                properties:
                  priceAlert:
                    $ref: '#/components/schemas/PriceAlert'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error400'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
  /signals/price_alerts/{alertId}:
    delete:
      summary: Delete price alert
      operationId: deletePriceAlert
      tags:
        - Signals
      parameters:
        - name: alertId
          in: path
          required: true
          schema:
            type: integer
            example: 1000
      responses:
        '200':
          description: Alert deleted
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error400'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
  /signals/trend/{symbol}:
    get:
      summary: Get market trend for symbol
      operationId: findMarketTrend
      tags:
        - Signals
      parameters:
        - name: symbol
          in: path
          required: true
          schema:
            type: string
            example: GBPUSD
      responses:
        '200':
          description: Trend data
          content:
            application/json:
              schema:
                type: object
                properties:
                  symbol:
                    type: string
                  trend:
                    type: number
                    description: >-
                      Floating point value from `-1` to `1` where `-1` indicates
                      that all open positions on the platform are currently
                      short and `1` indicates all open positions are currently
                      long.
  /public/prop-trading/challenges:
    get:
      tags:
        - Prop Trading
      summary: List all prop challenges
      description: Retrieve a list of all prop challenges
      operationId: listPropChallenges
      responses:
        '200':
          description: List of prop challenges
          content:
            application/json:
              schema:
                properties:
                  count:
                    type: integer
                    example: 1
                  propChallenges:
                    type: array
                    items:
                      $ref: '#/components/schemas/PropChallenge'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
  /public/prop-trading/challenges/{id}:
    get:
      tags:
        - Prop Trading
      summary: Get a prop challenge
      description: Retrieve a specific prop challenge by ID
      operationId: getPropChallenge
      parameters:
        - name: id
          in: path
          required: true
          description: ID of the prop challenge to retrieve
          schema:
            type: string
            example: TEST
      responses:
        '200':
          description: Prop challenge retrieved
          content:
            application/json:
              schema:
                properties:
                  propChallenge:
                    $ref: '#/components/schemas/PropChallenge'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error404'
  /public/prop-trading/funnels:
    get:
      tags:
        - Prop Trading
      summary: List all prop funnels
      description: Retrieve a list of all prop funnels.
      operationId: listPropFunnels
      responses:
        '200':
          description: Successful retrieval of prop funnels
          content:
            application/json:
              schema:
                type: object
                properties:
                  count:
                    type: integer
                    example: 10
                  funnels:
                    type: array
                    items:
                      $ref: '#/components/schemas/APIPropFunnel'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
  /public/prop-trading/funnels/{id}:
    get:
      tags:
        - Prop Trading
      summary: Get a prop funnel
      description: Retrieve a specific prop funnel by ID
      operationId: getPropFunnel
      parameters:
        - name: id
          in: path
          required: true
          description: ID of the prop funnel to retrieve
          schema:
            type: string
            example: my-funnel-id
      responses:
        '200':
          description: Successfully retrieved the prop funnel
          content:
            application/json:
              schema:
                type: object
                properties:
                  funnel:
                    $ref: '#/components/schemas/APIPropFunnel'
        '404':
          description: Funnel not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error404'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
components:
  securitySchemes:
    StandardAuth:
      type: http
      scheme: bearer
      description: Requires a valid JWT as received from the cashier OAuth2 flow.
  schemas:
    CreateOrder:
      type: object
      required:
        - symbol
        - type
        - side
        - size
      properties:
        symbol:
          type: string
          example: EURUSD
        type:
          $ref: '#/components/schemas/OrderTypeEnum'
        side:
          $ref: '#/components/schemas/TradeSideEnum'
        size:
          type: string
          format: decimal
          example: '0.01'
        limitPrice:
          type: string
          format: decimal
          nullable: true
          example: '1.12345'
        stopPrice:
          type: string
          format: decimal
          nullable: true
          example: '1.12345'
        stopLoss:
          type: string
          format: decimal
          nullable: true
          example: '1.12345'
        trailingStopLossPct:
          $ref: '#/components/schemas/TrailingStopLossPct'
        takeProfit:
          type: string
          format: decimal
          nullable: true
          example: '1.12345'
        orderDuration:
          $ref: '#/components/schemas/OrderDuration'
        closePositionAfterSeconds:
          type: integer
          nullable: true
          example: 50
        invest:
          type: string
          format: decimal
          nullable: true
          example: '0.5'
        positionId:
          type: integer
          format: int64
          nullable: true
          example: 15
    ModifyOrder:
      type: object
      properties:
        size:
          type: string
          example: '0.01'
        limitPrice:
          type: string
          example: '1.12345'
        stopPrice:
          type: string
          example: '1.12345'
        stopLoss:
          type: string
          example: '1.12345'
        takeProfit:
          type: string
          example: '1.12345'
        trailingStopLossPct:
          $ref: '#/components/schemas/TrailingStopLossPct'
    Order:
      type: object
      properties:
        id:
          type: integer
          format: int64
          example: 356
        type:
          $ref: '#/components/schemas/OrderTypeEnum'
        symbol:
          type: string
          example: EURUSD
        side:
          $ref: '#/components/schemas/TradeSideEnum'
        reason:
          $ref: '#/components/schemas/OrderReasonEnum'
        positionId:
          type: integer
          format: int64
          nullable: true
          example: null
        limitPrice:
          type: string
          format: decimal
          nullable: true
          example: '0.6'
        stopPrice:
          type: string
          format: decimal
          nullable: true
          example: null
        size:
          type: string
          format: decimal
          example: '0.1'
        takeProfit:
          type: string
          format: decimal
          nullable: true
          example: null
        stopLoss:
          type: string
          format: decimal
          nullable: true
          example: null
        trailingStopLossPct:
          $ref: '#/components/schemas/TrailingStopLossPct'
        filledQuantity:
          type: string
          format: decimal
          nullable: true
          example: null
        placedAt:
          type: string
          format: date-time
          example: '2024-06-05T09:42:38.01044Z'
        executedAt:
          type: string
          format: date-time
          nullable: true
          example: null
        averagePrice:
          type: string
          format: decimal
          nullable: true
          example: null
        requestPrice:
          type: string
          format: decimal
          nullable: true
          example: null
        status:
          $ref: '#/components/schemas/OrderStatusEnum'
        orderDuration:
          $ref: '#/components/schemas/OrderDuration'
    Trade:
      type: object
      properties:
        id:
          type: integer
          format: int64
          example: 1
        accountId:
          type: integer
          format: int64
          example: 2
        orderId:
          type: integer
          format: int64
          example: 3
        positionId:
          type: integer
          format: int64
          example: 3
        symbol:
          type: string
          example: EURUSD
        side:
          $ref: '#/components/schemas/TradeSideEnum'
        price:
          type: string
          format: decimal
          example: '0.6'
        size:
          type: string
          format: decimal
          example: '0.1'
        profitLoss:
          type: string
          format: decimal
          example: '-0.23'
          nullable: true
        commission:
          type: string
          format: decimal
          example: '0.02'
        executedAt:
          type: string
          format: date-time
          example: null
    TrailingStopLossPct:
      type: number
      description: >-
        Percentage at which trailing stop loss is triggered. Must be between 0
        and 100.
      example: 5
    TrailingStopLossPrice:
      type: string
      format: decimal
      nullable: true
      description: Price at which trailing stop loss is triggered.
      example: '0.1'
    OrderStatusEnum:
      type: string
      enum:
        - new
        - pending
        - executing
        - filled
        - rejected
        - cancelled
        - timeout
    OrderTypeEnum:
      type: string
      enum:
        - market
        - limit
        - stop
    OrderReasonEnum:
      type: string
      enum:
        - user_trading
        - time_expired
        - invest_exceeded
        - stop_out
        - copytrading
        - stop_loss
        - take_profit
    OrderDuration:
      type: string
      enum:
        - GTC
        - GTD
        - GFD
        - FOK
        - IOC
    Instrument:
      type: object
      properties:
        symbol:
          type: string
          example: EURUSD
        ticker:
          type: string
          example: EURUSD
        full_name:
          type: string
          example: EURUSD
        description:
          type: string
          example: EURUSD
        exchange:
          type: string
          example: WINTRADO
        type:
          $ref: '#/components/schemas/InstrumentCategory'
    InstrumentCategory:
      type: string
      enum:
        - currencies
        - indices
        - commodities
        - cryptos
        - equities
    TradingViewInstrumentFull:
      type: object
      properties:
        ticker:
          type: string
          example: EURUSD
        name:
          type: string
          example: EURUSD
        full_name:
          type: string
          example: EURUSD
        description:
          type: string
          example: EURUSD
        type:
          $ref: '#/components/schemas/InstrumentCategory'
        session:
          type: string
          example: 24x7
        timezone:
          type: string
          example: Etc/UTC
        exchange:
          type: string
          example: WINTRADO
        listed_exchange:
          type: string
          example: WINTRADO
        format:
          type: string
          example: price
        minmov:
          type: integer
          example: 1
        pricescale:
          type: integer
          example: 100000
        has_intraday:
          type: boolean
          example: true
        has_daily:
          type: boolean
          example: true
        has_weekly_and_monthly:
          type: boolean
          example: false
        supported_resolutions:
          type: array
          items:
            type: string
          example:
            - '1'
            - '5'
            - '15'
            - '30'
            - '60'
            - '240'
            - 1D
        data_status:
          type: string
          example: streaming
    InstrumentsInfo:
      type: object
      properties:
        defaultInstrument:
          type: string
          example: EURUSD
        instruments:
          type: array
          items:
            $ref: '#/components/schemas/InstrumentInfo'
        timezone:
          type: string
          example: Europe/Berlin
        messageType:
          type: string
          example: InstrumentsInfo
    InstrumentInfo:
      type: object
      properties:
        category:
          $ref: '#/components/schemas/InstrumentCategory'
        contractSize:
          type: integer
          example: 100000
        currency:
          type: string
          example: USD
        decimals:
          type: integer
          example: 5
        marginCurrency:
          type: string
          example: EUR
        maxOrderSize:
          type: string
          format: decimal
          example: '3'
        minOrderSize:
          type: string
          format: decimal
          example: '0.01'
        precision:
          type: number
          format: double
          example: 0.00001
        sizes:
          type: object
          additionalProperties:
            type: string
            format: decimal
          example: {}
        stakeMode:
          type: string
          example: SPREAD_BETTING
        stepOrderSize:
          type: string
          format: decimal
          example: '0.01'
        swap3DayWeekday:
          type: string
          nullable: true
          example: null
        swapLong:
          type: string
          format: decimal
          nullable: true
          example: '2'
        swapMode:
          $ref: '#/components/schemas/SwapMode'
        swapShort:
          type: string
          format: decimal
          nullable: true
          example: '2'
        symbol:
          type: string
          example: EURUSD
        tradingHours:
          type: array
          items:
            $ref: '#/components/schemas/TradingSession'
    TradingSession:
      type: object
      properties:
        startTime:
          type: string
          example: MONDAY:00:00
        endTime:
          type: string
          example: SUNDAY:23:59
    SwapMode:
      type: string
      enum:
        - DISABLED
        - POINTS
    Account:
      type: object
      properties:
        id:
          type: integer
          example: 65
        tradingType:
          $ref: '#/components/schemas/TradingType'
        accountType:
          $ref: '#/components/schemas/AccountType'
        enabled:
          type: boolean
        disableReason:
          $ref: '#/components/schemas/AccountDisableReason'
        userTradingEnabled:
          type: boolean
        group:
          type: string
          example: group1
        leverage:
          type: integer
          example: 30
        balance:
          type: string
          example: '0'
        credit:
          type: string
          example: '0'
        equity:
          type: string
          example: '0'
        margin:
          type: string
          example: '0'
        marginFree:
          type: string
          example: '0'
        profitLoss:
          type: string
          example: '0'
        pendingWithdrawal:
          type: string
          example: '50.00'
        withdrawalAvailability:
          $ref: '#/components/schemas/WithdrawalAvailability'
        marginCall:
          type: boolean
        marginLevelPercent:
          type: number
          format: float
          example: 550
        stopOut:
          type: boolean
        isDemo:
          type: boolean
        currency:
          type: string
          example: USD
        updatedAt:
          type: string
          format: date-time
          example: '2024-05-29T09:45:03.754098Z'
        createdAt:
          type: string
          format: date-time
        name:
          type: string
          example: John Doe
        email:
          type: string
          example: john@doe.com
        country:
          type: string
          example: US
    TradingType:
      type: string
      enum:
        - HEDGING
        - NETTING
    AccountType:
      type: string
      enum:
        - REGULAR
        - FUNDED
        - CHALLENGE
    AccountDisableReason:
      type: string
      enum:
        - daily_drawdown_limit_breached
        - total_drawdown_limit_breached
        - inactivity_days_limit_breached
        - trading_days_limit_breached
        - account_passed
        - admin_requested
      example: admin_requested
    WithdrawalAvailability:
      type: string
      enum:
        - ENABLED
        - DISABLED_ACCOUNT_TYPE
        - DISABLED_BALANCE_TOO_LOW
        - DISABLED_OBJECTIVES_NOT_MET
        - DISABLED_PENDING_WITHDRAWAL
      example: ENABLED
    FundedAccount:
      allOf:
        - $ref: '#/components/schemas/Account'
        - type: object
          properties:
            fundedAccountTypeId:
              type: integer
              example: 1
            status:
              $ref: '#/components/schemas/PropAccountStatus'
            behavior:
              $ref: '#/components/schemas/FundedAccountBehavior'
            availableWithdrawalFunds:
              type: string
              example: '500.00'
            traderProfitShareFactor:
              type: string
              example: '0.80'
            limits:
              type: array
              items:
                $ref: '#/components/schemas/Limit'
            objectives:
              type: array
              items:
                $ref: '#/components/schemas/Objective'
    FundedAccountBehavior:
      type: string
      enum:
        - REGULAR
        - BINARY
    ChallengeAccount:
      allOf:
        - $ref: '#/components/schemas/Account'
        - type: object
          properties:
            propChallengeId:
              type: integer
              example: 10
            status:
              $ref: '#/components/schemas/PropAccountStatus'
            startedAt:
              type: string
              format: date-time
            endedAt:
              type: string
              format: date-time
              nullable: true
            limits:
              type: array
              items:
                $ref: '#/components/schemas/Limit'
            objectives:
              type: array
              items:
                $ref: '#/components/schemas/Objective'
    Position:
      type: object
      properties:
        positionId:
          type: integer
          format: int64
          example: 183
        symbol:
          type: string
          example: EURUSD
        status:
          $ref: '#/components/schemas/PositionStatusEnum'
        size:
          type: string
          format: decimal
          example: '0.01'
        side:
          $ref: '#/components/schemas/TradeSideEnum'
        invest:
          type: string
          format: decimal
          nullable: true
          example: null
        closePositionAfterSeconds:
          type: integer
          nullable: true
          example: null
        openPrice:
          type: string
          format: decimal
          nullable: true
          example: '1.09775'
        openedAt:
          type: string
          format: date-time
          nullable: true
          example: '2024-05-29T08:28:23.89257Z'
        profitLoss:
          type: string
          format: decimal
          example: '-0.23'
        swap:
          type: string
          format: decimal
          example: '0'
        margin:
          type: string
          format: decimal
          example: '21.96'
        commission:
          type: string
          format: decimal
          example: '0.01'
        stopLoss:
          type: string
          format: decimal
          nullable: true
          example: null
        trailingStopLossPct:
          $ref: '#/components/schemas/TrailingStopLossPct'
        trailingStopLossPrice:
          $ref: '#/components/schemas/TrailingStopLossPrice'
        takeProfit:
          type: string
          format: decimal
          nullable: true
          example: null
        platform:
          $ref: '#/components/schemas/TradingPlatformsEnum'
    TradeSideEnum:
      type: string
      enum:
        - buy
        - sell
    TradingPlatformsEnum:
      type: string
      enum:
        - wintrado
        - pro
        - neo
        - admin
    PositionStatusEnum:
      type: string
      enum:
        - open
        - error-on-closing
        - closed
    PerformanceData:
      type: object
      properties:
        symbol:
          type: string
          example: GBPUSD
        performance:
          type: string
          example: '5.5'
    ModifyPosition:
      type: object
      properties:
        stopLoss:
          type: string
          example: '1.12345'
        takeProfit:
          type: string
          example: '1.12345'
        trailingStopLossPct:
          $ref: '#/components/schemas/TrailingStopLossPct'
    Positions:
      type: object
      properties:
        positions:
          type: array
          items:
            $ref: '#/components/schemas/Position'
    Orders:
      type: object
      properties:
        orders:
          type: array
          items:
            $ref: '#/components/schemas/Order'
    Instruments:
      type: object
      properties:
        instruments:
          type: array
          items:
            $ref: '#/components/schemas/Instrument'
        ok:
          type: boolean
          example: true
    InstrumentPerformance:
      type: object
      properties:
        oneWeekPerformance:
          type: string
          example: '-1.85%'
        oneMonthPerformance:
          type: string
          example: '-2.00%'
        threeMonthsPerformance:
          type: string
          example: '-2.00%'
        sixMonthsPerformance:
          type: string
          example: '-2.00%'
        yearPerformance:
          type: string
          example: null
        YTDPerformance:
          type: string
          example: null
    InstrumentCandles:
      type: object
      properties:
        candles:
          type: array
          items:
            $ref: '#/components/schemas/Candle'
    Candle:
      type: object
      properties:
        start:
          type: integer
          description: Opening time of this candle as timestamp with ms precision
          example: 1683899700000
        end:
          type: integer
          description: Closing time of this candle as timestamp with ms precision
          example: 1683899700000
        open:
          type: string
          example: '1.09562'
        close:
          type: string
          example: '1.09562'
        high:
          type: string
          example: '1.09562'
        low:
          type: string
          example: '1.09562'
    CreatePriceAlertRequest:
      type: object
      required:
        - symbol
        - price
        - condition
      properties:
        symbol:
          type: string
          example: EURUSD
        price:
          type: string
          format: decimal
          example: '1.12345'
        condition:
          $ref: '#/components/schemas/PriceAlertConditionEnum'
        expirationDate:
          type: string
          format: date-time
          nullable: true
          example: '2024-12-31T23:59:59Z'
    PriceAlert:
      type: object
      properties:
        id:
          type: integer
          example: 1
        accountId:
          type: integer
          example: 123
        symbol:
          type: string
          example: EURUSD
        price:
          type: string
          format: decimal
          example: '1.12345'
        condition:
          $ref: '#/components/schemas/PriceAlertConditionEnum'
        expirationDate:
          type: string
          format: date-time
          nullable: true
          example: '2024-12-31T23:59:59Z'
    PriceAlertConditionEnum:
      type: string
      enum:
        - BID_BELOW
        - BID_ABOVE
        - ASK_BELOW
        - ASK_ABOVE
    PropChallenge:
      type: object
      properties:
        id:
          type: integer
          example: 1
        title:
          type: string
          example: challenge123
        leverage:
          type: integer
          example: 100
        initialBalance:
          type: string
          format: decimal
          example: '100000.00'
        minTradingDays:
          type: integer
          example: 10
        maxTradingDays:
          type: integer
          example: 30
        maxInactivityDays:
          type: integer
          example: 5
        profitTargetFactor:
          type: string
          format: decimal
          example: '0.5'
        maxDailyDrawdownFactor:
          type: string
          format: decimal
          example: '0.1'
        maxTotalDrawdownFactor:
          type: string
          format: decimal
          example: '0.2'
        accountGroup:
          type: string
          example: GroupA
        accountCurrency:
          type: string
          example: USD
    PropAccountStatus:
      type: string
      enum:
        - ACTIVE
        - PASSED
        - FAILED
      description: Status of the prop trading account
      example: FAILED
    ChallengeFailReason:
      type: string
      enum:
        - drawdown_limit_breached
        - trading_days_limit_breached
        - inactivity_limit_breached
        - admin_requested
      description: Reason for challenge failure
      example: drawdown_limit_breached
    Limit:
      type: object
      properties:
        name:
          type: string
          description: Name of the limit
          example: maxDailyDrawdown
        limit:
          type: string
          format: decimal
          description: Limit value
          example: '2000.00'
        current:
          type: string
          format: decimal
          description: Current value
          example: '2500.00'
        isBreached:
          type: boolean
          description: Indicates if the limit has been breached
          example: true
        isFactor:
          type: boolean
          description: Indicates if the limit value is a factor amount
          example: true
    Objective:
      type: object
      properties:
        name:
          type: string
          description: Name of the objective
          example: minTradingDays
        target:
          type: string
          format: integer
          description: Target value for the objective
          example: '100'
        current:
          type: string
          format: integer
          description: Current progress value
          example: '20'
        status:
          $ref: '#/components/schemas/PropAccountStatus'
        isFactor:
          type: boolean
          description: Indicates if the objective value is a factor amount
          example: true
    FundedAccountType:
      type: object
      properties:
        id:
          type: integer
          example: 1
        title:
          type: string
          example: Demo
        leverage:
          type: integer
          example: 100
        initialBalance:
          type: string
          format: decimal
          example: '100000.00'
        minTradingDays:
          type: integer
          example: 10
        maxInactivityDays:
          type: integer
          example: 30
        maxDailyDrawdownFactor:
          type: string
          format: decimal
          example: '0.05'
        maxTotalDrawdownFactor:
          type: string
          format: decimal
          example: '0.10'
        accountGroup:
          type: string
          example: Group1
        accountCurrency:
          type: string
          example: USD
        behavior:
          type: string
          example: REGULAR
        profitTargetFactor:
          type: string
          format: decimal
          example: '0.5'
        traderProfitShareFactor:
          type: string
          format: decimal
          example: '0.7'
    APIPropFunnel:
      type: object
      properties:
        id:
          type: string
          example: my-funnel-id
        firstChallenge:
          $ref: '#/components/schemas/PropChallenge'
        secondChallenge:
          $ref: '#/components/schemas/PropChallenge'
        thirdChallenge:
          $ref: '#/components/schemas/PropChallenge'
        fundedAccountType:
          $ref: '#/components/schemas/FundedAccountType'
      description: >-
        A complete view of a prop funnel with up to three challenges and a
        funded account type.
    DailyBalancesEquities:
      type: object
      properties:
        balance:
          type: string
          format: decimal
          example: '10000.00'
        equity:
          type: string
          format: decimal
          example: '12500.00'
        date:
          type: string
          format: date-time
          example: '2024-12-01T00:00:00Z'
    DailyAccountHistory:
      type: object
      properties:
        accountId:
          type: integer
          example: 1
        values:
          type: array
          items:
            $ref: '#/components/schemas/DailyBalancesEquities'
    MarginCalculationResponse:
      type: object
      required:
        - margin
        - freeMarginExceeded
        - marginCall
      properties:
        margin:
          type: string
          description: Margin that would be reserved if the order were placed.
          example: '1325.67'
        freeMarginExceeded:
          type: boolean
          description: >
            **true** when the order would require more margin than the account’s
            current free margin.
          example: false
        marginCall:
          type: boolean
          description: >
            **true** when placing the order would cause the account to drop
            below its margin-call level.
          example: false
    Error400:
      type: object
      required:
        - message
      properties:
        message:
          type: string
    Error404:
      type: object
      required:
        - message
      properties:
        message:
          type: string
    Error422:
      type: object
      required:
        - message
      properties:
        ok:
          type: boolean
          example: false
        errors:
          type: array
          items:
            type: string
    Error500:
      type: object
      required:
        - message
      properties:
        ok:
          type: boolean
          example: false
        error:
          type: string
