Go

Cấu hình

Tham chiếu đầy đủ tham số Config cho Go SDK

Config

Config là đối tượng cấu hình trung tâm của SDK. Tạo instance Config với thông tin xác thực:

import "github.com/SSI-Securities-Inc/ssi-sdk-go/v3/ssi"

config := ssi.NewConfig("YOUR_CLIENT_ID")
config.APIKey     = "YOUR_API_KEY"
config.APISecret  = "YOUR_API_SECRET"
config.PrivateKey = "YOUR_PRIVATE_KEY"

Tất cả tham số cấu hình

Tham sốKiểuMặc địnhMô tả
ClientIDstring(bắt buộc)Client ID xác thực
APIKeystring""API key từ SSI
APISecretstring""API secret từ SSI
PrivateKeystring""Private key để ký lệnh giao dịch
APIURLstring"https://api.ssi.com.vn"URL REST API
StreamingURLstring"wss://stream.ssi.com.vn/ws/v3"URL WebSocket streaming
Timeoutint60Timeout request (giây)
MaxRetriesint5Số lần retry tối đa
RetryDelayfloat642.0Delay cơ sở giữa các lần retry (exponential backoff, giây)
RateLimitPerSecondint10Giới hạn request/giây (0 = không giới hạn)
LogLevelstring"INFO"Mức log: DEBUG, INFO, WARNING, ERROR

Cấu hình nâng cao

Debug logging

config := ssi.NewConfig("YOUR_CLIENT_ID")
config.APIKey    = "YOUR_API_KEY"
config.APISecret = "YOUR_API_SECRET"
config.LogLevel  = "DEBUG"

Tuỳ chỉnh retry & rate limit

config := ssi.NewConfig("YOUR_CLIENT_ID")
config.APIKey             = "YOUR_API_KEY"
config.APISecret          = "YOUR_API_SECRET"
config.MaxRetries         = 3
config.RetryDelay         = 1.0
config.RateLimitPerSecond = 5

Proxy

config.Proxy = "http://proxy.example.com:8080"

Khuyến nghị

  • Lưu credentials (APIKey, APISecret, PrivateKey) trong biến môi trường hoặc secret manager.
  • Thiếu APIKey/APISecret sẽ gây lỗi xác thực.
  • Thiếu PrivateKey sẽ ảnh hưởng đến thao tác ký lệnh.
  • Đặt RateLimitPerSecond theo chính sách nền tảng.
  • Chỉ bật LogLevel = "DEBUG" trong môi trường phát triển.
  • Điều chỉnh Timeout, MaxRetries, và RetryDelay theo workload thực tế.

Trên trang này