.NET

Cấu hình

Tham chiếu đầy đủ các tham số Config của .NET SDK

Config

Lớp Config (sealed class) là trung tâm cấu hình SDK. Tạo đối tượng Config với thông tin xác thực:

using SsiSdk;

var config = new Config("YOUR_CLIENT_ID")
{
    ApiKey = "YOUR_API_KEY",
    ApiSecret = "YOUR_API_SECRET",
    PrivateKey = "YOUR_PRIVATE_KEY",
};

Config có 2 constructor: Config() (rỗng, gán property sau) và Config(string clientId) (gán sẵn ClientId).

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

Tham sốKiểuMặc địnhMô tả
ClientIdstring""Client ID xác thực
ApiKeystring""API key từ SSI
ApiSecretstring""API secret từ SSI
PrivateKeystring""Private key cho 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
TimeoutSecondsint60Timeout request (giây)
MaxRetriesint5Số lần retry tối đa
RetryDelaydouble2.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
Proxystring?nullProxy URL

Cấu hình nâng cao

Debug logging

var config = new Config("YOUR_CLIENT_ID")
{
    ApiKey = "YOUR_API_KEY",
    ApiSecret = "YOUR_API_SECRET",
    LogLevel = "DEBUG",
};

Tuỳ chỉnh retry & rate limit

var config = new Config("YOUR_CLIENT_ID")
{
    ApiKey = "YOUR_API_KEY",
    ApiSecret = "YOUR_API_SECRET",
    MaxRetries = 3,
    RetryDelay = 1.0,
    RateLimitPerSecond = 5,
};

Proxy

var config = new Config("YOUR_CLIENT_ID")
{
    ApiKey = "YOUR_API_KEY",
    ApiSecret = "YOUR_API_SECRET",
    Proxy = "http://proxy.example.com:8080",
};

Khuyến nghị

  • Giữ thông tin khóa (ApiKey, ApiSecret, PrivateKey) trong biến môi trường hoặc secret manager (Azure Key Vault, AWS Secrets Manager, ...) — không hardcode hoặc commit vào Git.
  • Thiếu ApiKey/ApiSecret sẽ làm luồng xác thực thất bại (AuthenticationException).
  • Thiếu PrivateKey sẽ ảnh hưởng các nghiệp vụ ký lệnh giao dịch.
  • Cấu hình RateLimitPerSecond phù hợp với chính sách hệ thống.
  • Chỉ bật LogLevel = "DEBUG" trong môi trường phát triển.
  • Đặt TimeoutSeconds, MaxRetries, RetryDelay phù hợp với tải thực tế.

Trên trang này