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

# Danh mục

> Cập nhật vị thế và lãi/lỗ của tài khoản. SSI hiện hỗ trợ tài khoản đuôi 8.



## AsyncAPI

````yaml vi/asyncapi/ssi.2026-07-29.asyncapi.yaml portfolioStream
id: portfolioStream
title: Danh mục
description: Cập nhật vị thế và lãi/lỗ của tài khoản. SSI hiện hỗ trợ tài khoản đuôi 8.
servers:
  - id: production
    protocol: wss
    host: stream.ssi.com.vn
    bindings: []
    variables: []
address: /ws/v3
parameters: []
bindings: []
operations:
  - &ref_3
    id: onPortfolioEvent
    title: Nhận sự kiện danh mục
    type: send
    messages:
      - &ref_6
        id: update
        contentType: application/json
        payload:
          - name: Sự kiện danh mục
            description: Cập nhật vị thế và lãi/lỗ của tài khoản.
            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: symbol
                type: string
                description: Mã chứng khoán.
                required: true
              - name: accountNo
                type: string
                description: Số tài khoản.
                required: true
              - name: longQty
                type: number
                description: Vị thế long.
                required: true
              - name: shortQty
                type: number
                description: Vị thế short.
                required: true
              - name: net
                type: number
                description: Vị thế net, bằng long trừ short.
                required: true
              - name: bidAvgPrice
                type: string
                description: Giá mua trung bình.
                required: true
              - name: askAvgPrice
                type: string
                description: Giá bán trung bình.
                required: true
              - name: tradePrice
                type: string
                description: Giá khớp.
                required: true
              - name: marketPrice
                type: string
                description: Giá thị trường.
                required: true
              - name: floatingPL
                type: string
                description: Lãi/lỗ tạm tính.
                required: true
              - name: tradingPL
                type: string
                description: Lãi/lỗ đã chốt.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - eventType
            - notifyId
            - connectionId
            - symbol
            - accountNo
            - longQty
            - shortQty
            - net
            - bidAvgPrice
            - askAvgPrice
            - tradePrice
            - marketPrice
            - floatingPL
            - tradingPL
          properties:
            eventType:
              type: string
              const: clientPortfolioEvent
              description: Loại event.
              x-parser-schema-id: <anonymous-schema-237>
            notifyId:
              type: integer
              format: int64
              description: Số serial của event message.
              x-parser-schema-id: <anonymous-schema-238>
            connectionId:
              type: string
              description: Định danh phiên kết nối stream.
              x-parser-schema-id: <anonymous-schema-239>
            symbol:
              type: string
              description: Mã chứng khoán.
              x-parser-schema-id: <anonymous-schema-240>
            accountNo:
              type: string
              description: Số tài khoản.
              x-parser-schema-id: <anonymous-schema-241>
            longQty:
              type: number
              description: Vị thế long.
              x-parser-schema-id: <anonymous-schema-242>
            shortQty:
              type: number
              description: Vị thế short.
              x-parser-schema-id: <anonymous-schema-243>
            net:
              type: number
              description: Vị thế net, bằng long trừ short.
              x-parser-schema-id: <anonymous-schema-244>
            bidAvgPrice:
              type: string
              description: Giá mua trung bình.
              x-parser-schema-id: <anonymous-schema-245>
            askAvgPrice:
              type: string
              description: Giá bán trung bình.
              x-parser-schema-id: <anonymous-schema-246>
            tradePrice:
              type: string
              description: Giá khớp.
              x-parser-schema-id: <anonymous-schema-247>
            marketPrice:
              type: string
              description: Giá thị trường.
              x-parser-schema-id: <anonymous-schema-248>
            floatingPL:
              type: string
              description: Lãi/lỗ tạm tính.
              x-parser-schema-id: <anonymous-schema-249>
            tradingPL:
              type: string
              description: Lãi/lỗ đã chốt.
              x-parser-schema-id: <anonymous-schema-250>
          x-parser-schema-id: <anonymous-schema-236>
        title: Sự kiện danh mục
        description: Cập nhật vị thế và lãi/lỗ của tài khoản.
        example: |-
          {
            "eventType": "clientPortfolioEvent",
            "notifyId": 1023456,
            "connectionId": "CONN-8899-XYZZ",
            "symbol": "VND",
            "accountNo": "0123456789",
            "longQty": 1500,
            "shortQty": 500,
            "net": 1000,
            "bidAvgPrice": "12.35",
            "askAvgPrice": "12.40",
            "tradePrice": "12.38",
            "marketPrice": "12.45",
            "floatingPL": "1500.75",
            "tradingPL": "2500.50"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: update
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: portfolioStream
  - &ref_1
    id: onPortfolioSubscription
    title: Đăng ký luồng danh mục
    type: receive
    messages:
      - &ref_4
        id: subscribeRequest
        contentType: application/json
        payload:
          - name: Yêu cầu đăng ký cập nhật danh mục
            description: Đăng ký các topic portfolio 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 cập nhật danh mục.
                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-227>
            channel:
              type: string
              const: TRADING
              x-parser-schema-id: <anonymous-schema-228>
            topics:
              type: array
              minItems: 1
              uniqueItems: true
              description: Danh sách topic cập nhật danh mục.
              items:
                type: string
                minLength: 1
                pattern: ^portfolio\.(\*|[A-Za-z0-9_-]+(?:-[A-Za-z0-9_-]+)*)$
                x-parser-schema-id: <anonymous-schema-230>
              x-parser-schema-id: <anonymous-schema-229>
          x-parser-schema-id: <anonymous-schema-226>
        title: Yêu cầu đăng ký cập nhật danh mục
        description: Đăng ký các topic portfolio trên channel TRADING.
        example: |-
          {
            "method": "SUBSCRIBE",
            "channel": "TRADING",
            "topics": [
              "portfolio.0901351",
              "portfolio.1231996-1231998",
              "portfolio.*"
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribeRequest
    bindings: []
    extensions: *ref_0
  - &ref_2
    id: onPortfolioUnsubscription
    title: Hủy đăng ký luồng danh mục
    type: receive
    messages:
      - &ref_5
        id: unsubscribeRequest
        contentType: application/json
        payload:
          - name: Yêu cầu hủy cập nhật danh mục
            description: Hủy đăng ký các topic portfolio 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 cập nhật danh mục 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-232>
            channel:
              type: string
              const: TRADING
              x-parser-schema-id: <anonymous-schema-233>
            topics:
              type: array
              minItems: 1
              uniqueItems: true
              description: Danh sách topic cập nhật danh mục cần hủy.
              items:
                type: string
                minLength: 1
                pattern: ^portfolio\.(\*|[A-Za-z0-9_-]+(?:-[A-Za-z0-9_-]+)*)$
                x-parser-schema-id: <anonymous-schema-235>
              x-parser-schema-id: <anonymous-schema-234>
          x-parser-schema-id: <anonymous-schema-231>
        title: Yêu cầu hủy cập nhật danh mục
        description: Hủy đăng ký các topic portfolio trên channel TRADING.
        example: |-
          {
            "method": "UNSUBSCRIBE",
            "channel": "TRADING",
            "topics": [
              "portfolio.0901351",
              "portfolio.*"
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribeRequest
    bindings: []
    extensions: *ref_0
sendOperations:
  - *ref_1
  - *ref_2
receiveOperations:
  - *ref_3
sendMessages:
  - *ref_4
  - *ref_5
receiveMessages:
  - *ref_6
extensions:
  - id: x-parser-unique-object-id
    value: portfolioStream
securitySchemes: []

````

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