> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ekiden.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Set Trading Stop

> Set the take profit, stop loss or trailing stop for the position.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/position/trading-stop
openapi: 3.1.0
info:
  title: ekiden-gateway
  description: >-
    API Gateway and WebSocket proxy based on Axum and Utoipa, handling auth,
    rate limiting, and connection buffering.
  license:
    name: ''
  version: 0.1.1
servers:
  - url: https://api.ekiden.fi/
    description: Production
  - url: https://api.staging.ekiden.fi/
    description: Staging
  - url: https://api.dev.ekiden.fi/
    description: Development
  - url: http://localhost:4020/
    description: Local
security: []
paths:
  /api/v1/position/trading-stop:
    post:
      tags:
        - Position
      summary: Set Trading Stop
      description: Set the take profit, stop loss or trailing stop for the position.
      operationId: set_trading_stop
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetTradingStopRequest'
        required: true
      responses:
        '200':
          description: Trading stop set
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SetTradingStopResponse'
      security:
        - bearer_auth: []
components:
  schemas:
    SetTradingStopRequest:
      type: object
      description: Set the take profit, stop loss or trailing stop for the position.
      required:
        - symbol
        - sub_account_address
      properties:
        active_price:
          type:
            - string
            - 'null'
        sl_size:
          type:
            - string
            - 'null'
          description: >-
            Stop loss size

            valid for TP/SL partial mode, note: the value of tpSize and slSize
            must equal
        sub_account_address:
          type: string
        symbol:
          $ref: '#/components/schemas/Symbol'
        tp_size:
          type:
            - string
            - 'null'
          description: >-
            Take profit size

            valid for TP/SL partial mode, note: the value of tpSize and slSize
            must equal
        tpsl:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TpSl'
        trailing_stop:
          type:
            - string
            - 'null'
    SetTradingStopResponse:
      type: object
      description: Response for setting trading stop.
      required:
        - success
        - time
      properties:
        success:
          type: boolean
        time:
          type: string
          format: date-time
          example: '1672531200000'
    Symbol:
      type: string
      example: BTCUSDC
    TpSl:
      type: object
      required:
        - mode
      properties:
        mode:
          $ref: '#/components/schemas/TpSlMode'
        stop_loss:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TpSlSpec'
        take_profit:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TpSlSpec'
    TpSlMode:
      type: string
      enum:
        - Full
        - Partial
    TpSlSpec:
      oneOf:
        - type: object
          required:
            - market
          properties:
            market:
              type: object
              required:
                - trigger_price
                - trigger_by
              properties:
                trigger_by:
                  $ref: '#/components/schemas/TriggerBy'
                trigger_price:
                  type: string
        - type: object
          required:
            - limit
          properties:
            limit:
              type: object
              required:
                - trigger_price
                - limit_price
                - trigger_by
              properties:
                limit_price:
                  type: string
                trigger_by:
                  $ref: '#/components/schemas/TriggerBy'
                trigger_price:
                  type: string
    TriggerBy:
      type: string
      enum:
        - LastPrice
        - IndexPrice
        - MarkPrice
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer

````