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

# Cài đặt chốt lời, cắt lỗ cho vị thế

> Cài đặt cấu hình chốt lời, cắt lỗ cho vị thế đang nắm giữ theo `positionId.`

Khuyến nghị: Body Request gửi lên đầy đủ các trường thông tin.



## OpenAPI

````yaml https://cdn.entrade.com.vn/dnse-openapi/doc/dnse-openapi-2026-07-23.yaml post /positions/{positionId}/pnl-configs
openapi: 3.0.0
info:
  title: OpenAPI-V2-Spec 260730
  version: 1.0.0
  description: DNSE OpenAPI spec and tests
servers:
  - url: https://openapi-uat.dnse.com.vn
security: []
paths:
  /positions/{positionId}/pnl-configs:
    parameters:
      - name: positionId
        in: path
        required: true
        description: 'Id vị thế '
        schema:
          type: integer
        example: 177952229647243
    post:
      tags:
        - trading
      summary: Cài đặt chốt lời, cắt lỗ cho vị thế
      description: >-
        Cài đặt cấu hình chốt lời, cắt lỗ cho vị thế đang nắm giữ theo
        `positionId.`


        Khuyến nghị: Body Request gửi lên đầy đủ các trường thông tin.
      parameters:
        - name: marketType
          in: query
          description: |-
            Loại thị trường 
            - DERIVATIVE: Deal phái sinh (chỉ hỗ trợ phái sinh)
          schema:
            type: string
          example: DERIVATIVE
        - name: X-API-Key
          in: header
          description: API Key được cấp khi đăng ký dịch vụ
          schema:
            type: string
          example: '{{apiKey}}'
        - name: X-Aux-Date
          in: header
          description: Thời gian thực hiện yêu cầu
          schema:
            type: string
          example: '{{date}}'
        - name: X-Signature
          in: header
          description: Chữ ký xác thực yêu cầu
          schema:
            type: string
          example: '{{signature}}'
        - name: version
          in: header
          description: 'Phiên bản API '
          schema:
            type: string
          example: '2026-07-23'
        - name: trading-token
          in: header
          description: Token đặt lệnh
          schema:
            type: string
          example: '{{tradingToken}}'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                takeProfit:
                  type: object
                  description: Cấu hình chốt lời (Take Profit)
                  properties:
                    enabled:
                      type: boolean
                      example: true
                      description: Bật/tắt chức năng chốt lời
                    strategy:
                      type: string
                      example: DELTA_PRICE
                      description: |-
                        Chiến lược kích hoạt chốt lời 
                          - PNL_RATE: Kích hoạt theo tỷ lệ %
                          - DELTA_PRICE: Kích hoạt theo mức chênh lệch giá                       
                    rate:
                      type: number
                      example: 0.52
                      description: >-
                        Tỷ lệ % so với giá hòa vốn, dùng để kích hoạt chốt lời
                        khi strategy = PNL_RATE. Giá trị phải lớn hơn 0
                      format: double
                    deltaPrice:
                      type: number
                      example: 162.8
                      description: >-
                        Mức chênh lệch giá so với giá hòa vốn, dùng để kích hoạt
                        chốt lời khi strategy = DELTA_PRICE. Giá trị phải lớn
                        hơn 0
                      format: double
                    orderMethod:
                      type: string
                      example: FASTEST
                      description: >-
                        Phương thức đặt lệnh khi điều kiện chốt lời được kích
                        hoạt.
                          - FASTEST: Lệnh khớp ngay với giá đặt là giá trần/sàn tùy theo chiều vị thế Bán/Mua
                          - DELTA_PRICE: Lệnh đặt theo biên độ giá so với giá kích hoạt 
                    orderDeltaPrice:
                      type: integer
                      format: double
                      example: 2
                      description: >-
                        Biên độ giá đặt lệnh so với giá kích hoạt khi
                        orderMethod = DELTA_PRICE. Có thể là số âm, số dương
                        hoặc bằng 0
                stopLoss:
                  type: object
                  description: Cấu hình cắt lỗ (Stop Loss)
                  properties:
                    enabled:
                      type: boolean
                      example: null
                      description: Bật/tắt chức năng cắt lỗ
                    strategy:
                      type: string
                      example: DELTA_PRICE
                      description: |-
                        Chiến lược kích hoạt cắt lỗ 
                          - PNL_RATE: Kích hoạt theo tỷ lệ %
                          - DELTA_PRICE: Kích hoạt theo mức chênh lệch giá   
                    rate:
                      type: number
                      example: -0.34
                      format: double
                      description: >-
                        Tỷ lệ % so với giá hòa vốn, dùng để kích hoạt cắt lỗ khi
                        strategy = PNL_RATE. Giá trị hợp lệ trong khoảng [-1.0,
                        0)
                    deltaPrice:
                      type: number
                      format: double
                      example: 50.3
                      description: >-
                        Mức chênh lệch giá so với giá hòa vốn, dùng để kích hoạt
                        cắt lỗ khi strategy = DELTA_PRICE. Giá trị phải lớn hơn
                        0
                    orderMethod:
                      type: string
                      example: FASTEST
                      description: >-
                        Phương thức đặt lệnh khi điều kiện chốt lời được kích
                        hoạt.
                          - FASTEST: Lệnh khớp ngay với giá đặt là giá trần/sàn tùy theo chiều vị thế Bán/Mua
                          - DELTA_PRICE: Lệnh đặt theo biên độ giá so với giá kích hoạt 
                    orderDeltaPrice:
                      type: number
                      format: double
                      description: >-
                        Biên độ giá đặt lệnh so với giá kích hoạt khi
                        orderMethod = DELTA_PRICE. Có thể là số âm, số dương
                        hoặc bằng 0
                      example: 10.5
                    trailingEnabled:
                      type: boolean
                      example: true
                      description: >-
                        Bật/tắt cơ chế Trailing Stop. Lưu ý cơ chế này chỉ hoạt
                        động khi chức năng cắt lỗ được bật
            example:
              takeProfit:
                enabled: true
                strategy: DELTA_PRICE
                rate: 0.52
                deltaPrice: 162.8
                orderMethod: FASTEST
                orderDeltaPrice: 2
              stopLoss:
                enabled: true
                strategy: PNL_RATE
                rate: -0.34
                deltaPrice: 50.3
                orderMethod: DELTA_PRICE
                orderDeltaPrice: 10.5
                trailingEnabled: true
      responses:
        '200':
          description: OK
          headers:
            Cache-Control:
              schema:
                type: string
              example: no-cache, no-store, max-age=0, must-revalidate
            Content-Length:
              schema:
                type: integer
              example: 565
            Date:
              schema:
                type: string
              example: Wed, 03 Jun 2026 07:44:49 GMT
            Expires:
              schema:
                type: integer
              example: 0
            Pragma:
              schema:
                type: string
              example: no-cache
            Vary:
              schema:
                type: string
              example: Origin
            X-Content-Type-Options:
              schema:
                type: string
              example: nosniff
            X-Ratelimit-Limit:
              schema:
                type: integer
              example: -1
            X-Ratelimit-Remaining:
              schema:
                type: integer
              example: 0
            X-Ratelimit-Reset:
              schema:
                type: integer
              example: 0
            X-Tyk-Api-Expires:
              schema:
                type: string
              example: Thu, 02 Jan 3000 15:04:00 UTC
            X-Xss-Protection:
              schema:
                type: integer
              example: 0
          content:
            application/json:
              schema:
                type: object
                properties:
                  accountNo:
                    type: string
                    example: '0001179019'
                    description: Số tiểu khoản chứng khoán
                  positionId:
                    type: integer
                    example: 177952229647243
                    description: ID vị thế
                    format: int64
                  configs:
                    type: object
                    example:
                      takeProfit:
                        enabled: true
                        strategy: DELTA_PRICE
                        rate: 0.52
                        deltaPrice: 162.8
                        orderMethod: FASTEST
                        orderDeltaPrice: 2
                      stopLoss:
                        enabled: true
                        strategy: PNL_RATE
                        rate: -0.34
                        deltaPrice: 50.3
                        orderMethod: DELTA_PRICE
                        orderDeltaPrice: 10.5
                        trailingEnabled: true
                    description: Cấu hình chốt lời và cắt lỗ của vị thế
                    properties:
                      takeProfit:
                        type: object
                        example:
                          enabled: true
                          strategy: DELTA_PRICE
                          rate: 0.52
                          deltaPrice: 162.8
                          orderMethod: FASTEST
                          orderDeltaPrice: 2
                        description: Cấu hình chốt lời (Take Profit)
                        properties:
                          enabled:
                            type: boolean
                            example: true
                            description: Bật/tắt chức năng chốt lời
                          strategy:
                            type: string
                            example: DELTA_PRICE
                            description: |-
                              Chiến lược kích hoạt chốt lời
                              - PNL_RATE: Kích hoạt theo tỷ lệ %
                              - DELTA_PRICE: Kích hoạt theo mức chênh lệch giá
                          rate:
                            type: number
                            example: 0.52
                            description: >-
                              Tỷ lệ % so với giá hòa vốn, dùng để kích hoạt chốt
                              lời khi strategy = PNL_RATE. Giá trị phải lớn hơn
                              0
                            format: double
                          deltaPrice:
                            type: number
                            example: 162.8
                            description: >-
                              Mức chênh lệch giá so với giá hòa vốn, dùng để
                              kích hoạt chốt lời khi strategy = DELTA_PRICE. Giá
                              trị phải lớn hơn 0
                            format: double
                          orderMethod:
                            type: string
                            example: FASTEST
                            description: >-
                              Phương thức đặt lệnh khi điều kiện chốt lời được
                              kích hoạt.

                              - FASTEST: Lệnh khớp ngay với giá đặt là giá
                              trần/sàn tùy theo chiều vị thế Bán/Mua

                              - DELTA_PRICE: Lệnh đặt theo biên độ giá so với
                              giá kích hoạt
                          orderDeltaPrice:
                            type: integer
                            example: 2
                            description: >-
                              Biên độ giá đặt lệnh khi orderMethod =
                              DELTA_PRICE. Bằng 0 khi orderMethod = FASTEST
                            format: int32
                      stopLoss:
                        type: object
                        example:
                          enabled: true
                          strategy: PNL_RATE
                          rate: -0.34
                          deltaPrice: 50.3
                          orderMethod: DELTA_PRICE
                          orderDeltaPrice: 10.5
                          trailingEnabled: true
                        description: Cấu hình cắt lỗ (Stop Loss)
                        properties:
                          enabled:
                            type: boolean
                            example: true
                            description: Bật/tắt chức năng cắt lỗ
                          strategy:
                            type: string
                            example: PNL_RATE
                            description: |-
                              Chiến lược kích hoạt cắt lỗ
                              - PNL_RATE: Kích hoạt theo tỷ lệ %
                              - DELTA_PRICE: Kích hoạt theo mức chênh lệch giá.
                          rate:
                            type: number
                            example: -0.34
                            description: >-
                              Tỷ lệ % so với giá hòa vốn, dùng để kích hoạt chốt
                              lời khi strategy = PNL_RATE. Giá trị hợp lệ trong
                              khoảng [-1.0, 0)
                            format: double
                          deltaPrice:
                            type: number
                            example: 50.3
                            description: >-
                              Mức chênh lệch giá so với giá hòa vốn, dùng để
                              kích hoạt chốt lời khi strategy = DELTA_PRICE. Giá
                              trị phải lớn hơn 0
                            format: double
                          orderMethod:
                            type: string
                            example: DELTA_PRICE
                            description: >-
                              Phương thức đặt lệnh khi điều kiện chốt lời được
                              kích hoạt.

                              - FASTEST: Lệnh khớp ngay với giá đặt là giá
                              trần/sàn tùy theo chiều vị thế Bán/Mua

                              - DELTA_PRICE: Lệnh đặt theo biên độ giá so với
                              giá kích hoạt
                          orderDeltaPrice:
                            type: number
                            example: 10.5
                            description: >-
                              Biên độ giá đặt lệnh khi orderMethod =
                              DELTA_PRICE. Bằng 0 khi orderMethod = FASTEST
                            format: float
                          trailingEnabled:
                            type: boolean
                            example: true
                            description: >-
                              Bật/tắt cơ chế Trailing Stop. Lưu ý cơ chế này chỉ
                              hoạt động khi chức năng cắt lỗ được bật
                  createdDate:
                    type: string
                    example: '2026-06-02T02:47:36.384761Z'
                    description: Thời điểm cấu hình được tạo
                    format: date-time
                  modifiedDate:
                    type: string
                    example: '2026-06-03T07:52:08.00923505Z'
                    description: Thời điểm cập nhật cấu hình gần nhất
                    format: date-time
              example:
                positionId: 177952229647243
                configs:
                  takeProfit:
                    enabled: true
                    strategy: DELTA_PRICE
                    rate: 0.52
                    deltaPrice: 162.8
                    orderMethod: FASTEST
                    orderDeltaPrice: 2
                  stopLoss:
                    enabled: true
                    strategy: PNL_RATE
                    rate: -0.34
                    deltaPrice: 50.3
                    orderMethod: DELTA_PRICE
                    orderDeltaPrice: 10.5
                    trailingEnabled: true
                createdDate: '2026-06-02T02:47:36.384761Z'
                modifiedDate: '2026-06-03T07:44:44.235941815Z'
        '400':
          description: Yêu cầu không hợp lệ
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                  message:
                    type: string
                  status:
                    type: integer
              example:
                code: OA-003
                message: Thông tin nhập không hợp lệ
                status: 400
        '500':
          description: Lỗi hệ thống
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                  message:
                    type: string
                  status:
                    type: integer
              example:
                code: OA-009
                message: Lỗi hệ thống
                status: 500

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.