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

# Đặt lệnh

> Gửi yêu cầu đặt lệnh giao dịch trên tài khoản. Hỗ trợ các loại lệnh: 
- Lệnh thường NORMAL: Cơ sở, Phái sinh, Trái phiếu            
- Lệnh STOP: Cơ sở, Phái sinh
    
- Lệnh OCO: Phái sinh
    

Body request sẽ gồm các trường bắt buộc và khác nhau theo từng loại lệnh. Người dùng tham khảo hướng dẫn đặt lệnh ([tại đây](https://developers.dnse.com.vn/docs/guide/trading-api/trading_order))



## OpenAPI

````yaml https://cdn.entrade.com.vn/dnse-openapi/doc/dnse-openapi-2026-07-23.yaml post /accounts/{accountNo}/orders
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:
    parameters:
      - name: accountNo
        in: path
        required: true
        description: Số tiểu khoản
        schema:
          type: string
        example: '0001179019'
    post:
      tags:
        - trading
      summary: Đặt lệnh
      description: >-
        Gửi yêu cầu đặt lệnh giao dịch trên tài khoản. Hỗ trợ các loại lệnh: 

        - Lệnh thường NORMAL: Cơ sở, Phái sinh, Trái phiếu            

        - Lệnh STOP: Cơ sở, Phái sinh
            
        - Lệnh OCO: Phái sinh
            

        Body request sẽ gồm các trường bắt buộc và khác nhau theo từng loại
        lệnh. Người dùng tham khảo hướng dẫn đặt lệnh ([tại
        đây](https://developers.dnse.com.vn/docs/guide/trading-api/trading_order))
      parameters:
        - name: marketType
          in: query
          required: true
          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
          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)
          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'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                symbol:
                  type: string
                  example: 41I1G8000
                  description: Mã chứng khoán cần đặt lệnh
                loanPackageId:
                  type: integer
                  format: int32
                  example: 2278
                  description: Mã gói vay theo mã chứng khoán
                orderType:
                  type: string
                  example: LO
                  description: >-
                    - Loại lệnh với NORMAL: LO (lệnh giới hạn), MOK/MAK/MTL
                    (lệnh thị trường), ATO/ATC (lệnh phiên định kỳ mở/đóng cửa),
                    PLO (lệnh sau giờ)

                    - Loại lệnh với STOP: LO (lệnh giới hạn), MTL (lệnh thị
                    trường)

                    - Loại lệnh với OCO: LO (lệnh giới hạn)
                price:
                  type: number
                  format: double
                  example: 1990
                  description: |-
                    - Lệnh NORMAL: Giá đặt
                    - Lệnh STOP: Giá đặt lệnh dừng
                    - Lệnh OCO: Giá đặt lệnh chốt lời 
                quantity:
                  type: integer
                  format: int32
                  example: 3
                  description: Khối lượng đặt
                side:
                  type: string
                  example: NB
                  description: |-
                    Chiều đặt lệnh
                    - NB: Mua
                    - NS: Bán
                stopPrice:
                  type: number
                  format: double
                  example: 2000
                  description: Giá điều kiện dùng để kích hoạt lệnh dừng (lệnh STOP, OCO)
                stopOrderPrice:
                  type: number
                  format: double
                  example: 2005
                  description: Giá đặt của lệnh cắt lỗ (chỉ áp dụng với lệnh OCO)
                conditionOperator:
                  type: string
                  example: '>='
                  description: >-
                    Điều kiện kích hoạt lệnh dừng (chỉ áp dụng với lệnh STOP)

                    - `>=`: Kích hoạt khi giá thị trường lớn hơn hoặc bằng giá
                    điều kiện

                    - `<=`: Kích hoạt khi giá thị trường nhỏ hơn hoặc bằng giá
                    điều kiện
                durationType:
                  type: string
                  example: GTD
                  description: |-
                    Hiệu lực của lệnh
                    - GTD: Có hiệu lực đến ngày, giờ chỉ định (lệnh STOP)
                    - DAY: Lệnh có hiệu lực trong ngày (lệnh OCO)
                durationDateTime:
                  type: string
                  format: date-time
                  example: '2026-08-01T07:30:00.000+07:00'
                  description: >-
                    Ngày, giờ hết hiệu lực của lệnh. Chỉ áp dụng khi
                    durationType = GTD (lệnh STOP)
            examples:
              NORMAL - STOCK:
                value:
                  symbol: MBS
                  loanPackageId: 5757
                  orderType: LO
                  price: 18600
                  quantity: 300
                  side: NB
              STOP - DERIVATIVE:
                value:
                  symbol: 41I1G8000
                  loanPackageId: 2278
                  orderType: LO
                  price: 1990
                  quantity: 3
                  side: NB
                  stopPrice: 2000
                  conditionOperator: '>='
                  durationType: GTD
                  durationDateTime: '2026-08-01T07:30:00.000+07:00'
              OCO - DERIVATIVE:
                value:
                  symbol: 41I1G9000
                  loanPackageId: 2278
                  orderType: LO
                  price: 1916
                  quantity: 3
                  side: NS
                  stopPrice: 1910
                  stopOrderPrice: 1907
                  durationType: DAY
      responses:
        '200':
          description: OK
          headers:
            Content-Length:
              schema:
                type: integer
              example: 487
            Date:
              schema:
                type: string
              example: Tue, 24 Mar 2026 04:09:50 GMT
            Vary:
              schema:
                type: string
              example: Origin
            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
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: '1631'
                    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
                      - STOP: Lệnh dừng có điều kiện
                      - OCO: Lệnh OCO phái sinh
                  marketType:
                    type: string
                    example: STOCK
                    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
                  symbol:
                    type: string
                    example: MBS
                    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: Pending
                    description: |-
                      Trạng thái lệnh khi đặt thành công
                      - PendingNew: Chờ gửi (lệnh thường NORMAL)
                      - New: Chờ kích hoạt (lệnh STOP/OCO)
                  price:
                    type: number
                    format: double
                    example: 18600
                    description: Giá đặt
                  quantity:
                    type: integer
                    example: 300
                    description: Khối lượng đặt
                    format: int32
                  loanPackageId:
                    type: integer
                    format: int32
                    example: 1036
                    description: ID gói vay
                  transDate:
                    type: string
                    format: date
                    example: '2026-01-29'
                    description: Ngày giao dịch
                  createdDate:
                    type: string
                    format: date-time
                    example: '2026-08-03T07:27:34.272131175Z'
                    description: Thời điểm tạo lệnh
                  modifiedDate:
                    type: string
                    format: date-time
                    example: '2026-08-03T07:27:34.272132175Z'
                    description: Thời điểm cập nhật lệnh
              examples:
                NORMAL - STOCK:
                  value:
                    id: '1631'
                    accountNo: '0001179019'
                    orderCategory: NORMAL
                    marketType: STOCK
                    symbol: MBS
                    side: NB
                    orderType: LO
                    orderStatus: PendingNew
                    price: 18600
                    quantity: 300
                    loanPackageId: 5757
                    transDate: '2026-01-29'
                    createdDate: '2026-08-03T07:27:34.272131175Z'
                    modifiedDate: '2026-08-03T07:27:34.272132175Z'
                NORMAL - DERIVATIVE:
                  value:
                    id: '2230'
                    accountNo: '0001179019'
                    orderCategory: NORMAL
                    marketType: DERIVATIVE
                    symbol: 41I1G9000
                    side: NB
                    orderType: LO
                    orderStatus: PendingNew
                    price: 1990
                    quantity: 3
                    loanPackageId: 5757
                    transDate: '2026-08-03'
                    createdDate: '2026-08-03T07:27:34.272131175Z'
                    modifiedDate: '2026-08-03T07:27:34.272132175Z'
        '201':
          description: OK
          headers:
            Content-Length:
              schema:
                type: integer
              example: 413
            Date:
              schema:
                type: string
              example: Thu, 16 Jul 2026 07:46:52 GMT
            Vary:
              schema:
                type: string
              example: Origin
            X-Ratelimit-Limit:
              schema:
                type: integer
              example: -1
            X-Ratelimit-Remaining:
              schema:
                type: integer
              example: 0
            X-Ratelimit-Reset:
              schema:
                type: integer
              example: 1782966202
            X-Request-Id:
              schema:
                type: string
              example: OOvwkrZHakuuFwXsZNRNLnqfWJoMNBrT
            X-Tyk-Api-Expires:
              schema:
                type: string
              example: Thu, 02 Jan 3000 15:04:00 UTC
          content:
            application/json:
              schema:
                type: object
                description: Thông tin lệnh điều kiện.
                properties:
                  id:
                    type: string
                    description: Id lệnh giao dịch.
                  accountNo:
                    type: string
                    description: Số tiểu khoản.
                  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
                  marketType:
                    type: string
                    description: |
                      Loại thị trường
                      - STOCK: Lệnh cơ sở
                      - DERIVATIVE: Lệnh phái sinh
                  symbol:
                    type: string
                    description: Mã chứng khoán
                  side:
                    type: string
                    description: |
                      Chiều đặt lệnh
                      - NB: Mua
                      - NS: Bán
                  orderType:
                    type: string
                    description: |
                      Loại lệnh đặt cho lệnh dừng (lệnh STOP/OCO)
                      - LO: Lệnh giới hạn
                      - MTL: Lệnh thị trường            
                  orderStatus:
                    type: string
                    description: |
                      Trạng thái lệnh khi đặt thành công
                      - PendingNew: Chờ gửi (lệnh thường NORMAL)
                      - New: Chờ kích hoạt (lệnh STOP/OCO)
                  price:
                    type: integer
                    description: Giá đặt
                  quantity:
                    type: integer
                    description: Khối lượng đặt
                  loanPackageId:
                    type: integer
                    description: ID gói vay
                  stopPrice:
                    type: integer
                    description: Giá điều kiện kích hoạt lệnh dừng
                  conditionOperator:
                    type: string
                    description: >
                      Điều kiện kích hoạt lệnh dừng (chỉ áp dụng với lệnh STOP)


                      - `>=`: Kích hoạt khi giá thị trường lớn hơn hoặc bằng giá
                      điều kiện


                      - `<=`: Kích hoạt khi giá thị trường nhỏ hơn hoặc bằng giá
                      điều kiện
                  durationType:
                    type: string
                    description: |
                      Thời hạn hiệu lực của lệnh
                      - DAY: Lệnh có hiệu lực trong ngày (lệnh OCO)
                      - GTD: Có hiệu lực đến ngày, giờ chỉ định (lệnh STOP)
                  durationDateTime:
                    type: string
                    description: >-
                      Thời điểm hết hiệu lực của lệnh khi durationType là GTD
                      (lệnh STOP).
                    format: date-time
                  createdDate:
                    type: string
                    description: Thời điểm tạo lệnh.
                    format: date-time
                  modifiedDate:
                    type: string
                    description: Thời điểm cập nhật lệnh.
                    format: date-time
              examples:
                STOP - DERIVATIVE:
                  value:
                    id: d9guo2d1j9cc72osmg1g
                    accountNo: '0001179019'
                    orderCategory: STOP
                    marketType: DERIVATIVE
                    symbol: 41I1G8000
                    side: NB
                    orderType: LO
                    orderStatus: New
                    price: 1990
                    quantity: 3
                    loanPackageId: 2278
                    stopPrice: 2000
                    conditionOperator: '>='
                    durationType: GTD
                    durationDateTime: '2026-08-01T07:30:00+07:00'
                    createdDate: '2026-07-23T10:25:13.251588Z'
                    modifiedDate: '2026-07-23T10:25:13.251588Z'
                OCO - DERIVATIVE:
                  value:
                    accountNo: '0001179019'
                    createdDate: '2026-08-04T02:24:40.055903Z'
                    durationType: DAY
                    id: d9okqq13qkqc72rbl930
                    loanPackageId: 2278
                    marketType: DERIVATIVE
                    modifiedDate: '2026-08-04T02:24:40.055903Z'
                    orderCategory: OCO
                    orderStatus: New
                    orderType: LO
                    price: 1916
                    quantity: 3
                    side: NS
                    stopOrderPrice: 1907
                    stopPrice: 1910
                    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.