> ## 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.

# Sửa lệnh



## OpenAPI

````yaml /vi/openapi/dnse.openapi.yaml put /accounts/{accountNo}/orders/{orderId}
openapi: 3.0.0
info:
  title: DNSE OpenAPI (2026-09-25)
  version: 2.0.0
  description: DNSE OpenAPI spec
servers:
  - url: https://openapi.dnse.com.vn
    description: Production
  - url: https://sb-openapi.dnse.com.vn
    description: Sanbox
security: []
tags:
  - name: trading
    description: Xác thực và các hoạt động đặt lệnh.
    x-group: Giao dịch
  - name: account
    description: Tài khoản, số dư, khoản vay, lệnh và vị thế.
    x-group: Tài khoản
  - name: market
    description: Thông tin mã chứng khoán, báo giá, OHLC và giao dịch.
    x-group: Dữ liệu thị trường
paths:
  /accounts/{accountNo}/orders/{orderId}:
    parameters:
      - name: accountNo
        in: path
        required: true
        description: Số tiểu khoản
        deprecated: false
        schema:
          type: string
        example: '0001179019'
      - name: orderId
        in: path
        required: true
        description: Mã lệnh giao dịch
        deprecated: false
        schema:
          type: string
        example: '96'
    put:
      tags:
        - trading
      summary: Sửa lệnh
      operationId: account_replaceOrder
      parameters:
        - $ref: '#/components/parameters/XApiKey'
        - $ref: '#/components/parameters/XAuxDate'
        - $ref: '#/components/parameters/XSignature'
        - $ref: '#/components/parameters/TradingToken'
        - name: marketType
          in: query
          required: true
          description: |-
            Loại thị trường 
            - STOCK: Gói vay giao dịch cơ sở
            - DERIVATIVE: Gói vay giao dịch phái sinh
          deprecated: false
          schema:
            $ref: '#/components/schemas/MarketType'
          example: DERIVATIVE
        - name: orderCategory
          in: query
          required: true
          description: Phân loại lệnh thường, lệnh điều kiện (mặc định NORMAL)
          deprecated: false
          schema:
            $ref: '#/components/schemas/OrderCategory'
          example: NORMAL
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrderReplaceRequest'
            example:
              price: 1851
              quantity: 3
      responses:
        '200':
          description: OK
          headers:
            Content-Length:
              $ref: '#/components/headers/ContentLength'
            Date:
              $ref: '#/components/headers/Date'
            Vary:
              $ref: '#/components/headers/Vary'
            X-Ratelimit-Limit:
              $ref: '#/components/headers/XRateLimitLimit'
            X-Ratelimit-Remaining:
              $ref: '#/components/headers/XRateLimitRemaining'
            X-Ratelimit-Reset:
              $ref: '#/components/headers/XRateLimitReset'
            X-Tyk-Api-Expires:
              schema:
                type: string
              example: Thu, 02 Jan 3000 15:04:00 UTC
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderReplaceResponse'
              example:
                id: 1626
                accountNo: '0001179019'
                side: NS
                loanPackageId: 2278
                symbol: 41I1G4000
                orderType: LO
                orderCategory: NORMAL
                price: 1851
                quantity: 3
                fillQuantity: 0
                canceledQuantity: 0
                marketType: DERIVATIVE
                transDate: '2026-03-16'
                createdDate: '2026-03-24T04:09:50.761146893Z'
                modifiedDate: '2026-03-24T04:14:21.004856492Z'
        '400':
          $ref: '#/components/responses/BadRequest'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    XApiKey:
      name: X-Api-Key
      in: header
      required: true
      description: >-
        API key được cấp khi đăng ký dịch vụ DNSE OpenAPI.

        Ví dụ:
        `b3JnOmRuc2UgaWQ6MjdlZTc1MzcxZGFkNTY0NmYzYTM2NDk1ZGE3OGNiOGQgaDptdXJtdXIxMjg=`
      schema:
        type: string
    XAuxDate:
      name: X-Aux-Date
      in: header
      required: true
      description: |-
        Thời gian thực hiện request, dùng trong cơ chế ký request của DNSE.
        Ví dụ: `Sat, 01 May 2026 14:24:23 +0000`
      schema:
        type: string
    XSignature:
      name: X-Signature
      in: header
      required: true
      description: >-
        Chữ ký xác thực request được tạo từ API key secret và X-Aux-Date.

        Ví dụ: `Signature
        keyId="b3JnOmRuc2UgaWQ6MjdlZTc1MzcxZGFkNTY0NmYzYTM2NDk1ZGE3OGNiOGQgaDptdXJtdXIxMjg=",algorithm="hmac-sha256",headers="(request-target)
        x-aux-date",signature="rfbVXHDUi%2B%2FsOkLXle7O17Qm%2F05cbISSR%2BDcFrBHfqQ%3D",nonce="4add8c3264e4492b9f8ecde0cf26b523"`
      schema:
        type: string
    TradingToken:
      name: trading-token
      in: header
      required: true
      description: >-
        Trading token dùng cho các operation đặt, sửa, hủy lệnh hoặc đóng vị
        thế.

        Ví dụ: `9ab81e9c-8a81-45aa-8190-b69a1c179d52`
      schema:
        type: string
  schemas:
    MarketType:
      type: string
      description: |-
        Loại thị trường.

        - `STOCK`: Giao dịch cơ sở
        - `DERIVATIVE`: Giao dịch phái sinh
        - `BOND`: Giao dịch trái phiếu
      enum:
        - STOCK
        - DERIVATIVE
        - BOND
      x-enum-descriptions:
        - Giao dịch cơ sở
        - Giao dịch phái sinh
        - Giao dịch trái phiếu
      x-enum-varnames:
        - STOCK
        - DERIVATIVE
        - BOND
      example: STOCK
    OrderCategory:
      type: string
      description: |-
        Phân loại lệnh.

        - `NORMAL`: Lệnh thường
        - `STOP`: Lệnh dừng có điều kiện
        - `OCO`: Lệnh OCO phái sinh
        - `CONDITIONAL`: Lệnh điều kiện
      enum:
        - NORMAL
        - STOP
        - OCO
        - CONDITIONAL
      x-enum-descriptions:
        - Lệnh thường
        - Lệnh dừng có điều kiện
        - Lệnh OCO phái sinh
        - Lệnh điều kiện
      x-enum-varnames:
        - NORMAL
        - STOP
        - OCO
        - CONDITIONAL
      example: NORMAL
    OrderReplaceRequest:
      type: object
      properties:
        price:
          type: number
          format: double
          example: 1851
          description: |-
            Giá mới cho lệnh LO
            - Đối với lệnh cơ sở, có thể sửa cả giá và khối lượng
            - Đối với lệnh phái sinh, chỉ được sửa hoặc giá hoặc khối lượng
        quantity:
          type: integer
          format: int32
          example: 3
          description: >-
            Khối lượng mới

            - Đối với lệnh phái sinh, khối lượng mới phải lớn hơn khối lượng đã
            khớp (nếu có) của lệnh đã đặt
    OrderReplaceResponse:
      type: object
      properties:
        id:
          type: integer
          format: int32
          example: 1626
          description: Id lệnh giao dịch
        accountNo:
          type: string
          example: '0001179019'
          description: Số tiểu khoản
        side:
          allOf:
            - $ref: '#/components/schemas/OrderSide'
          example: NS
          description: |-
            Chiều đặt lệnh
            - NB: Mua
            - NS: Bán
        loanPackageId:
          type: integer
          format: int32
          example: 2278
          description: Mã gói vay
        symbol:
          type: string
          example: 41I1G4000
          description: Mã chứng khoán
        orderType:
          allOf:
            - $ref: '#/components/schemas/OrderType'
          example: LO
          description: |-
            Loại lệnh
            - LO: Lệnh giới hạn
            - MOK/MAK/MTL: Lệnh thị trường
            - ATO/ATC: Lệnh phiên định kỳ mở cửa/đóng cửa
            - PLO: Lệnh khớp lệnh sau giờ
        orderCategory:
          allOf:
            - $ref: '#/components/schemas/OrderCategory'
          example: NORMAL
          description: Phân loại lệnh thường (mặc định NORMAL)
        price:
          type: number
          format: double
          example: 1851
          description: Giá đặt
        quantity:
          type: integer
          format: int32
          example: 3
          description: Khối lượng đặt
        fillQuantity:
          type: integer
          format: int32
          example: 0
          description: Khối lượng khớp
        canceledQuantity:
          type: integer
          format: int32
          example: 0
          description: Khối lượng đã hủy
        marketType:
          allOf:
            - $ref: '#/components/schemas/MarketType'
          example: DERIVATIVE
          description: |-
            Loại thị trường
            - STOCK: Lệnh cơ sở
            - DERIVATIVE: Lệnh phái sinh
        transDate:
          type: string
          example: '2026-03-16'
          description: Ngày giao dịch
        createdDate:
          type: string
          format: date-time
          example: '2026-03-24T04:09:50.761146893Z'
          description: Thời điểm tạo
        modifiedDate:
          type: string
          format: date-time
          example: '2026-03-24T04:14:21.004856492Z'
          description: Thời điểm cập nhật
    OrderSide:
      type: string
      description: |-
        Chiều đặt lệnh hoặc vị thế.

        - `NB`: Mua
        - `NS`: Bán
      enum:
        - NB
        - NS
      x-enum-descriptions:
        - Mua
        - Bán
      x-enum-varnames:
        - BUY
        - SELL
      example: NB
    OrderType:
      type: string
      description: |-
        Loại lệnh.

        - `LO`: Lệnh giới hạn
        - `MOK`: Lệnh thị trường khớp toàn bộ hoặc hủy
        - `MAK`: Lệnh thị trường khớp một phần và hủy phần còn lại
        - `MTL`: Lệnh thị trường khớp theo giá thị trường
        - `ATO`: Lệnh phiên định kỳ mở cửa
        - `ATC`: Lệnh phiên định kỳ đóng cửa
        - `PLO`: Lệnh khớp lệnh sau giờ
      enum:
        - LO
        - MOK
        - MAK
        - MTL
        - ATO
        - ATC
        - PLO
      x-enum-descriptions:
        - Lệnh giới hạn
        - Lệnh thị trường khớp toàn bộ hoặc hủy
        - Lệnh thị trường khớp một phần và hủy phần còn lại
        - Lệnh thị trường khớp theo giá thị trường
        - Lệnh phiên định kỳ mở cửa
        - Lệnh phiên định kỳ đóng cửa
        - Lệnh khớp lệnh sau giờ
      x-enum-varnames:
        - LIMIT
        - MARKET_OR_CANCEL
        - MARKET_AND_CANCEL
        - MARKET_TO_LIMIT
        - AT_OPEN
        - AT_CLOSE
        - POST_CLOSE
      example: LO
    ErrorBody:
      type: object
      required:
        - status
        - code
        - message
      properties:
        status:
          type: integer
          format: int32
          description: Mã HTTP.
          example: 400
        code:
          type: string
          description: Mã lỗi DNSE.
          example: OA-003
        message:
          type: string
          description: Thông điệp lỗi.
          example: Thông tin nhập không hợp lệ
  headers:
    ContentLength:
      description: Response body size in bytes.
      schema:
        type: integer
      example: 430
    Date:
      description: Response date from the DNSE gateway.
      schema:
        type: string
      example: Wed, 18 Mar 2026 16:17:35 GMT
    Vary:
      description: >-
        Response header indicating the request headers used for content
        negotiation.
      schema:
        type: string
      example: Origin
    XRateLimitLimit:
      description: Maximum number of requests allowed in the current rate-limit window.
      schema:
        type: integer
      example: 300
    XRateLimitRemaining:
      description: Number of requests remaining in the current rate-limit window.
      schema:
        type: integer
      example: 299
    XRateLimitReset:
      description: Unix timestamp at which the current rate-limit window resets.
      schema:
        type: integer
      example: 1773850655
    XRequestId:
      description: Unique identifier assigned to the request by the DNSE gateway.
      schema:
        type: string
      example: unknown
  responses:
    BadRequest:
      description: Yêu cầu không hợp lệ.
      headers:
        Content-Length:
          $ref: '#/components/headers/ContentLength'
        Date:
          $ref: '#/components/headers/Date'
        Vary:
          $ref: '#/components/headers/Vary'
        X-Ratelimit-Limit:
          $ref: '#/components/headers/XRateLimitLimit'
        X-Ratelimit-Remaining:
          $ref: '#/components/headers/XRateLimitRemaining'
        X-Ratelimit-Reset:
          $ref: '#/components/headers/XRateLimitReset'
        X-Request-Id:
          $ref: '#/components/headers/XRequestId'
        X-Tyk-Api-Expires:
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          example:
            status: 400
            code: OA-003
            message: Thông tin nhập không hợp lệ
    InternalError:
      description: Lỗi hệ thống.
      headers:
        Content-Length:
          $ref: '#/components/headers/ContentLength'
        Date:
          $ref: '#/components/headers/Date'
        Vary:
          $ref: '#/components/headers/Vary'
        X-Ratelimit-Limit:
          $ref: '#/components/headers/XRateLimitLimit'
        X-Ratelimit-Remaining:
          $ref: '#/components/headers/XRateLimitRemaining'
        X-Ratelimit-Reset:
          $ref: '#/components/headers/XRateLimitReset'
        X-Request-Id:
          $ref: '#/components/headers/XRequestId'
        X-Tyk-Api-Expires:
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          example:
            status: 500
            code: OA-009
            message: Lỗi hệ thống

````

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