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

# Lịch sử giá khớp và cung cầu

> Client xác thực bằng `d|a|||<BASE64_JWT>`, subscribe bằng `d|st|...`,
unsubscribe bằng `d|ut|...` và gửi heartbeat `d|po` mỗi 2 giây.



## AsyncAPI

````yaml vi/openapi/tcbs.v1.asyncapi.yaml historyStream
id: historyStream
title: Lịch sử giá khớp và cung cầu
description: |-
  Client xác thực bằng `d|a|||<BASE64_JWT>`, subscribe bằng `d|st|...`,
  unsubscribe bằng `d|ut|...` và gửi heartbeat `d|po` mỗi 2 giây.
servers:
  - id: production
    protocol: wss
    host: openapi.tcbs.com.vn
    bindings: []
    variables: []
address: /ws/ouranos/v1/stream
parameters: []
bindings: []
operations:
  - &ref_2
    id: sendHistoryCommand
    title: Gửi lệnh điều khiển luồng lịch sử
    type: receive
    messages:
      - &ref_4
        id: command
        contentType: text/plain
        payload:
          - type: string
            examples: &ref_0
              - d|st|C001+C002S60+C002S900|TCB
              - d|po
            x-parser-schema-id: <anonymous-schema-123>
            name: Lệnh điều khiển luồng lịch sử
        headers: []
        jsonPayloadSchema:
          type: string
          examples: *ref_0
          x-parser-schema-id: <anonymous-schema-123>
        title: Lệnh điều khiển luồng lịch sử
        example: '"d|st|C001+C002S60+C002S900|TCB"'
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: command
    bindings: []
    extensions: &ref_1
      - id: x-parser-unique-object-id
        value: historyStream
  - &ref_3
    id: receiveHistoryData
    title: Nhận lịch sử giá và cung cầu
    type: send
    messages:
      - &ref_5
        id: authResult
        contentType: application/json
        payload:
          - name: Kết quả xác thực Ouranos
            description: >-
              Trên wire server gửi `d|0|{JSON_PAYLOAD}`; payload dưới đây là
              phần JSON đã tách prefix.
            type: object
            properties:
              - name: success
                type: boolean
                description: Kết quả xác thực.
                required: true
              - name: error
                type: object
                required: false
                properties:
                  - name: code
                    type: string
                    required: true
                  - name: message
                    type: string
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - success
          properties:
            success:
              type: boolean
              description: Kết quả xác thực.
              x-parser-schema-id: <anonymous-schema-125>
            error:
              oneOf:
                - type: 'null'
                  x-parser-schema-id: <anonymous-schema-127>
                - type: object
                  required:
                    - code
                    - message
                  properties:
                    code:
                      type: string
                      x-parser-schema-id: <anonymous-schema-129>
                    message:
                      type: string
                      x-parser-schema-id: <anonymous-schema-130>
                  x-parser-schema-id: <anonymous-schema-128>
              x-parser-schema-id: <anonymous-schema-126>
          x-parser-schema-id: <anonymous-schema-124>
        title: Kết quả xác thực Ouranos
        description: >-
          Trên wire server gửi `d|0|{JSON_PAYLOAD}`; payload dưới đây là phần
          JSON đã tách prefix.
        example: |-
          {
            "success": true,
            "error": null
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: authResult
      - &ref_6
        id: priceHistory
        contentType: application/json
        payload:
          - name: Lịch sử giá khớp một phút
            description: Trên wire server gửi `C001|<SYMBOL>|{JSON_PAYLOAD}`.
            type: object
            properties:
              - name: symbol
                type: string
                description: Mã chứng khoán.
                required: true
              - name: closePrice
                type: number
                description: Giá khớp.
                required: true
              - name: closeVol
                type: number
                description: Khối lượng khớp một phút.
                required: true
              - name: change
                type: number
                description: Thay đổi so với tham chiếu.
                required: true
              - name: reference
                type: number
                description: Giá tham chiếu.
                required: true
              - name: totalTrading
                type: number
                description: Tổng khối lượng giao dịch trong ngày.
                required: true
              - name: totalTradingValue
                type: number
                description: Tổng giá trị giao dịch trong ngày.
                required: true
              - name: timeSec
                type: string
                description: Thời gian epoch seconds.
                required: true
              - name: action
                type: string
                description: Mua hoặc bán chủ động.
                enumValues:
                  - BU
                  - SD
                required: true
              - name: unitTimeFrame
                type: string
                description: Khung thời gian tính bằng giây.
                required: true
              - name: tradingValue
                type: number
                description: Giá trị khớp trong một phút.
                required: true
              - name: buyUpAcc
                type: number
                description: Khối lượng mua chủ động tích lũy.
                required: true
              - name: sellDownAcc
                type: number
                description: Khối lượng bán chủ động tích lũy.
                required: true
              - name: bidPrice
                type: number
                description: Giá đặt mua tốt nhất.
                required: true
              - name: bidVol
                type: number
                description: Khối lượng đặt mua.
                required: true
              - name: askPrice
                type: number
                description: Giá đặt bán tốt nhất.
                required: true
              - name: askVol
                type: number
                description: Khối lượng đặt bán.
                required: true
              - name: prevChange
                type: number
                description: Thay đổi so với giá khớp gần nhất.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - symbol
            - closePrice
            - closeVol
            - change
            - reference
            - totalTrading
            - totalTradingValue
            - timeSec
            - action
            - unitTimeFrame
            - tradingValue
            - buyUpAcc
            - sellDownAcc
            - bidPrice
            - bidVol
            - askPrice
            - askVol
            - prevChange
          properties:
            symbol:
              type: string
              description: Mã chứng khoán.
              x-parser-schema-id: <anonymous-schema-132>
            closePrice:
              type: number
              description: Giá khớp.
              x-parser-schema-id: <anonymous-schema-133>
            closeVol:
              type: number
              description: Khối lượng khớp một phút.
              x-parser-schema-id: <anonymous-schema-134>
            change:
              type: number
              description: Thay đổi so với tham chiếu.
              x-parser-schema-id: <anonymous-schema-135>
            reference:
              type: number
              description: Giá tham chiếu.
              x-parser-schema-id: <anonymous-schema-136>
            totalTrading:
              type: number
              description: Tổng khối lượng giao dịch trong ngày.
              x-parser-schema-id: <anonymous-schema-137>
            totalTradingValue:
              type: number
              description: Tổng giá trị giao dịch trong ngày.
              x-parser-schema-id: <anonymous-schema-138>
            timeSec:
              type: string
              description: Thời gian epoch seconds.
              x-parser-schema-id: <anonymous-schema-139>
            action:
              type: string
              enum:
                - BU
                - SD
              description: Mua hoặc bán chủ động.
              x-parser-schema-id: <anonymous-schema-140>
            unitTimeFrame:
              type: string
              description: Khung thời gian tính bằng giây.
              x-parser-schema-id: <anonymous-schema-141>
            tradingValue:
              type: number
              description: Giá trị khớp trong một phút.
              x-parser-schema-id: <anonymous-schema-142>
            buyUpAcc:
              type: number
              description: Khối lượng mua chủ động tích lũy.
              x-parser-schema-id: <anonymous-schema-143>
            sellDownAcc:
              type: number
              description: Khối lượng bán chủ động tích lũy.
              x-parser-schema-id: <anonymous-schema-144>
            bidPrice:
              type: number
              description: Giá đặt mua tốt nhất.
              x-parser-schema-id: <anonymous-schema-145>
            bidVol:
              type: number
              description: Khối lượng đặt mua.
              x-parser-schema-id: <anonymous-schema-146>
            askPrice:
              type: number
              description: Giá đặt bán tốt nhất.
              x-parser-schema-id: <anonymous-schema-147>
            askVol:
              type: number
              description: Khối lượng đặt bán.
              x-parser-schema-id: <anonymous-schema-148>
            prevChange:
              type: number
              description: Thay đổi so với giá khớp gần nhất.
              x-parser-schema-id: <anonymous-schema-149>
          x-parser-schema-id: <anonymous-schema-131>
        title: Lịch sử giá khớp một phút
        description: Trên wire server gửi `C001|<SYMBOL>|{JSON_PAYLOAD}`.
        example: |-
          {
            "symbol": "<string>",
            "closePrice": 123,
            "closeVol": 123,
            "change": 123,
            "reference": 123,
            "totalTrading": 123,
            "totalTradingValue": 123,
            "timeSec": "<string>",
            "action": "<string>",
            "unitTimeFrame": "<string>",
            "tradingValue": 123,
            "buyUpAcc": 123,
            "sellDownAcc": 123,
            "bidPrice": 123,
            "bidVol": 123,
            "askPrice": 123,
            "askVol": 123,
            "prevChange": 123
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: priceHistory
      - &ref_7
        id: supplyDemand
        contentType: application/json
        payload:
          - name: Cung cầu một phút
            description: Trên wire server gửi `C002S60|<SYMBOL>|{JSON_PAYLOAD}`.
            type: object
            properties:
              - name: symbol
                type: string
                description: Mã chứng khoán.
                required: true
              - name: timeSec
                type: string
                description: Thời gian epoch seconds.
                required: true
              - name: totalBUVol
                type: number
                description: Khối lượng mua chủ động trong một phút.
                required: true
              - name: totalBUVolAcc
                type: number
                description: Khối lượng mua chủ động tích lũy.
                required: true
              - name: totalSDVol
                type: number
                description: Khối lượng bán chủ động trong một phút.
                required: true
              - name: totalSDVolAcc
                type: number
                description: Khối lượng bán chủ động tích lũy.
                required: true
              - name: bsAccRatio
                type: number
                description: Tỷ lệ mua/bán chủ động tích lũy.
                required: true
              - name: unitTimeFrame
                type: string
                description: Khung thời gian 60 giây.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - symbol
            - timeSec
            - totalBUVol
            - totalBUVolAcc
            - totalSDVol
            - totalSDVolAcc
            - bsAccRatio
            - unitTimeFrame
          properties:
            symbol:
              type: string
              description: Mã chứng khoán.
              x-parser-schema-id: <anonymous-schema-151>
            timeSec:
              type: string
              description: Thời gian epoch seconds.
              x-parser-schema-id: <anonymous-schema-152>
            totalBUVol:
              type: number
              description: Khối lượng mua chủ động trong một phút.
              x-parser-schema-id: <anonymous-schema-153>
            totalBUVolAcc:
              type: number
              description: Khối lượng mua chủ động tích lũy.
              x-parser-schema-id: <anonymous-schema-154>
            totalSDVol:
              type: number
              description: Khối lượng bán chủ động trong một phút.
              x-parser-schema-id: <anonymous-schema-155>
            totalSDVolAcc:
              type: number
              description: Khối lượng bán chủ động tích lũy.
              x-parser-schema-id: <anonymous-schema-156>
            bsAccRatio:
              type: number
              description: Tỷ lệ mua/bán chủ động tích lũy.
              x-parser-schema-id: <anonymous-schema-157>
            unitTimeFrame:
              type: string
              description: Khung thời gian 60 giây.
              x-parser-schema-id: <anonymous-schema-158>
          x-parser-schema-id: <anonymous-schema-150>
        title: Cung cầu một phút
        description: Trên wire server gửi `C002S60|<SYMBOL>|{JSON_PAYLOAD}`.
        example: |-
          {
            "symbol": "<string>",
            "timeSec": "<string>",
            "totalBUVol": 123,
            "totalBUVolAcc": 123,
            "totalSDVol": 123,
            "totalSDVolAcc": 123,
            "bsAccRatio": 123,
            "unitTimeFrame": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: supplyDemand
      - &ref_8
        id: foreignFlow
        contentType: application/json
        payload:
          - name: Dòng tiền khối ngoại 15 phút
            description: Trên wire server gửi `C002S900|<SYMBOL>|{JSON_PAYLOAD}`.
            type: object
            properties:
              - name: symbol
                type: string
                description: Mã chứng khoán.
                required: true
              - name: timeSec
                type: string
                description: Thời gian epoch seconds.
                required: true
              - name: totalBUVol
                type: number
                description: Khối lượng mua chủ động.
                required: true
              - name: totalBUVolAcc
                type: number
                description: Mua chủ động tích lũy.
                required: true
              - name: totalSDVol
                type: number
                description: Khối lượng bán chủ động.
                required: true
              - name: totalSDVolAcc
                type: number
                description: Bán chủ động tích lũy.
                required: true
              - name: bsAccRatio
                type: number
                description: Tỷ lệ mua/bán chủ động.
                required: true
              - name: unitTimeFrame
                type: string
                description: Khung thời gian 900 giây.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - symbol
            - timeSec
            - totalBUVol
            - totalBUVolAcc
            - totalSDVol
            - totalSDVolAcc
            - bsAccRatio
            - unitTimeFrame
          properties:
            symbol:
              type: string
              description: Mã chứng khoán.
              x-parser-schema-id: <anonymous-schema-160>
            timeSec:
              type: string
              description: Thời gian epoch seconds.
              x-parser-schema-id: <anonymous-schema-161>
            totalBUVol:
              type: number
              description: Khối lượng mua chủ động.
              x-parser-schema-id: <anonymous-schema-162>
            totalBUVolAcc:
              type: number
              description: Mua chủ động tích lũy.
              x-parser-schema-id: <anonymous-schema-163>
            totalSDVol:
              type: number
              description: Khối lượng bán chủ động.
              x-parser-schema-id: <anonymous-schema-164>
            totalSDVolAcc:
              type: number
              description: Bán chủ động tích lũy.
              x-parser-schema-id: <anonymous-schema-165>
            bsAccRatio:
              type: number
              description: Tỷ lệ mua/bán chủ động.
              x-parser-schema-id: <anonymous-schema-166>
            unitTimeFrame:
              type: string
              description: Khung thời gian 900 giây.
              x-parser-schema-id: <anonymous-schema-167>
          x-parser-schema-id: <anonymous-schema-159>
        title: Dòng tiền khối ngoại 15 phút
        description: Trên wire server gửi `C002S900|<SYMBOL>|{JSON_PAYLOAD}`.
        example: |-
          {
            "symbol": "<string>",
            "timeSec": "<string>",
            "totalBUVol": 123,
            "totalBUVolAcc": 123,
            "totalSDVol": 123,
            "totalSDVolAcc": 123,
            "bsAccRatio": 123,
            "unitTimeFrame": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: foreignFlow
    bindings: []
    extensions: *ref_1
sendOperations:
  - *ref_2
receiveOperations:
  - *ref_3
sendMessages:
  - *ref_4
receiveMessages:
  - *ref_5
  - *ref_6
  - *ref_7
  - *ref_8
extensions:
  - id: x-parser-unique-object-id
    value: historyStream
securitySchemes: []

````

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