Configuration
Full Config parameter reference for the .NET SDK
Config
The Config class (sealed) is the central SDK configuration object. Create a Config instance with your credentials:
using SsiSdk;
var config = new Config("YOUR_CLIENT_ID")
{
ApiKey = "YOUR_API_KEY",
ApiSecret = "YOUR_API_SECRET",
PrivateKey = "YOUR_PRIVATE_KEY",
};Config has 2 constructors: Config() (empty, set properties afterwards) and Config(string clientId) (pre-fills ClientId).
All Configuration Parameters
All durations are integer milliseconds (suffix Ms).
| Parameter | Type | Default | Description |
|---|---|---|---|
ClientId | string | "" | Authentication client ID |
ApiKey | string | "" | API key from SSI |
ApiSecret | string | "" | API secret from SSI |
PrivateKey | string | "" | Private key for order signing |
ApiUrl | string | "https://api.ssi.com.vn" | REST API URL. Blank or whitespace falls back to the default. |
StreamingUrl | string | "wss://stream.ssi.com.vn/ws/v3" | Market-data WebSocket streaming URL. Blank falls back to the default. |
TradingApiDomain | string | "https://api.ssi.com.vn" | Host (or full URL) of the Trading REST API. If equal to the default, ApiUrl is used. |
TradingWsDomain | string | "wss://api.ssi.com.vn/ws/v3/trading" | Host (or full URL) of the Trading WebSocket (see section 7) |
TimeoutMs | int | 60000 | HTTP/WebSocket request timeout (milliseconds) |
MaxRetries | int | 5 | Maximum retry attempts (GET only, see below) |
RetryDelayMs | int | 2000 | Base delay for retry and reconnect backoff (milliseconds) |
RateLimitPerSecond | int | 10 | Client-side request rate limit per second (0 = unlimited) |
LogLevel | string | "INFO" | Log level: DEBUG, INFO, WARNING, ERROR |
Proxy | string? | null | Proxy URL |
UserAgent | string? | null | User-Agent sent on REST and WebSocket. null or blank uses the SDK default. |
AutoReconnect | bool | true | Reconnect streaming sockets automatically |
OtpPollIntervalMs | int | 5000 | Interval between Smart OTP approval polls (milliseconds) |
OtpPollMaxWaitMs | int | 60000 | Total time to wait for a Smart OTP approval before giving up (milliseconds) |
MaxBatchOrders | int | 20 | Maximum orders per batch request. Values below 1 reset to 20. |
Read-only properties, derived from the parameters above:
| Property | Description |
|---|---|
TradingApiUrl | Base URL (scheme://host[:port]) that trading and account paths are sent to. Derived from TradingApiDomain; throws ValidationException if it is not an http(s) URL or a valid host. |
TradingWsUrl | WebSocket URL of the trading channel, derived from TradingWsDomain: adds wss:// if the scheme is missing and /ws/v3/trading if the path is missing. |
ToString() masks sensitive values: ApiKey is masked, ApiSecret and PrivateKey show ***. Even so, avoid logging Config.
Changes from the old version:
TimeoutSecondsbecameTimeoutMs,RetryDelay(seconds,double) becameRetryDelayMs(milliseconds,int), andConfig.DeviceIdwas removed (the SDK uses the OS machine id asdeviceIdwhen sending batches).
Retry and rate limit
- Only GET requests are retried. On a 429 for a GET, the SDK waits per
Retry-After, otherwise 1 second doubling each time, up to 3 retries and at most 30 seconds per wait. - POST, PUT and DELETE are never resent (place order, cancel, batch, FCO), because a repeated order could be created twice. After a timeout the outcome is unknown: check the order book before resending.
RateLimitPerSecondis a client-side limit; the server's rate-limit info is inauth.RateLimitand inRateLimitException.
TradingWsOptions
Options for TradingWs.ConnectAsync(auth, options) (namespace SsiSdk). If you pass none, the defaults apply. For behaviour details see Trading WebSocket.
| Option | Type | Default | Description |
|---|---|---|---|
RequestTimeoutMs | int? | null | How long to wait for a command's response. Through TradingWs.ConnectAsync, null becomes Config.TimeoutMs (or 10000 if that value is less than or equal to 0). A TradingWsClient created directly uses 10000. |
SignatureEncoding | string | "auto" | "auto", "base64" or "hex". Any other value throws ValidationException. |
HandshakeGraceMs | int | 500 | How long to wait for a rejection frame after connecting |
RespectRateLimit | bool | true | Wait when the server reports the quota is exhausted |
MaxRateLimitWaitMs | int | 2000 | Maximum wait for the rate limit |
PingIntervalMs | int? | 30000 | Ping period. null or 0 turns the ping loop off. |
UserAgent | string? | null | null uses Config.UserAgent |
Note: the XML comment of
RequestTimeoutMsin the SDK source still says "10000 when unset"; the table above reflects the code.
Advanced Configuration
Debug logging
var config = new Config("YOUR_CLIENT_ID")
{
ApiKey = "YOUR_API_KEY",
ApiSecret = "YOUR_API_SECRET",
LogLevel = "DEBUG",
};Custom retry & rate limit
var config = new Config("YOUR_CLIENT_ID")
{
ApiKey = "YOUR_API_KEY",
ApiSecret = "YOUR_API_SECRET",
MaxRetries = 3,
RetryDelayMs = 1000,
RateLimitPerSecond = 5,
};Smart OTP and batch
var config = new Config("YOUR_CLIENT_ID")
{
ApiKey = "YOUR_API_KEY",
ApiSecret = "YOUR_API_SECRET",
PrivateKey = "YOUR_PRIVATE_KEY",
OtpPollIntervalMs = 3000, // poll Smart OTP every 3 seconds
OtpPollMaxWaitMs = 90000, // wait for approval for at most 90 seconds
MaxBatchOrders = 20, // orders per batch limit
};The API reference states a server-side batch limit of 50 orders per request, while the SDK default is 20. Raising
MaxBatchOrdersis the caller's decision: see Batch Orders.
Proxy
var config = new Config("YOUR_CLIENT_ID")
{
ApiKey = "YOUR_API_KEY",
ApiSecret = "YOUR_API_SECRET",
Proxy = "http://proxy.example.com:8080",
};Recommendations
- Keep credentials (
ApiKey,ApiSecret,PrivateKey) in environment variables or a secret manager (Azure Key Vault, AWS Secrets Manager, etc.) — never hardcode them or commit to Git. - Missing
ApiKey/ApiSecretwill cause authentication to fail (AuthenticationException). - Missing
PrivateKeywill affect order signing operations (REST and Trading WebSocket). - Set
RateLimitPerSecondaccording to platform policy. - Only enable
LogLevel = "DEBUG"in development environments. - Tune
TimeoutMs,MaxRetries, andRetryDelayMsaccording to actual workload.