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

# Khớp lệnh

> Gửi cập nhật khớp lệnh theo danh sách mã chứng khoán trong một nhóm thị trường.



## AsyncAPI

````yaml vi/asyncapi/dnse.2026-09-10.asyncapi.yaml tradeStream
id: tradeStream
title: Khớp lệnh
description: >-
  Gửi cập nhật khớp lệnh theo danh sách mã chứng khoán trong một nhóm thị
  trường.
servers:
  - id: production
    protocol: wss
    host: ws-openapi.dnse.com.vn
    bindings: []
    variables: []
  - id: sanbox
    protocol: wss
    host: ws-sb-openapi.dnse.com.vn
    bindings: []
    variables: []
address: /v1/stream
parameters: []
bindings:
  - protocol: ws
    version: 0.1.0
    value:
      method: GET
      query:
        type: object
        additionalProperties: false
        required:
          - encoding
        properties:
          encoding:
            type: string
            const: json
            default: json
            description: Định dạng mã hóa dữ liệu WebSocket (`json`, `msgpack`).
    schemaProperties:
      - name: method
        type: string
        description: GET
        required: false
      - name: query
        type: object
        required: false
        properties:
          - name: encoding
            type: string
            description: Định dạng mã hóa dữ liệu WebSocket (`json`, `msgpack`).
            required: true
