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



## OpenAPI

````yaml /vi/openapi/dnse.2026-08-06.openapi.yaml post /accounts/{accountNo}/orders
openapi: 3.0.0
info:
  title: DNSE LightSpeed API v2
  version: 1.0.0
  description: DNSE OpenAPI spec and tests
servers:
  - url: https://openapi.dnse.com.vn
    description: Production
  - url: https://openapi-uat.dnse.com.vn
    description: UAT
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-data
    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:
    parameters:
      - name: accountNo
        in: path
        required: true
        description: Số tiểu khoản
        deprecated: false
        schema:
          type: string
        example: '0001179019'
    post:
      tags:
        - account
      summary: Đặt lệnh
      operationId: postAccountsAccountNoOrders
      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, DERIVATIVE hoặc BOND.'
          schema:
            allOf:
              - $ref: '#/components/schemas/MarketType'
            enum:
              - STOCK
              - DERIVATIVE
              - BOND
          example: DERIVATIVE
        - name: orderCategory
          in: query
          description: 'Phân loại lệnh: NORMAL, STOP hoặc OCO.'
          schema:
            allOf:
              - $ref: '#/components/schemas/OrderCategory'
            enum:
              - NORMAL
              - STOP
              - OCO
          required: true
          example: STOP
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - loanPackageId
                - orderType
                - price
                - quantity
                - side
                - symbol
              properties:
                loanPackageId:
                  type: integer
                  format: int32
                  example: 2278
                  description: Mã gói vay theo mã chứng khoán
                orderType:
                  allOf:
                    - $ref: '#/components/schemas/OrderType'
                  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:
                  allOf:
                    - $ref: '#/components/schemas/OrderSide'
                  description: |-
                    Chiều đặt lệnh
                    - NB: Mua
                    - NS: Bán
                symbol:
                  type: string
                  example: 41I1G8000
                  description: Mã chứng khoán cần đặt lệnh
                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:
                  allOf:
                    - $ref: '#/components/schemas/ConditionOperator'
                  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:
                  allOf:
                    - $ref: '#/components/schemas/OrderDurationType'
                  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
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlaceOrderResponse'
              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:
                    allOf:
                      - $ref: '#/components/schemas/OrderCategory'
                  marketType:
                    allOf:
                      - $ref: '#/components/schemas/MarketType'
                  symbol:
                    type: string
                    description: Mã chứng khoán
                  side:
                    allOf:
                      - $ref: '#/components/schemas/OrderSide'
                  orderType:
                    allOf:
                      - $ref: '#/components/schemas/OrderType'
                  orderStatus:
                    allOf:
                      - $ref: '#/components/schemas/OrderStatus'
                    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
                  stopOrderPrice:
                    type: integer
                    description: Giá đặt lệnh dừng OCO
                  conditionOperator:
                    allOf:
                      - $ref: '#/components/schemas/ConditionOperator'
                    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:
                    allOf:
                      - $ref: '#/components/schemas/OrderDurationType'
                    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':
          $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
    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
    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
    ConditionOperator:
      type: string
      description: |-
        Điều kiện so sánh để kích hoạt lệnh dừng.

        - `>=`: 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
      enum:
        - '>='
        - <=
      x-enum-descriptions:
        - Lớn hơn hoặc bằng
        - Nhỏ hơn hoặc bằng
      x-enum-varnames:
        - GREATER_THAN_OR_EQUAL
        - LESS_THAN_OR_EQUAL
      example: '>='
    OrderDurationType:
      type: string
      description: |-
        Thời hạn hiệu lực của lệnh.

        - `GTD`: Có hiệu lực đến ngày, giờ chỉ định
        - `DAY`: Có hiệu lực trong ngày
      enum:
        - GTD
        - DAY
      x-enum-descriptions:
        - Có hiệu lực đến ngày, giờ chỉ định
        - Có hiệu lực trong ngày
      x-enum-varnames:
        - GOOD_TILL_DATE
        - DAY
      example: GTD
    PlaceOrderResponse:
      type: object
      properties:
        id:
          type: string
          example: '1631'
          description: Id lệnh giao dịch
        symbol:
          type: string
          example: MBS
          description: Mã chứng khoán
        side:
          allOf:
            - $ref: '#/components/schemas/OrderSide'
          example: NB
          description: |-
            Chiều đặt lệnh
            - NB: Mua
            - NS: Bá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ờ
        orderStatus:
          allOf:
            - $ref: '#/components/schemas/OrderStatus'
          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
        averagePrice:
          type: number
        quantity:
          type: integer
          format: int32
          example: 300
          description: Khối lượng đặt
        fillQuantity:
          type: integer
        canceledQuantity:
          type: integer
        leaveQuantity:
          type: integer
        accountNo:
          type: string
          example: '0001179019'
          description: Số tiểu khoản
        marketType:
          allOf:
            - $ref: '#/components/schemas/MarketType'
          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
        orderCategory:
          allOf:
            - $ref: '#/components/schemas/OrderCategory'
          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
        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
        loanPackageId:
          type: integer
          format: int32
          example: 1036
          description: ID gói vay
    OrderStatus:
      type: string
      description: |-
        Trạng thái lệnh.

        - `Pending`: Chờ gửi
        - `PendingNew`: Chờ gửi
        - `New`: Chờ khớp hoặc chờ kích hoạt
        - `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`: Được giải tỏa do không khớp trong phiên
      enum:
        - Pending
        - PendingNew
        - New
        - PendingReplace
        - PendingCancel
        - PartiallyFilled
        - Filled
        - Canceled
        - Rejected
        - Expired
        - DoneForDay
      x-enum-descriptions:
        - Chờ gửi
        - Chờ gửi
        - Chờ khớp hoặc chờ kích hoạt
        - Chờ sửa
        - Chờ hủy
        - Khớp một phần
        - Khớp toàn bộ
        - Đã hủy
        - Bị từ chối
        - Hết hạn trong phiên
        - Được giải tỏa do không khớp trong phiên
      x-enum-varnames:
        - PENDING
        - PENDING_NEW
        - NEW
        - PENDING_REPLACE
        - PENDING_CANCEL
        - PARTIALLY_FILLED
        - FILLED
        - CANCELED
        - REJECTED
        - EXPIRED
        - DONE_FOR_DAY
      example: New
    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ệ
  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
  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

````

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