.NET

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

ParameterTypeDefaultDescription
ClientIdstring""Authentication client ID
ApiKeystring""API key from SSI
ApiSecretstring""API secret from SSI
PrivateKeystring""Private key for order signing
ApiUrlstring"https://api.ssi.com.vn"REST API URL. Blank or whitespace falls back to the default.
StreamingUrlstring"wss://stream.ssi.com.vn/ws/v3"Market-data WebSocket streaming URL. Blank falls back to the default.
TradingApiDomainstring"https://api.ssi.com.vn"Host (or full URL) of the Trading REST API. If equal to the default, ApiUrl is used.
TradingWsDomainstring"wss://api.ssi.com.vn/ws/v3/trading"Host (or full URL) of the Trading WebSocket (see section 7)
TimeoutMsint60000HTTP/WebSocket request timeout (milliseconds)
MaxRetriesint5Maximum retry attempts (GET only, see below)
RetryDelayMsint2000Base delay for retry and reconnect backoff (milliseconds)
RateLimitPerSecondint10Client-side request rate limit per second (0 = unlimited)
LogLevelstring"INFO"Log level: DEBUG, INFO, WARNING, ERROR
Proxystring?nullProxy URL
UserAgentstring?nullUser-Agent sent on REST and WebSocket. null or blank uses the SDK default.
AutoReconnectbooltrueReconnect streaming sockets automatically
OtpPollIntervalMsint5000Interval between Smart OTP approval polls (milliseconds)
OtpPollMaxWaitMsint60000Total time to wait for a Smart OTP approval before giving up (milliseconds)
MaxBatchOrdersint20Maximum orders per batch request. Values below 1 reset to 20.

Read-only properties, derived from the parameters above:

PropertyDescription
TradingApiUrlBase 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.
TradingWsUrlWebSocket 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: TimeoutSeconds became TimeoutMs, RetryDelay (seconds, double) became RetryDelayMs (milliseconds, int), and Config.DeviceId was removed (the SDK uses the OS machine id as deviceId when 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.
  • RateLimitPerSecond is a client-side limit; the server's rate-limit info is in auth.RateLimit and in RateLimitException.

TradingWsOptions

Options for TradingWs.ConnectAsync(auth, options) (namespace SsiSdk). If you pass none, the defaults apply. For behaviour details see Trading WebSocket.

OptionTypeDefaultDescription
RequestTimeoutMsint?nullHow 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.
SignatureEncodingstring"auto""auto", "base64" or "hex". Any other value throws ValidationException.
HandshakeGraceMsint500How long to wait for a rejection frame after connecting
RespectRateLimitbooltrueWait when the server reports the quota is exhausted
MaxRateLimitWaitMsint2000Maximum wait for the rate limit
PingIntervalMsint?30000Ping period. null or 0 turns the ping loop off.
UserAgentstring?nullnull uses Config.UserAgent

Note: the XML comment of RequestTimeoutMs in 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 MaxBatchOrders is 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/ApiSecret will cause authentication to fail (AuthenticationException).
  • Missing PrivateKey will affect order signing operations (REST and Trading WebSocket).
  • Set RateLimitPerSecond according to platform policy.
  • Only enable LogLevel = "DEBUG" in development environments.
  • Tune TimeoutMs, MaxRetries, and RetryDelayMs according to actual workload.

On this page