> ## 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ự kiện lệnh

> Cập nhật trạng thái lệnh, khớp lệnh và sự kiện lệnh điều kiện (FCO).
FCO được trả về trên cùng topic `order`.



## AsyncAPI

````yaml vi/asyncapi/ssi.2026-07-29.asyncapi.yaml orderStream
id: orderStream
title: Sự kiện lệnh
description: |-
  Cập nhật trạng thái lệnh, khớp lệnh và sự kiện lệnh điều kiện (FCO).
  FCO được trả về trên cùng topic `order`.
servers:
  - id: production
    protocol: wss
    host: stream.ssi.com.vn
    bindings: []
    variables: []
address: /ws/v3
parameters: []
bindings: []
operations:
  - &ref_6
    id: onOrderEvent
    title: Nhận sự kiện lệnh
    type: send
    messages:
      - &ref_11
        id: orderEvent
        contentType: application/json
        payload:
          - name: Sự kiện lệnh
            description: Trạng thái lệnh khi đặt, sửa, hủy hoặc thay đổi trạng thái.
            type: object
            properties:
              - name: channel
                type: string
                description: Kênh dữ liệu giao dịch.
                required: true
              - name: topic
                type: string
                description: Topic sự kiện lệnh theo tài khoản và mã lệnh.
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: eventType
                    type: string
                    description: Loại event.
                    required: true
                  - name: notifyId
                    type: integer
                    description: Số serial của event message.
                    required: true
                  - name: connectionId
                    type: &ref_0
                      - string
                      - 'null'
                    description: Định danh phiên kết nối stream.
                    required: true
                  - name: clientRequestId
                    type: string
                    description: Định danh lệnh trong ngày.
                    required: true
                  - name: orderId
                    type: string
                    description: Số định danh lệnh trên hệ thống giao dịch.
                    required: true
                  - name: symbol
                    type: string
                    description: Mã chứng khoán.
                    required: true
                  - name: side
                    type: string
                    description: B là BUY, S là SELL.
                    enumValues:
                      - B
                      - S
                    required: true
                  - name: orderType
                    type: string
                    description: Loại lệnh, ví dụ `LO`, `ATO`, `ATC`.
                    required: true
                  - name: accountNo
                    type: string
                    description: Số tài khoản đặt lệnh.
                    required: true
                  - name: price
                    type: string
                    description: Giá đặt lệnh.
                    required: true
                  - name: avgPrice
                    type: string
                    description: Giá khớp trung bình.
                    required: true
                  - name: quantity
                    type: number
                    description: Khối lượng đặt lệnh.
                    required: true
                  - name: cancelQty
                    type: number
                    description: Khối lượng đã hủy.
                    required: true
                  - name: osQty
                    type: number
                    description: Khối lượng chưa khớp.
                    required: true
                  - name: filledQty
                    type: number
                    description: Khối lượng khớp.
                    required: true
                  - name: inputTime
                    type: string
                    description: Thời gian tiếp nhận đặt lệnh.
                    required: true
                  - name: modifiedTime
                    type: string
                    description: Thời gian sửa hoặc cập nhật trạng thái.
                    required: true
                  - name: orderStatus
                    type: string
                    description: Trạng thái lệnh.
                    required: true
                  - name: rejectReason
                    type: &ref_1
                      - string
                      - 'null'
                    description: Lý do từ chối.
                    required: true
                  - name: errorCode
                    type: string
                    description: Mã lỗi lệnh.
                    required: true
                  - name: errorMessage
                    type: &ref_2
                      - string
                      - 'null'
                    description: Thông tin lệnh lỗi.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - channel
            - topic
            - data
          properties:
            channel:
              type: string
              const: TRADING
              description: Kênh dữ liệu giao dịch.
              x-parser-schema-id: <anonymous-schema-174>
            topic:
              type: string
              pattern: ^order\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?\.?$
              description: Topic sự kiện lệnh theo tài khoản và mã lệnh.
              x-parser-schema-id: <anonymous-schema-175>
            data:
              type: object
              additionalProperties: false
              required:
                - eventType
                - notifyId
                - connectionId
                - clientRequestId
                - orderId
                - symbol
                - side
                - orderType
                - accountNo
                - price
                - avgPrice
                - quantity
                - cancelQty
                - osQty
                - filledQty
                - inputTime
                - modifiedTime
                - orderStatus
                - rejectReason
                - errorCode
                - errorMessage
              properties:
                eventType:
                  type: string
                  const: orderEvent
                  description: Loại event.
                  x-parser-schema-id: <anonymous-schema-177>
                notifyId:
                  type: integer
                  format: int64
                  description: Số serial của event message.
                  x-parser-schema-id: <anonymous-schema-178>
                connectionId:
                  type: *ref_0
                  description: Định danh phiên kết nối stream.
                  x-parser-schema-id: <anonymous-schema-179>
                clientRequestId:
                  type: string
                  description: Định danh lệnh trong ngày.
                  x-parser-schema-id: <anonymous-schema-180>
                orderId:
                  type: string
                  description: Số định danh lệnh trên hệ thống giao dịch.
                  x-parser-schema-id: <anonymous-schema-181>
                symbol:
                  type: string
                  description: Mã chứng khoán.
                  x-parser-schema-id: <anonymous-schema-182>
                side:
                  type: string
                  enum:
                    - B
                    - S
                  description: B là BUY, S là SELL.
                  x-parser-schema-id: <anonymous-schema-183>
                orderType:
                  type: string
                  description: Loại lệnh, ví dụ `LO`, `ATO`, `ATC`.
                  x-parser-schema-id: <anonymous-schema-184>
                accountNo:
                  type: string
                  description: Số tài khoản đặt lệnh.
                  x-parser-schema-id: <anonymous-schema-185>
                price:
                  type: string
                  description: Giá đặt lệnh.
                  x-parser-schema-id: <anonymous-schema-186>
                avgPrice:
                  type: string
                  description: Giá khớp trung bình.
                  x-parser-schema-id: <anonymous-schema-187>
                quantity:
                  type: number
                  description: Khối lượng đặt lệnh.
                  x-parser-schema-id: <anonymous-schema-188>
                cancelQty:
                  type: number
                  description: Khối lượng đã hủy.
                  x-parser-schema-id: <anonymous-schema-189>
                osQty:
                  type: number
                  description: Khối lượng chưa khớp.
                  x-parser-schema-id: <anonymous-schema-190>
                filledQty:
                  type: number
                  description: Khối lượng khớp.
                  x-parser-schema-id: <anonymous-schema-191>
                inputTime:
                  type: string
                  description: Thời gian tiếp nhận đặt lệnh.
                  x-parser-schema-id: <anonymous-schema-192>
                modifiedTime:
                  type: string
                  description: Thời gian sửa hoặc cập nhật trạng thái.
                  x-parser-schema-id: <anonymous-schema-193>
                orderStatus:
                  type: string
                  description: Trạng thái lệnh.
                  x-parser-schema-id: <anonymous-schema-194>
                rejectReason:
                  type: *ref_1
                  description: Lý do từ chối.
                  x-parser-schema-id: <anonymous-schema-195>
                errorCode:
                  type: string
                  description: Mã lỗi lệnh.
                  x-parser-schema-id: <anonymous-schema-196>
                errorMessage:
                  type: *ref_2
                  description: Thông tin lệnh lỗi.
                  x-parser-schema-id: <anonymous-schema-197>
              x-parser-schema-id: <anonymous-schema-176>
          x-parser-schema-id: <anonymous-schema-173>
        title: Sự kiện lệnh
        description: Trạng thái lệnh khi đặt, sửa, hủy hoặc thay đổi trạng thái.
        example: |-
          {
            "channel": "TRADING",
            "topic": "order.0901351.ORD123456.",
            "data": {
              "eventType": "orderEvent",
              "notifyId": 123456789,
              "connectionId": "conn-001",
              "clientRequestId": "req-20240226-001",
              "orderId": "ORD123456",
              "symbol": "VNM",
              "side": "B",
              "orderType": "LO",
              "accountNo": "0901351",
              "price": "72000",
              "avgPrice": "0",
              "quantity": 1000,
              "cancelQty": 0,
              "osQty": 1000,
              "filledQty": 0,
              "inputTime": "2026/03/01 14:20:55",
              "modifiedTime": "2026/03/01 14:20:55",
              "orderStatus": "PD",
              "rejectReason": "",
              "errorCode": "",
              "errorMessage": ""
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: orderEvent
    bindings: []
    extensions: &ref_3
      - id: x-parser-unique-object-id
        value: orderStream
  - &ref_4
    id: onOrderSubscription
    title: Đăng ký luồng lệnh
    type: receive
    messages:
      - &ref_9
        id: subscribeRequest
        contentType: application/json
        payload:
          - name: Yêu cầu đăng ký sự kiện lệnh
            description: Đăng ký các topic order trên channel TRADING.
            type: object
            properties:
              - name: method
                type: string
                description: SUBSCRIBE
                required: true
              - name: channel
                type: string
                description: TRADING
                required: true
              - name: topics
                type: array
                description: Danh sách topic sự kiện lệnh.
                required: true
                properties:
                  - name: item
                    type: string
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - method
            - channel
            - topics
          properties:
            method:
              type: string
              const: SUBSCRIBE
              x-parser-schema-id: <anonymous-schema-164>
            channel:
              type: string
              const: TRADING
              x-parser-schema-id: <anonymous-schema-165>
            topics:
              type: array
              minItems: 1
              uniqueItems: true
              description: Danh sách topic sự kiện lệnh.
              items:
                type: string
                minLength: 1
                pattern: ^order\.(\*|[A-Za-z0-9_-]+(?:-[A-Za-z0-9_-]+)*)$
                x-parser-schema-id: <anonymous-schema-167>
              x-parser-schema-id: <anonymous-schema-166>
          x-parser-schema-id: <anonymous-schema-163>
        title: Yêu cầu đăng ký sự kiện lệnh
        description: Đăng ký các topic order trên channel TRADING.
        example: |-
          {
            "method": "SUBSCRIBE",
            "channel": "TRADING",
            "topics": [
              "order.1231991",
              "order.1231996-1231998",
              "order.*"
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribeRequest
    bindings: []
    extensions: *ref_3
  - &ref_5
    id: onOrderUnsubscription
    title: Hủy đăng ký luồng lệnh
    type: receive
    messages:
      - &ref_10
        id: unsubscribeRequest
        contentType: application/json
        payload:
          - name: Yêu cầu hủy sự kiện lệnh
            description: Hủy đăng ký các topic order trên channel TRADING.
            type: object
            properties:
              - name: method
                type: string
                description: UNSUBSCRIBE
                required: true
              - name: channel
                type: string
                description: TRADING
                required: true
              - name: topics
                type: array
                description: Danh sách topic sự kiện lệnh cần hủy.
                required: true
                properties:
                  - name: item
                    type: string
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - method
            - channel
            - topics
          properties:
            method:
              type: string
              const: UNSUBSCRIBE
              x-parser-schema-id: <anonymous-schema-169>
            channel:
              type: string
              const: TRADING
              x-parser-schema-id: <anonymous-schema-170>
            topics:
              type: array
              minItems: 1
              uniqueItems: true
              description: Danh sách topic sự kiện lệnh cần hủy.
              items:
                type: string
                minLength: 1
                pattern: ^order\.(\*|[A-Za-z0-9_-]+(?:-[A-Za-z0-9_-]+)*)$
                x-parser-schema-id: <anonymous-schema-172>
              x-parser-schema-id: <anonymous-schema-171>
          x-parser-schema-id: <anonymous-schema-168>
        title: Yêu cầu hủy sự kiện lệnh
        description: Hủy đăng ký các topic order trên channel TRADING.
        example: |-
          {
            "method": "UNSUBSCRIBE",
            "channel": "TRADING",
            "topics": [
              "order.1231991",
              "order.*"
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribeRequest
    bindings: []
    extensions: *ref_3
  - &ref_7
    id: onOrderMatchEvent
    title: Nhận sự kiện khớp lệnh
    type: send
    messages:
      - &ref_12
        id: orderMatchEvent
        contentType: application/json
        payload:
          - name: Sự kiện khớp lệnh
            description: Sự kiện phát sinh khi lệnh được khớp một phần hoặc toàn bộ.
            type: object
            properties:
              - name: eventType
                type: string
                description: Loại event.
                required: true
              - name: notifyId
                type: integer
                description: Số serial của event message.
                required: true
              - name: connectionId
                type: string
                description: Định danh phiên kết nối stream.
                required: true
              - name: clientRequestId
                type: string
                description: Định danh lệnh trong ngày.
                required: true
              - name: orderId
                type: string
                description: Số định danh lệnh trên hệ thống giao dịch.
                required: true
              - name: symbol
                type: string
                description: Mã chứng khoán.
                required: true
              - name: side
                type: string
                description: B là BUY, S là SELL.
                enumValues:
                  - B
                  - S
                required: true
              - name: accountNo
                type: string
                description: Số tài khoản đặt lệnh.
                required: true
              - name: matchPrice
                type: string
                description: Giá khớp.
                required: true
              - name: matchQty
                type: number
                description: Khối lượng khớp.
                required: true
              - name: matchTime
                type: string
                description: Thời gian khớp.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - eventType
            - notifyId
            - connectionId
            - clientRequestId
            - orderId
            - symbol
            - side
            - accountNo
            - matchPrice
            - matchQty
            - matchTime
          properties:
            eventType:
              type: string
              const: orderMatchEvent
              description: Loại event.
              x-parser-schema-id: <anonymous-schema-199>
            notifyId:
              type: integer
              format: int64
              description: Số serial của event message.
              x-parser-schema-id: <anonymous-schema-200>
            connectionId:
              type: string
              description: Định danh phiên kết nối stream.
              x-parser-schema-id: <anonymous-schema-201>
            clientRequestId:
              type: string
              description: Định danh lệnh trong ngày.
              x-parser-schema-id: <anonymous-schema-202>
            orderId:
              type: string
              description: Số định danh lệnh trên hệ thống giao dịch.
              x-parser-schema-id: <anonymous-schema-203>
            symbol:
              type: string
              description: Mã chứng khoán.
              x-parser-schema-id: <anonymous-schema-204>
            side:
              type: string
              enum:
                - B
                - S
              description: B là BUY, S là SELL.
              x-parser-schema-id: <anonymous-schema-205>
            accountNo:
              type: string
              description: Số tài khoản đặt lệnh.
              x-parser-schema-id: <anonymous-schema-206>
            matchPrice:
              type: string
              description: Giá khớp.
              x-parser-schema-id: <anonymous-schema-207>
            matchQty:
              type: number
              description: Khối lượng khớp.
              x-parser-schema-id: <anonymous-schema-208>
            matchTime:
              type: string
              description: Thời gian khớp.
              x-parser-schema-id: <anonymous-schema-209>
          x-parser-schema-id: <anonymous-schema-198>
        title: Sự kiện khớp lệnh
        description: Sự kiện phát sinh khi lệnh được khớp một phần hoặc toàn bộ.
        example: |-
          {
            "eventType": "orderMatchEvent",
            "notifyId": 1061597,
            "connectionId": "connection_id_value",
            "clientRequestId": "91530521",
            "orderId": "26022601219922",
            "symbol": "MSR",
            "side": "S",
            "accountNo": "Q276811",
            "matchPrice": "43100.0",
            "matchQty": 500,
            "matchTime": "2026/03/01 14:20:55"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: orderMatchEvent
    bindings: []
    extensions: *ref_3
  - &ref_8
    id: onFcoEvent
    title: Nhận sự kiện lệnh điều kiện
    description: FCO được gửi trên cùng topic order.
    type: send
    messages:
      - &ref_13
        id: fcoEvent
        contentType: application/json
        payload:
          - name: Sự kiện lệnh điều kiện
            description: Cập nhật trạng thái lệnh điều kiện FastConnect Conditional Order.
            type: object
            properties:
              - name: type
                type: string
                description: Loại event.
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: fcoId
                    type: string
                    description: ID lệnh điều kiện.
                    required: true
                  - name: notifyID
                    type: integer
                    description: ID thông báo.
                    required: true
                  - name: processStatus
                    type: string
                    description: Trạng thái xử lý lệnh điều kiện.
                    required: true
                  - name: matchedQuantity
                    type: number
                    description: Khối lượng đã khớp.
                    required: true
                  - name: isPlaceOrder
                    type: boolean
                    description: Có lệnh thực phát sinh hay chưa.
                    required: true
                  - name: instrumentID
                    type: string
                    description: Mã chứng khoán hoặc mã phái sinh.
                    required: true
                  - name: quantity
                    type: number
                    description: Khối lượng muốn đặt lệnh.
                    required: true
                  - name: price
                    type: string
                    description: Giá đặt hoặc `MP`, `MOK`, `MTL`.
                    required: true
                  - name: account
                    type: string
                    description: Tiểu khoản đặt lệnh.
                    required: true
                  - name: updatedTime
                    type: string
                    description: Unix timestamp milliseconds.
                    required: true
                  - name: status
                    type: string
                    description: Mã trạng thái.
                    required: true
                  - name: message
                    type: string
                    description: Thông báo kết quả hoặc lỗi.
                    required: true
                  - name: username
                    type: string
                    description: ID người dùng tại SSI.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - type
            - data
          properties:
            type:
              type: string
              const: fcoEvent
              description: Loại event.
              x-parser-schema-id: <anonymous-schema-211>
            data:
              type: object
              additionalProperties: false
              required:
                - fcoId
                - notifyID
                - processStatus
                - matchedQuantity
                - isPlaceOrder
                - instrumentID
                - quantity
                - price
                - account
                - updatedTime
                - status
                - message
                - username
              properties:
                fcoId:
                  type: string
                  format: uuid
                  description: ID lệnh điều kiện.
                  x-parser-schema-id: <anonymous-schema-213>
                notifyID:
                  type: integer
                  format: int64
                  description: ID thông báo.
                  x-parser-schema-id: <anonymous-schema-214>
                processStatus:
                  type: string
                  description: Trạng thái xử lý lệnh điều kiện.
                  x-parser-schema-id: <anonymous-schema-215>
                matchedQuantity:
                  type: number
                  description: Khối lượng đã khớp.
                  x-parser-schema-id: <anonymous-schema-216>
                isPlaceOrder:
                  type: boolean
                  description: Có lệnh thực phát sinh hay chưa.
                  x-parser-schema-id: <anonymous-schema-217>
                instrumentID:
                  type: string
                  description: Mã chứng khoán hoặc mã phái sinh.
                  x-parser-schema-id: <anonymous-schema-218>
                quantity:
                  type: number
                  description: Khối lượng muốn đặt lệnh.
                  x-parser-schema-id: <anonymous-schema-219>
                price:
                  type: string
                  description: Giá đặt hoặc `MP`, `MOK`, `MTL`.
                  x-parser-schema-id: <anonymous-schema-220>
                account:
                  type: string
                  description: Tiểu khoản đặt lệnh.
                  x-parser-schema-id: <anonymous-schema-221>
                updatedTime:
                  type: string
                  description: Unix timestamp milliseconds.
                  x-parser-schema-id: <anonymous-schema-222>
                status:
                  type: string
                  description: Mã trạng thái.
                  x-parser-schema-id: <anonymous-schema-223>
                message:
                  type: string
                  description: Thông báo kết quả hoặc lỗi.
                  x-parser-schema-id: <anonymous-schema-224>
                username:
                  type: string
                  description: ID người dùng tại SSI.
                  x-parser-schema-id: <anonymous-schema-225>
              x-parser-schema-id: <anonymous-schema-212>
          x-parser-schema-id: <anonymous-schema-210>
        title: Sự kiện lệnh điều kiện
        description: Cập nhật trạng thái lệnh điều kiện FastConnect Conditional Order.
        example: |-
          {
            "type": "fcoEvent",
            "data": {
              "fcoId": "7528ac20-a340-4233-8bb7-a2379fc3c638",
              "notifyID": 1249008,
              "processStatus": "INIT",
              "matchedQuantity": 0,
              "isPlaceOrder": false,
              "instrumentID": "ssi",
              "quantity": 4000,
              "price": "MP",
              "account": "1231496",
              "updatedTime": "1751966448000",
              "status": "200",
              "message": "Success",
              "username": "123149"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: fcoEvent
    bindings: []
    extensions: *ref_3
sendOperations:
  - *ref_4
  - *ref_5
receiveOperations:
  - *ref_6
  - *ref_7
  - *ref_8
sendMessages:
  - *ref_9
  - *ref_10
receiveMessages:
  - *ref_11
  - *ref_12
  - *ref_13
extensions:
  - id: x-parser-unique-object-id
    value: orderStream
securitySchemes: []

````

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