operations:
  - &ref_1
    id: onTradeSubscription
    title: Đăng ký luồng khớp lệnh
    type: receive
    messages:
      - &ref_3
        id: subscribeRequest
        contentType: application/json
        payload:
          - name: Đăng ký luồng khớp lệnh
            description: Đăng ký topic `tick.{market_group}.{encoding}`.
            type: object
            properties:
              - name: action
                type: string
                description: subscribe
                required: true
              - name: channels
                type: array
                required: true
                properties:
                  - name: name
                    type: string
                    description: Topic khớp lệnh theo nhóm thị trường.
                    required: true
                  - name: symbols
                    type: array
                    required: true
                    properties:
                      - name: item
                        type: string
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - action
            - channels
          properties:
            action:
              type: string
              const: subscribe
              x-parser-schema-id: <anonymous-schema-53>
            channels:
              type: array
              minItems: 1
              uniqueItems: true
              items:
                type: object
                additionalProperties: false
                required:
                  - name
                  - symbols
                properties:
                  name:
                    type: string
                    description: Topic khớp lệnh theo nhóm thị trường.
                    pattern: ^tick\.[A-Z0-9]+\.json$
                    x-parser-schema-id: <anonymous-schema-56>
                  symbols:
                    type: array
                    minItems: 1
                    uniqueItems: true
                    items:
                      type: string
                      minLength: 1
                      x-parser-schema-id: <anonymous-schema-58>
                    x-parser-schema-id: <anonymous-schema-57>
                x-parser-schema-id: <anonymous-schema-55>
              x-parser-schema-id: <anonymous-schema-54>
          x-parser-schema-id: <anonymous-schema-52>
        title: Đăng ký luồng khớp lệnh
        description: Đăng ký topic `tick.{market_group}.{encoding}`.
        example: |-
          {
            "action": "subscribe",
            "channels": [
              {
                "name": "tick.G1.json",
                "symbols": [
                  "HPG"
                ]
              }
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribeRequest
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: tradeStream
  - &ref_2
    id: onTradeUpdates
    title: Nhận cập nhật khớp lệnh
    type: send
    messages:
      - &ref_4
        id: update
        contentType: application/json
        payload:
          - name: Cập nhật khớp lệnh
            description: Bản cập nhật giao dịch khớp lệnh của một mã chứng khoán.
            type: object
            properties:
              - name: T
                type: string
                description: Mã loại message khớp lệnh.
                required: true
              - name: symbol
                type: string
                description: Mã chứng khoán.
                required: true
              - name: marketId
                type: string
                description: Mã thị trường niêm yết mã chứng khoán.
                required: true
              - name: boardId
                type: string
                description: Mã bảng giao dịch.
                required: true
              - name: isin
                type: string
                description: Mã định danh quốc tế (ISIN) của chứng khoán.
                required: true
              - name: matchPrice
                type: number
                description: Giá khớp gần nhất.
                required: true
              - name: matchQtty
                type: integer
                description: Khối lượng khớp gần nhất.
                required: true
              - name: totalVolumeTraded
                type: integer
                description: Tổng khối lượng khớp trong ngày.
                required: true
              - name: grossTradeAmount
                type: number
                description: Tổng giá trị giao dịch trong ngày.
                required: true
              - name: highestPrice
                type: number
                description: Giá khớp cao nhất trong ngày.
                required: true
              - name: lowestPrice
                type: number
                description: Giá khớp thấp nhất trong ngày.
                required: true
              - name: openPrice
                type: number
                description: Giá mở cửa.
                required: true
              - name: tradingSessionId
                type: string
                description: Mã phiên giao dịch hiện tại.
                required: true
              - name: multicastReceiveTime
                type: object
                description: Thời gian nhận message qua multicast.
                required: true
                properties:
                  - name: Seconds
                    type: integer
                    description: Unix timestamp tính bằng giây.
                    required: true
                  - name: Nanos
                    type: integer
                    description: Phần nanosecond của timestamp.
                    required: true
              - name: time
                type: object
                description: Thời gian trong các message giá của sàn trả về.
                required: true
                properties:
                  - name: Seconds
                    type: integer
                    description: Unix timestamp tính bằng giây.
                    required: true
                  - name: Nanos
                    type: integer
                    description: Phần nanosecond của timestamp.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          description: Dữ liệu khớp lệnh theo thời gian thực.
          required:
            - T
            - symbol
            - matchPrice
            - matchQtty
            - marketId
            - boardId
            - isin
            - totalVolumeTraded
            - grossTradeAmount
            - highestPrice
            - lowestPrice
            - openPrice
            - tradingSessionId
            - multicastReceiveTime
            - time
          properties:
            T:
              type: string
              description: Mã loại message khớp lệnh.
              const: t
              x-parser-schema-id: <anonymous-schema-60>
            symbol:
              type: string
              description: Mã chứng khoán.
              x-parser-schema-id: <anonymous-schema-61>
            marketId:
              type: string
              description: Mã thị trường niêm yết mã chứng khoán.
              x-parser-schema-id: <anonymous-schema-62>
            boardId:
              type: string
              description: Mã bảng giao dịch.
              x-parser-schema-id: <anonymous-schema-63>
            isin:
              type: string
              description: Mã định danh quốc tế (ISIN) của chứng khoán.
              x-parser-schema-id: <anonymous-schema-64>
            matchPrice:
              type: number
              description: Giá khớp gần nhất.
              x-parser-schema-id: <anonymous-schema-65>
            matchQtty:
              type: integer
              description: Khối lượng khớp gần nhất.
              x-parser-schema-id: <anonymous-schema-66>
            totalVolumeTraded:
              type: integer
              description: Tổng khối lượng khớp trong ngày.
              x-parser-schema-id: <anonymous-schema-67>
            grossTradeAmount:
              type: number
              description: Tổng giá trị giao dịch trong ngày.
              x-parser-schema-id: <anonymous-schema-68>
            highestPrice:
              type: number
              description: Giá khớp cao nhất trong ngày.
              x-parser-schema-id: <anonymous-schema-69>
            lowestPrice:
              type: number
              description: Giá khớp thấp nhất trong ngày.
              x-parser-schema-id: <anonymous-schema-70>
            openPrice:
              type: number
              description: Giá mở cửa.
              x-parser-schema-id: <anonymous-schema-71>
            tradingSessionId:
              type: string
              description: Mã phiên giao dịch hiện tại.
              x-parser-schema-id: <anonymous-schema-72>
            multicastReceiveTime:
              type: object
              description: Thời gian nhận message qua multicast.
              required:
                - Seconds
                - Nanos
              properties:
                Seconds:
                  type: integer
                  format: int64
                  description: Unix timestamp tính bằng giây.
                  x-parser-schema-id: <anonymous-schema-74>
                Nanos:
                  type: integer
                  format: int32
                  description: Phần nanosecond của timestamp.
                  x-parser-schema-id: <anonymous-schema-75>
              x-parser-schema-id: <anonymous-schema-73>
            time:
              type: object
              description: Thời gian trong các message giá của sàn trả về.
              required:
                - Seconds
                - Nanos
              properties:
                Seconds:
                  type: integer
                  format: int64
                  description: Unix timestamp tính bằng giây.
                  x-parser-schema-id: <anonymous-schema-77>
                Nanos:
                  type: integer
                  format: int32
                  description: Phần nanosecond của timestamp.
                  x-parser-schema-id: <anonymous-schema-78>
              x-parser-schema-id: <anonymous-schema-76>
          x-parser-schema-id: <anonymous-schema-59>
        title: Cập nhật khớp lệnh
        description: Bản cập nhật giao dịch khớp lệnh của một mã chứng khoán.
        example: |-
          {
            "T": "t",
            "boardId": "G1",
            "grossTradeAmount": 205.111605,
            "highestPrice": 21.2,
            "isin": "VN000000HPG4",
            "lowestPrice": 20.9,
            "marketId": "STO",
            "matchPrice": 21.05,
            "matchQtty": 90,
            "multicastReceiveTime": {
              "Nanos": 687300758,
              "Seconds": 1787120768
            },
            "openPrice": 21.1,
            "symbol": "HPG",
            "time": {
              "Nanos": 35000000,
              "Seconds": 1787120771
            },
            "totalVolumeTraded": 976440,
            "tradingSessionId": "40"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: update
    bindings: []
    extensions: *ref_0
sendOperations:
  - *ref_1
receiveOperations:
  - *ref_2
sendMessages:
  - *ref_3
receiveMessages:
  - *ref_4
extensions:
  - id: x-parser-unique-object-id
    value: tradeStream
securitySchemes: []

````

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