WebSocket API

order.place

Đặt lệnh mới. Hệ thống phản hồi ngay (orderStatus: "PD") để xác nhận đã nhận lệnh — trạng thái khớp lệnh thật sẽ đến sau qua kênh thông báo order.{accountNo} (xem mục "Đặt/sửa/hủy lệnh: xác nhận nhanh, kết quả đến sau" ở đầu tài liệu). Yêu cầu chữ ký signature (RSA+SHA256) theo quy định UBCKNN về toàn vẹn dữ liệu giao dịch.

Scope bắt buộc: tradingws:order:post.

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

bodyobjectrequired
idstringrequired

Định danh do client tự sinh để đối chiếu response.

methodstringrequired
paramsobjectrequired
symbolstringrequired

Mã chứng khoán.

sidestringrequired

Chiều mua hoặc bán của lệnh. (B - Buy/Mua, S - Sell/Bán)

orderTypestringoptional

Loại lệnh giao dịch. Mặc định `LO` nếu để trống.

accountNostringrequired

Số tài khoản giao dịch.

pricestring | nulloptional

Giá đặt lệnh. Bắt buộc và phải > 0 khi `orderType` là `LO`; không bắt buộc với các loại lệnh khác.

quantitynumberrequired

Khối lượng đặt lệnh.

clientRequestIdstring | nulloptional

Định danh lệnh do client tạo ra, dùng để đối chiếu trong response và event push sau này. Khi để trống, hệ thống tự sinh `clientRequestId`.

deviceIdstringrequired

Định danh thiết bị gửi yêu cầu đặt lệnh (MAC address hoặc IMEI).

userAgentstring | nulloptional

Thông tin trình duyệt/ứng dụng gửi yêu cầu.

signaturestringrequired

Chữ ký RSA+SHA256 (base64) trên nội dung `params`, dùng SecretKey của API Key. Bắt buộc.

timestampintegerrequired

Unix timestamp (mili-giây) tại thời điểm gửi request, dùng làm input ký số.

Response Body

application/json

application/json

Sample Request

wscat -c wss://api.ssi.com.vn/ws/v3/trading -x '{
  "id": "req-0001",
  "method": "order.place",
  "params": {
    "symbol": "SSI",
    "side": "B",
    "orderType": "LO",
    "price": "45.50",
    "quantity": 1000,
    "accountNo": "0901351",
    "deviceId": "MAC-AABBCCDDEEFF"
  },
  "signature": "base64(RSA-SHA256(...))",
  "timestamp": 1755000000000
}'

Sample Response

{
  "id": "req-0001",
  "method": "order.place",
  "status": 200,
  "result": {
    "clientRequestId": "req-0001",
    "orderStatus": "PD"
  },
  "rateLimit": {
    "limit": 50,
    "remaining": 47,
    "resetMs": 900
  }
}