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

# Luồng điều khiển

> Client sử dụng các message điều khiển để quản lý topic trên hai channel `DATA` và `TRADING`.
Token được lấy trước qua API `getAccessToken` và dùng khi thiết lập kết nối.



## AsyncAPI

````yaml vi/asyncapi/ssi.2026-07-29.asyncapi.yaml controlStream
id: controlStream
title: Luồng điều khiển
description: >-
  Client sử dụng các message điều khiển để quản lý topic trên hai channel `DATA`
  và `TRADING`.

  Token được lấy trước qua API `getAccessToken` và dùng khi thiết lập kết nối.
servers:
  - id: production
    protocol: wss
    host: stream.ssi.com.vn
    bindings: []
    variables: []
address: /ws/v3
parameters: []
bindings: []
operations:
  - &ref_1
    id: onSubscribeRequest
    title: Gửi yêu cầu subscribe
    description: Client đăng ký một hoặc nhiều topic dữ liệu.
    type: receive
    messages:
      - &ref_5
        id: subscribeRequest
        contentType: application/json
        payload:
          - name: Yêu cầu đăng ký topic
            description: Client đăng ký một hoặc nhiều topic dữ liệu.
            type: object
            properties:
              - name: method
                type: string
                description: Phương thức đăng ký topic.
                required: true
              - name: channel
                type: string
                description: Nhóm dữ liệu cần đăng ký.
                enumValues:
                  - DATA
                  - TRADING
                required: true
              - name: topics
                type: array
                description: Danh sách topic cần theo dõi.
                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
              description: Phương thức đăng ký topic.
              x-parser-schema-id: <anonymous-schema-2>
            channel:
              type: string
              enum:
                - DATA
                - TRADING
              description: Nhóm dữ liệu cần đăng ký.
              x-parser-schema-id: <anonymous-schema-3>
            topics:
              type: array
              minItems: 1
              uniqueItems: true
              items:
                type: string
                minLength: 1
                pattern: >-
                  ^(trade|quote|room|put|oddlot)\.(index|exchange|[A-Za-z0-9_-]+(?:-[A-Za-z0-9_-]+)*|\*)(?:@(tick|1m|5m))?$|^market\.(index|exchange|[A-Za-z0-9_-]+(?:-[A-Za-z0-9_-]+)*|\*)$|^(order|portfolio)\..+$
                x-parser-schema-id: <anonymous-schema-5>
              description: Danh sách topic cần theo dõi.
              x-parser-schema-id: <anonymous-schema-4>
          x-parser-schema-id: <anonymous-schema-1>
        title: Yêu cầu đăng ký topic
        description: Client đăng ký một hoặc nhiều topic dữ liệu.
        example: |-
          {
            "method": "SUBSCRIBE",
            "channel": "DATA",
            "topics": [
              "trade.SSI",
              "quote.vn30"
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribeRequest
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: controlStream
  - &ref_2
    id: onUnsubscribeRequest
    title: Gửi yêu cầu unsubscribe
    description: Client hủy đăng ký một hoặc nhiều topic dữ liệu.
    type: receive
    messages:
      - &ref_6
        id: unsubscribeRequest
        contentType: application/json
        payload:
          - name: Yêu cầu hủy đăng ký topic
            description: Client hủy đăng ký một hoặc nhiều topic dữ liệu.
            type: object
            properties:
              - name: method
                type: string
                description: Phương thức hủy đăng ký topic.
                required: true
              - name: channel
                type: string
                description: Nhóm dữ liệu cần hủy đăng ký.
                enumValues:
                  - DATA
                  - TRADING
                required: true
              - name: topics
                type: array
                description: Danh sách topic cần hủy theo dõi.
                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
              description: Phương thức hủy đăng ký topic.
              x-parser-schema-id: <anonymous-schema-7>
            channel:
              type: string
              enum:
                - DATA
                - TRADING
              description: Nhóm dữ liệu cần hủy đăng ký.
              x-parser-schema-id: <anonymous-schema-8>
            topics:
              type: array
              minItems: 1
              uniqueItems: true
              items:
                type: string
                minLength: 1
                pattern: >-
                  ^(trade|quote|room|put|oddlot)\.(index|exchange|[A-Za-z0-9_-]+(?:-[A-Za-z0-9_-]+)*|\*)(?:@(tick|1m|5m))?$|^market\.(index|exchange|[A-Za-z0-9_-]+(?:-[A-Za-z0-9_-]+)*|\*)$|^(order|portfolio)\..+$
                x-parser-schema-id: <anonymous-schema-10>
              description: Danh sách topic cần hủy theo dõi.
              x-parser-schema-id: <anonymous-schema-9>
          x-parser-schema-id: <anonymous-schema-6>
        title: Yêu cầu hủy đăng ký topic
        description: Client hủy đăng ký một hoặc nhiều topic dữ liệu.
        example: |-
          {
            "method": "UNSUBSCRIBE",
            "channel": "DATA",
            "topics": [
              "trade.SSI",
              "quote.SSI"
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribeRequest
    bindings: []
    extensions: *ref_0
  - &ref_3
    id: onListSubscriptionRequest
    title: Liệt kê subscription
    description: Client yêu cầu danh sách topic đang đăng ký.
    type: receive
    messages:
      - &ref_7
        id: listSubscriptionRequest
        contentType: application/json
        payload:
          - name: Yêu cầu liệt kê subscription
            description: Client yêu cầu scope topic đang đăng ký.
            type: object
            properties:
              - name: method
                type: string
                description: Phương thức lấy danh sách topic đang đăng ký.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - method
          properties:
            method:
              type: string
              const: LIST_SUBSCRIPTION
              description: Phương thức lấy danh sách topic đang đăng ký.
              x-parser-schema-id: <anonymous-schema-12>
          x-parser-schema-id: <anonymous-schema-11>
        title: Yêu cầu liệt kê subscription
        description: Client yêu cầu scope topic đang đăng ký.
        example: |-
          {
            "method": "LIST_SUBSCRIPTION"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: listSubscriptionRequest
    bindings: []
    extensions: *ref_0
  - &ref_4
    id: onSubscriptionListMessage
    title: Nhận danh sách subscription
    description: Server trả về scope subscription theo nhóm trading và data.
    type: send
    messages:
      - &ref_8
        id: subscriptionListMessage
        contentType: application/json
        payload:
          - name: Danh sách subscription
            description: Scope topic hiện tại theo nhóm trading và data.
            type: object
            properties:
              - name: trading
                type: string
                description: Các topic trading, phân tách bằng dấu chấm phẩy.
                required: true
              - name: data
                type: string
                description: Các topic market data, phân tách bằng dấu chấm phẩy.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - trading
            - data
          properties:
            trading:
              type: string
              description: Các topic trading, phân tách bằng dấu chấm phẩy.
              x-parser-schema-id: <anonymous-schema-14>
            data:
              type: string
              description: Các topic market data, phân tách bằng dấu chấm phẩy.
              x-parser-schema-id: <anonymous-schema-15>
          x-parser-schema-id: <anonymous-schema-13>
        title: Danh sách subscription
        description: Scope topic hiện tại theo nhóm trading và data.
        example: |-
          {
            "trading": "order.0901351;portfolio.0901351",
            "data": "trade.SSI;quote.vn30"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscriptionListMessage
    bindings: []
    extensions: *ref_0
sendOperations:
  - *ref_1
  - *ref_2
  - *ref_3
receiveOperations:
  - *ref_4
sendMessages:
  - *ref_5
  - *ref_6
  - *ref_7
receiveMessages:
  - *ref_8
extensions:
  - id: x-parser-unique-object-id
    value: controlStream
securitySchemes: []

````

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