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

# Thay đổi thông tin lệnh phái sinh

> Client xác thực bằng `authenticate|<BASE64_JSON>`, subscribe từng topic
`DE_ORDER`, `DE_CONDITIONAL_ORDER`, `DE_OPEN_POSITION` và gửi heartbeat `ping|1` mỗi 2 giây.



## AsyncAPI

````yaml vi/openapi/tcbs.v1.asyncapi.yaml derivativeOrderStream
id: derivativeOrderStream
title: Thay đổi thông tin lệnh phái sinh
description: >-
  Client xác thực bằng `authenticate|<BASE64_JSON>`, subscribe từng topic

  `DE_ORDER`, `DE_CONDITIONAL_ORDER`, `DE_OPEN_POSITION` và gửi heartbeat
  `ping|1` mỗi 2 giây.
servers:
  - id: production
    protocol: wss
    host: openapi.tcbs.com.vn
    bindings: []
    variables: []
address: /ws/nesoi
parameters: []
bindings: []
operations:
  - &ref_2
    id: sendDerivativeOrderCommand
    title: Gửi lệnh điều khiển luồng lệnh phái sinh
    type: receive
    messages:
      - &ref_4
        id: command
        contentType: text/plain
        payload:
          - type: string
            examples: &ref_0
              - subscribe|eyJ0b3BpYyI6IlNUT0NLX09SREVSIn0=
              - ping|1
            x-parser-schema-id: <anonymous-schema-203>
            name: Lệnh điều khiển luồng lệnh
            description: Xác thực, subscribe hoặc heartbeat.
        headers: []
        jsonPayloadSchema:
          type: string
          examples: *ref_0
          x-parser-schema-id: <anonymous-schema-203>
        title: Lệnh điều khiển luồng lệnh
        description: Xác thực, subscribe hoặc heartbeat.
        example: '"subscribe|eyJ0b3BpYyI6IlNUT0NLX09SREVSIn0="'
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: command
    bindings: []
    extensions: &ref_1
      - id: x-parser-unique-object-id
        value: derivativeOrderStream
  - &ref_3
    id: receiveDerivativeOrderData
    title: Nhận thay đổi lệnh và vị thế phái sinh
    type: send
    messages:
      - &ref_5
        id: authResult
        contentType: application/json
        payload:
          - name: Kết quả xác thực luồng lệnh
            description: >-
              Trên wire server gửi `authenticate|{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-205>
            error:
              oneOf:
                - type: 'null'
                  x-parser-schema-id: <anonymous-schema-207>
                - type: object
                  required:
                    - code
                    - message
                  properties:
                    code:
                      type: string
                      x-parser-schema-id: <anonymous-schema-209>
                    message:
                      type: string
                      x-parser-schema-id: <anonymous-schema-210>
                  x-parser-schema-id: <anonymous-schema-208>
              x-parser-schema-id: <anonymous-schema-206>
          x-parser-schema-id: <anonymous-schema-204>
        title: Kết quả xác thực luồng lệnh
        description: >-
          Trên wire server gửi `authenticate|{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: orderUpdate
        contentType: application/json
        payload:
          - name: Thay đổi lệnh phái sinh
            description: Trên wire server gửi `message_proto|DE_ORDER|{JSON_PAYLOAD}`.
            type: object
            properties:
              - name: subAccount
                type: string
                description: Số tài khoản phái sinh.
                required: true
              - name: orderNo
                type: string
                description: Số hiệu lệnh.
                required: true
              - name: pkOrderNo
                type: string
                description: Primary key lệnh.
                required: true
              - name: orderTime
                type: string
                description: Thời gian đặt lệnh.
                required: true
              - name: accountCode
                type: string
                description: Mã tài khoản.
                required: true
              - name: side
                type: string
                description: Chiều lệnh mua hoặc bán.
                enumValues:
                  - B
                  - S
                required: true
              - name: symbol
                type: string
                description: Mã hợp đồng.
                required: true
              - name: volume
                type: integer
                description: Khối lượng đặt lệnh.
                required: true
              - name: showPrice
                type: string
                description: Giá đặt hoặc MTL.
                required: true
              - name: matchVolume
                type: integer
                description: Khối lượng đã khớp.
                required: false
              - name: matchPriceBQ
                type: number
                description: Giá khớp bình quân.
                required: false
              - name: status
                type: string
                description: Trạng thái lệnh.
                required: true
              - name: orderStatus
                type: string
                description: Mã trạng thái lệnh.
                required: true
              - name: channel
                type: string
                description: Kênh đặt lệnh.
                required: true
              - name: group
                type: string
                description: Nhóm lệnh phái sinh.
                required: true
              - name: cancelTime
                type: string
                description: Thời gian hủy lệnh.
                required: false
              - name: isCancel
                type: string
                description: Có thể hủy.
                enumValues:
                  - '0'
                  - '1'
                required: false
              - name: isAmend
                type: string
                description: Có thể sửa.
                enumValues:
                  - '0'
                  - '1'
                required: false
              - name: info
                type: string
                description: Chi tiết từ chối.
                required: false
              - name: maxPrice
                type: integer
                description: Không dùng
                required: false
              - name: matchValue
                type: number
                description: Giá trị khớp.
                required: false
              - name: quote
                type: string
                description: Trạng thái quote.
                required: false
              - name: autoType
                type: string
                description: Loại lệnh tự động.
                required: false
              - name: product
                type: string
                description: Sản phẩm hoặc chỉ số SL/TP.
                required: false
              - name: orderType
                type: string
                description: Loại lệnh.
                required: true
              - name: source
                type: string
                description: Nguồn hệ thống hoặc người dùng.
                required: false
              - name: traderCode
                type: string
                description: Mã kênh đặt lệnh.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - subAccount
            - orderNo
            - pkOrderNo
            - orderTime
            - accountCode
            - side
            - symbol
            - volume
            - showPrice
            - status
            - orderStatus
            - channel
            - group
            - orderType
          properties:
            subAccount:
              type: string
              description: Số tài khoản phái sinh.
              x-parser-schema-id: <anonymous-schema-212>
            orderNo:
              type: string
              description: Số hiệu lệnh.
              x-parser-schema-id: <anonymous-schema-213>
            pkOrderNo:
              type: string
              description: Primary key lệnh.
              x-parser-schema-id: <anonymous-schema-214>
            orderTime:
              type: string
              description: Thời gian đặt lệnh.
              x-parser-schema-id: <anonymous-schema-215>
            accountCode:
              type: string
              description: Mã tài khoản.
              x-parser-schema-id: <anonymous-schema-216>
            side:
              type: string
              enum:
                - B
                - S
              description: Chiều lệnh mua hoặc bán.
              x-parser-schema-id: <anonymous-schema-217>
            symbol:
              type: string
              description: Mã hợp đồng.
              x-parser-schema-id: <anonymous-schema-218>
            volume:
              type: integer
              format: int64
              description: Khối lượng đặt lệnh.
              x-parser-schema-id: <anonymous-schema-219>
            showPrice:
              type: string
              description: Giá đặt hoặc MTL.
              x-parser-schema-id: <anonymous-schema-220>
            matchVolume:
              type: integer
              format: int64
              description: Khối lượng đã khớp.
              x-parser-schema-id: <anonymous-schema-221>
            matchPriceBQ:
              type: number
              description: Giá khớp bình quân.
              x-parser-schema-id: <anonymous-schema-222>
            status:
              type: string
              description: Trạng thái lệnh.
              x-parser-schema-id: <anonymous-schema-223>
            orderStatus:
              type: string
              description: Mã trạng thái lệnh.
              x-parser-schema-id: <anonymous-schema-224>
            channel:
              type: string
              description: Kênh đặt lệnh.
              x-parser-schema-id: <anonymous-schema-225>
            group:
              type: string
              description: Nhóm lệnh phái sinh.
              x-parser-schema-id: <anonymous-schema-226>
            cancelTime:
              type: string
              description: Thời gian hủy lệnh.
              x-parser-schema-id: <anonymous-schema-227>
            isCancel:
              type: string
              enum:
                - '0'
                - '1'
              description: Có thể hủy.
              x-parser-schema-id: <anonymous-schema-228>
            isAmend:
              type: string
              enum:
                - '0'
                - '1'
              description: Có thể sửa.
              x-parser-schema-id: <anonymous-schema-229>
            info:
              type: string
              description: Chi tiết từ chối.
              x-parser-schema-id: <anonymous-schema-230>
            maxPrice:
              type: integer
              format: int64
              description: Không dùng
              x-parser-schema-id: <anonymous-schema-231>
            matchValue:
              type: number
              description: Giá trị khớp.
              x-parser-schema-id: <anonymous-schema-232>
            quote:
              type: string
              description: Trạng thái quote.
              x-parser-schema-id: <anonymous-schema-233>
            autoType:
              type: string
              description: Loại lệnh tự động.
              x-parser-schema-id: <anonymous-schema-234>
            product:
              type: string
              description: Sản phẩm hoặc chỉ số SL/TP.
              x-parser-schema-id: <anonymous-schema-235>
            orderType:
              type: string
              description: Loại lệnh.
              x-parser-schema-id: <anonymous-schema-236>
            source:
              type: string
              description: Nguồn hệ thống hoặc người dùng.
              x-parser-schema-id: <anonymous-schema-237>
            traderCode:
              type: string
              description: Mã kênh đặt lệnh.
              x-parser-schema-id: <anonymous-schema-238>
          x-parser-schema-id: <anonymous-schema-211>
        title: Thay đổi lệnh phái sinh
        description: Trên wire server gửi `message_proto|DE_ORDER|{JSON_PAYLOAD}`.
        example: |-
          {
            "subAccount": "738764A",
            "orderNo": "41",
            "pkOrderNo": "7861546",
            "orderTime": "14:34:10",
            "accountCode": "738764A",
            "side": "B",
            "symbol": "VN30F2110",
            "volume": 1,
            "showPrice": "MTL",
            "status": "P",
            "orderStatus": "2",
            "channel": "D",
            "group": "FU",
            "isCancel": "1",
            "isAmend": "1"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: orderUpdate
      - &ref_7
        id: conditionalOrderUpdate
        contentType: application/json
        payload:
          - name: Thay đổi lệnh điều kiện phái sinh
            description: >-
              Trên wire server gửi
              `message_proto|DE_CONDITIONAL_ORDER|{JSON_PAYLOAD}`.
            type: object
            properties:
              - name: sub_account
                type: string
                description: Số tài khoản phái sinh.
                required: true
              - name: order_no
                type: string
                description: Số hiệu lệnh.
                required: true
              - name: group_order
                type: string
                description: Nhóm lệnh.
                required: false
              - name: pk_order_no
                type: string
                description: Primary key lệnh.
                required: true
              - name: account_code
                type: string
                description: Mã tài khoản.
                required: true
              - name: side
                type: string
                description: Chiều lệnh mua hoặc bán.
                enumValues:
                  - B
                  - S
                required: true
              - name: symbol
                type: string
                description: Mã hợp đồng.
                required: true
              - name: volume
                type: integer
                description: Khối lượng lệnh.
                required: true
              - name: show_price
                type: string
                description: Giá đặt.
                required: true
              - name: condition
                type: string
                description: Điều kiện kích hoạt.
                required: false
              - name: result
                type: string
                description: Hủy hoặc kích hoạt.
                enumValues:
                  - '0'
                  - '1'
                required: false
              - name: active_time
                type: string
                description: Thời gian kích hoạt.
                required: false
              - name: send_time
                type: string
                description: Thời gian đặt lệnh.
                required: false
              - name: cancel_time
                type: string
                description: Thời gian hủy.
                required: false
              - name: group
                type: string
                description: Nhóm phái sinh.
                required: false
              - name: channel
                type: string
                description: Kênh đặt lệnh.
                required: false
              - name: so_price
                type: number
                description: Giá stop.
                required: false
              - name: order_type
                type: string
                description: Loại lệnh.
                required: false
              - name: from_time
                type: string
                description: Ngày bắt đầu hiệu lực.
                required: false
              - name: exp_time
                type: string
                description: Ngày hết hiệu lực.
                required: false
              - name: status
                type: string
                description: Kích hoạt
                enumValues:
                  - '1'
                  - '2'
                  - '3'
                required: true
              - name: details
                type: string
                description: Số hiệu lệnh đã kích hoạt.
                required: false
              - name: message
                type: string
                description: Thông báo.
                required: false
              - name: notes
                type: string
                description: Loại chiến lược.
                required: false
              - name: call_back_point
                type: string
                description: Biên trượt trailing stop.
                required: false
              - name: trailing_price
                type: string
                description: Giá trailing.
                required: false
              - name: trigger_condition
                type: string
                description: Điều kiện kích hoạt trailing.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - sub_account
            - order_no
            - pk_order_no
            - account_code
            - side
            - symbol
            - volume
            - show_price
            - status
          properties:
            sub_account:
              type: string
              description: Số tài khoản phái sinh.
              x-parser-schema-id: <anonymous-schema-240>
            order_no:
              type: string
              description: Số hiệu lệnh.
              x-parser-schema-id: <anonymous-schema-241>
            group_order:
              type: string
              description: Nhóm lệnh.
              x-parser-schema-id: <anonymous-schema-242>
            pk_order_no:
              type: string
              description: Primary key lệnh.
              x-parser-schema-id: <anonymous-schema-243>
            account_code:
              type: string
              description: Mã tài khoản.
              x-parser-schema-id: <anonymous-schema-244>
            side:
              type: string
              enum:
                - B
                - S
              description: Chiều lệnh mua hoặc bán.
              x-parser-schema-id: <anonymous-schema-245>
            symbol:
              type: string
              description: Mã hợp đồng.
              x-parser-schema-id: <anonymous-schema-246>
            volume:
              type: integer
              format: int64
              description: Khối lượng lệnh.
              x-parser-schema-id: <anonymous-schema-247>
            show_price:
              type: string
              description: Giá đặt.
              x-parser-schema-id: <anonymous-schema-248>
            condition:
              type: string
              description: Điều kiện kích hoạt.
              x-parser-schema-id: <anonymous-schema-249>
            result:
              type: string
              enum:
                - '0'
                - '1'
              description: Hủy hoặc kích hoạt.
              x-parser-schema-id: <anonymous-schema-250>
            active_time:
              type: string
              description: Thời gian kích hoạt.
              x-parser-schema-id: <anonymous-schema-251>
            send_time:
              type: string
              description: Thời gian đặt lệnh.
              x-parser-schema-id: <anonymous-schema-252>
            cancel_time:
              type: string
              description: Thời gian hủy.
              x-parser-schema-id: <anonymous-schema-253>
            group:
              type: string
              description: Nhóm phái sinh.
              x-parser-schema-id: <anonymous-schema-254>
            channel:
              type: string
              description: Kênh đặt lệnh.
              x-parser-schema-id: <anonymous-schema-255>
            so_price:
              type: number
              description: Giá stop.
              x-parser-schema-id: <anonymous-schema-256>
            order_type:
              type: string
              description: Loại lệnh.
              x-parser-schema-id: <anonymous-schema-257>
            from_time:
              type: string
              description: Ngày bắt đầu hiệu lực.
              x-parser-schema-id: <anonymous-schema-258>
            exp_time:
              type: string
              description: Ngày hết hiệu lực.
              x-parser-schema-id: <anonymous-schema-259>
            status:
              type: string
              enum:
                - '1'
                - '2'
                - '3'
              description: Kích hoạt
              x-parser-schema-id: <anonymous-schema-260>
            details:
              type: string
              description: Số hiệu lệnh đã kích hoạt.
              x-parser-schema-id: <anonymous-schema-261>
            message:
              type: string
              description: Thông báo.
              x-parser-schema-id: <anonymous-schema-262>
            notes:
              type: string
              description: Loại chiến lược.
              x-parser-schema-id: <anonymous-schema-263>
            call_back_point:
              type: string
              description: Biên trượt trailing stop.
              x-parser-schema-id: <anonymous-schema-264>
            trailing_price:
              type: string
              description: Giá trailing.
              x-parser-schema-id: <anonymous-schema-265>
            trigger_condition:
              type: string
              description: Điều kiện kích hoạt trailing.
              x-parser-schema-id: <anonymous-schema-266>
          x-parser-schema-id: <anonymous-schema-239>
        title: Thay đổi lệnh điều kiện phái sinh
        description: >-
          Trên wire server gửi
          `message_proto|DE_CONDITIONAL_ORDER|{JSON_PAYLOAD}`.
        example: |-
          {
            "sub_account": "<string>",
            "order_no": "<string>",
            "group_order": "<string>",
            "pk_order_no": "<string>",
            "account_code": "<string>",
            "side": "<string>",
            "symbol": "<string>",
            "volume": 123,
            "show_price": "<string>",
            "condition": "<string>",
            "result": "<string>",
            "active_time": "<string>",
            "send_time": "<string>",
            "cancel_time": "<string>",
            "group": "<string>",
            "channel": "<string>",
            "so_price": 123,
            "order_type": "<string>",
            "from_time": "<string>",
            "exp_time": "<string>",
            "status": "<string>",
            "details": "<string>",
            "message": "<string>",
            "notes": "<string>",
            "call_back_point": "<string>",
            "trailing_price": "<string>",
            "trigger_condition": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: conditionalOrderUpdate
      - &ref_8
        id: openPositionUpdate
        contentType: application/json
        payload:
          - name: Thay đổi vị thế mở phái sinh
            description: >-
              Trên wire server gửi
              `message_proto|DE_OPEN_POSITION|{JSON_PAYLOAD}`.
            type: object
            properties:
              - name: sub_account
                type: string
                description: Số tài khoản phái sinh.
                required: true
              - name: symbol
                type: string
                description: Mã hợp đồng.
                required: true
              - name: side
                type: string
                description: Vị thế Long hoặc Short.
                enumValues:
                  - L
                  - S
                required: true
              - name: account
                type: string
                description: Số tài khoản.
                required: true
              - name: last_price
                type: number
                description: Giá hiện tại.
                required: true
              - name: avg_remain
                type: number
                description: Giá trung bình phần còn lại.
                required: true
              - name: im_value
                type: number
                description: Giá trị ký quỹ ban đầu.
                required: true
              - name: net
                type: number
                description: Số vị thế đang nắm giữ.
                required: true
              - name: stoploss
                type: number
                description: Giá stop loss.
                required: false
              - name: takeprofit
                type: number
                description: Giá take profit.
                required: false
              - name: pc_remain
                type: number
                description: Phần trăm lãi/lỗ vị thế mở.
                required: true
              - name: vm_remain
                type: number
                description: Giá trị VM chưa đóng.
                required: true
              - name: duedate
                type: string
                description: Ngày đáo hạn.
                required: true
              - name: netoffvol
                type: integer
                description: Số cần net-off.
                required: false
              - name: trigger_type
                type: string
                description: Giá kích hoạt trailing.
                required: false
              - name: call_back_point
                type: number
                description: Biên trượt trailing.
                required: false
              - name: trailing_price
                type: number
                description: Giá lệnh trailing.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - sub_account
            - symbol
            - side
            - account
            - last_price
            - avg_remain
            - im_value
            - net
            - pc_remain
            - vm_remain
            - duedate
          properties:
            sub_account:
              type: string
              description: Số tài khoản phái sinh.
              x-parser-schema-id: <anonymous-schema-268>
            symbol:
              type: string
              description: Mã hợp đồng.
              x-parser-schema-id: <anonymous-schema-269>
            side:
              type: string
              enum:
                - L
                - S
              description: Vị thế Long hoặc Short.
              x-parser-schema-id: <anonymous-schema-270>
            account:
              type: string
              description: Số tài khoản.
              x-parser-schema-id: <anonymous-schema-271>
            last_price:
              type: number
              description: Giá hiện tại.
              x-parser-schema-id: <anonymous-schema-272>
            avg_remain:
              type: number
              description: Giá trung bình phần còn lại.
              x-parser-schema-id: <anonymous-schema-273>
            im_value:
              type: number
              description: Giá trị ký quỹ ban đầu.
              x-parser-schema-id: <anonymous-schema-274>
            net:
              type: number
              description: Số vị thế đang nắm giữ.
              x-parser-schema-id: <anonymous-schema-275>
            stoploss:
              type: number
              description: Giá stop loss.
              x-parser-schema-id: <anonymous-schema-276>
            takeprofit:
              type: number
              description: Giá take profit.
              x-parser-schema-id: <anonymous-schema-277>
            pc_remain:
              type: number
              description: Phần trăm lãi/lỗ vị thế mở.
              x-parser-schema-id: <anonymous-schema-278>
            vm_remain:
              type: number
              description: Giá trị VM chưa đóng.
              x-parser-schema-id: <anonymous-schema-279>
            duedate:
              type: string
              description: Ngày đáo hạn.
              x-parser-schema-id: <anonymous-schema-280>
            netoffvol:
              type: integer
              format: int64
              description: Số cần net-off.
              x-parser-schema-id: <anonymous-schema-281>
            trigger_type:
              type: string
              description: Giá kích hoạt trailing.
              x-parser-schema-id: <anonymous-schema-282>
            call_back_point:
              type: number
              description: Biên trượt trailing.
              x-parser-schema-id: <anonymous-schema-283>
            trailing_price:
              type: number
              description: Giá lệnh trailing.
              x-parser-schema-id: <anonymous-schema-284>
          x-parser-schema-id: <anonymous-schema-267>
        title: Thay đổi vị thế mở phái sinh
        description: Trên wire server gửi `message_proto|DE_OPEN_POSITION|{JSON_PAYLOAD}`.
        example: |-
          {
            "sub_account": "<string>",
            "symbol": "<string>",
            "side": "<string>",
            "account": "<string>",
            "last_price": 123,
            "avg_remain": 123,
            "im_value": 123,
            "net": 123,
            "stoploss": 123,
            "takeprofit": 123,
            "pc_remain": 123,
            "vm_remain": 123,
            "duedate": "<string>",
            "netoffvol": 123,
            "trigger_type": "<string>",
            "call_back_point": 123,
            "trailing_price": 123
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: openPositionUpdate
    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: derivativeOrderStream
securitySchemes: []

````

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