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

# Hủy lệnh

> Gửi yêu cầu hủy lệnh đã đặt theo `orderId.`

Hỗ trợ hủy các loại lệnh:

- Lệnh thường NORMAL có trạng thái: chờ gửi, chờ khớp hoặc đã khớp 1 phần trong thời gian quy định
    
- Lệnh STOP /OCO có trạng thái: chờ kích hoạt



## OpenAPI

````yaml https://cdn.entrade.com.vn/dnse-openapi/doc/dnse-openapi-2026-07-23.yaml delete /accounts/{accountNo}/orders/{orderId}
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:
  /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: integer
        example: '966'
    delete:
      tags:
        - trading
      summary: Hủy lệnh
      description: "Gửi yêu cầu hủy lệnh đã đặt theo\_`orderId.`\n\nHỗ trợ hủy các loại lệnh:\n\n- Lệnh thường NORMAL có trạng thái: chờ gửi, chờ khớp hoặc đã khớp 1 phần trong thời gian quy định\n    \n- Lệnh STOP /OCO có trạng thái: chờ kích hoạt"
      parameters:
        - name: marketType
          in: query
          required: true
          description: |-
            Loại thị trường 
            - STOCK: Đặt lệnh cơ sở
            - DERIVATIVE: Đặt lệnh phái sinh
          deprecated: false
          schema:
            type: string
          example: DERIVATIVE
        - name: orderCategory
          in: query
          required: true
          description: |-
            Phân loại lệnh 
            - NORMAL: lệnh thường  (cơ sở, phái sinh, trái phiếu)
            - STOP: lệnh dừng có điều kiện (cơ sở, phái sinh)
            - OCO: lệnh OCO (phái sinh)
          deprecated: false
          schema:
            type: string
          example: STOP
        - name: X-API-Key
          in: header
          required: true
          description: API Key được cấp khi đăng ký dịch vụ
          schema:
            type: string
          example: '{{apiKey}}'
        - name: X-Signature
          in: header
          required: true
          description: Chữ ký xác thực yêu cầu
          schema:
            type: string
          example: '{{signature}}'
        - name: X-Aux-Date
          in: header
          required: true
          description: Thời gian thực hiện yêu cầu
          schema:
            type: string
          example: '{{date}}'
        - name: trading-token
          in: header
          required: true
          description: Token đặt lệnh
          schema:
            type: string
          example: '{{tradingToken}}'
        - name: version
          in: header
          required: true
          description: API version (YYYY-MM-DD)
          schema:
            type: string
            format: date
          example: '2026-07-23'
      responses:
        '200':
          description: OK
          headers:
            Date:
              deprecated: false
              schema: {}
              example: Tue, 04 Aug 2026 02:53:09 GMT
            Vary:
              deprecated: false
              schema: {}
              example: Origin
            X-Ratelimit-Limit:
              deprecated: false
              schema: {}
              example: '-1'
            X-Ratelimit-Remaining:
              deprecated: false
              schema: {}
              example: '0'
            X-Ratelimit-Reset:
              deprecated: false
              schema: {}
              example: '1784794513'
            X-Tyk-Api-Expires:
              deprecated: false
              schema: {}
              example: Thu, 02 Jan 3000 15:04:00 UTC
            Transfer-Encoding:
              deprecated: false
              schema: {}
              example: chunked
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: '741'
                    description: Id lệnh giao dịch
                  accountNo:
                    type: string
                    example: '0001179019'
                    description: Số tiểu khoản
                  orderCategory:
                    type: string
                    example: NORMAL
                    description: |-
                      Phân loại lệnh 
                      - NORMAL: lệnh thường  (cơ sở, phái sinh, trái phiếu)
                      - STOP: lệnh dừng có điều kiện (cơ sở, phái sinh)
                      - OCO: lệnh OCO (phái sinh)                      
                  marketType:
                    type: string
                    example: STOCK
                    description: |-
                      Loại thị trường
                      - STOCK: Lệnh cơ sở
                      - DERIVATIVE: Lệnh phái sinh
                      - BOND: Lệnh phái sinh
                  symbol:
                    type: string
                    example: SHS
                    description: Mã chứng khoán
                  side:
                    type: string
                    example: NB
                    description: |-
                      Chiều đặt lệnh
                      - NB: Mua
                      - NS: Bán
                  orderType:
                    type: string
                    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ờ
                  orderStatus:
                    type: string
                    example: PendingCancel
                    description: |-
                      Trạng thái lệnh NORMAL:

                        - Pending/PendingNew: Chờ gửi

                        - New: Chờ khớp

                        - PendingReplace: Chờ sửa

                        - PendingCancel: Chờ hủy

                        - PartiallyFilled: Khớp một phần

                        - Filled: Khớp toàn bộ

                        - Canceled: Đã hủy

                        - Rejected: Bị từ chối

                        - Expired: Hết hạn trong phiên

                        - DoneForDay: Lệnh được giải tỏa do không khớp trong phiên

                      Trạng thái lệnh STOP/OCO:

                        - New: Chờ kích hoạt                              
                        - Activated: Đã kích hoạt
                        - Cancelled: Đã hủy
                        - Expired: Hết hiệu lực
                        - Rejected: Bị từ chối
                        - Failed: Lệnh thất bại
                  price:
                    type: integer
                    format: int32
                    example: 15600
                    description: Giá đặt
                  quantity:
                    type: integer
                    format: int32
                    example: 800
                    description: Khối lượng đặt
                  loanPackageId:
                    type: integer
                    format: int32
                    example: 1372
                    description: Mã gói vay
                  priceSecure:
                    type: integer
                    format: int32
                    example: 15600
                    description: Giá bảo đảm
                  averagePrice:
                    type: integer
                    format: int32
                    example: 0
                    description: Giá khớp trung bình
                  fillQuantity:
                    type: integer
                    example: 0
                    description: Khối lượng khớp
                    format: int32
                  canceledQuantity:
                    type: integer
                    example: 0
                    description: Khối lượng đã hủy
                    format: int32
                  leaveQuantity:
                    type: integer
                    format: int32
                    example: 800
                    description: Khối lượng còn lại
                  transDate:
                    type: string
                    example: '2026-01-30'
                    description: Ngày giao dịch
                  createdDate:
                    type: string
                    format: date-time
                    example: '2026-08-04T02:52:57.305213488Z'
                    description: Thời điểm tạo
                  modifiedDate:
                    type: string
                    format: date-time
                    example: '2026-08-04T02:53:09.831996595Z'
                    description: Thời điểm cập nhật
              examples:
                NORMAL - STOCK:
                  value:
                    id: '741'
                    accountNo: '0001179019'
                    orderCategory: NORMAL
                    marketType: STOCK
                    symbol: SHS
                    side: NB
                    orderType: LO
                    orderStatus: PendingCancel
                    price: 15600
                    quantity: 800
                    loanPackageId: 1372
                    priceSecure: 15600
                    averagePrice: 0
                    fillQuantity: 0
                    canceledQuantity: 0
                    leaveQuantity: 800
                    transDate: '2026-01-30'
                    createdDate: '2026-08-04T02:52:57.305213488Z'
                    modifiedDate: '2026-08-04T02:53:09.831996595Z'
                STOP - DERIVATIVE:
                  value:
                    accountNo: '0001179019'
                    conditionOperator: '>='
                    createdDate: '2026-08-04T02:56:19.530727Z'
                    durationDateTime: '2026-08-08T07:30:00Z'
                    durationType: GTD
                    id: d9ol9kq0cvks72pfqiug
                    loanPackageId: 2278
                    marketType: DERIVATIVE
                    modifiedDate: '2026-08-04T02:56:43.821292Z'
                    orderCategory: STOP
                    orderStatus: Canceled
                    orderType: LO
                    price: 1991
                    quantity: 4
                    side: NS
                    stopPrice: 1990
                    symbol: 41I1G9000
        '400':
          description: Yêu cầu không hợp lệ
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    example: 400
                    description: Mã HTTP
                    format: int32
                  code:
                    type: string
                    example: OA-003
                    description: Mã lỗi
                  message:
                    type: string
                    example: Thông tin nhập không hợp lệ
                    description: Thông điệp lỗi
              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:
                  status:
                    type: integer
                    example: 500
                    description: Mã HTTP
                    format: int32
                  code:
                    type: string
                    example: OA-009
                    description: Mã lỗi
                  message:
                    type: string
                    example: Lỗi hệ thống
                    description: Thông điệp lỗi
              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.