Configuration
Full Config parameter reference for Go SDK
Config
Config is the central SDK configuration object. Create a Config instance with your credentials:
import "github.com/SSI-Securities-Inc/ssi-sdk-go/v3/ssi"
config := ssi.NewConfig("YOUR_CLIENT_ID")
config.APIKey = os.Getenv("SSI_API_KEY")
config.APISecret = os.Getenv("SSI_API_SECRET")
config.PrivateKey = os.Getenv("SSI_PRIVATE_KEY")All Configuration Parameters
Every duration is an integer in milliseconds with an Ms suffix (the old Timeout int and RetryDelay float64 fields no longer exist, and DeviceID was removed).
| Parameter | Type | Default | Description |
|---|---|---|---|
ClientID | string | (required) | Authentication client ID |
APIKey | string | "" | API key from SSI |
APISecret | string | "" | API secret from SSI |
PrivateKey | string | "" | Private key for order signing (REST orders and Trading WebSocket commands) |
APIURL | string | "https://api.ssi.com.vn" | REST API URL. Auth and market data always use this URL |
StreamingURL | string | "wss://stream.ssi.com.vn/ws/v3" | WebSocket streaming URL |
TradingAPIDomain | string | follows APIURL | Optional domain for trading, account and portfolio REST calls. A bare host gets https:// |
TradingWSDomain | string | "wss://api.ssi.com.vn/ws/v3/trading" | Domain of the Trading WebSocket. A bare host gets wss:// and the /ws/v3/trading path |
TimeoutMs | int | 60000 | HTTP request timeout and WebSocket handshake timeout (ms) |
MaxRetries | int | 5 | Maximum retry attempts |
RetryDelayMs | int | 2000 | Base delay between retries (ms, doubles on each retry) |
RateLimitPerSecond | int | 10 | Client-side request rate limit per second (0 = unlimited). A limit reported by the server can only lower it |
MaxBatchOrders | int | 20 | Largest batch accepted by PlaceBatchOrders / CancelBatchOrders (and the Trading WebSocket batch calls). Below 1 is normalized to 20 |
LogLevel | string | "INFO" | Log level: DEBUG, INFO, WARNING, ERROR |
Proxy | string | "" | Proxy URL (REST only) |
UserAgent | string | (a browser-like default) | Optional. Sent on HTTP requests and in order payloads. Also the User-Agent of the Trading WebSocket upgrade |
AutoReconnect | bool | true | The stream reconnects and resubscribes by itself. See Connection events |
OTPPollIntervalMs | int | 5000 | How often EnsureAuthenticated polls while a Smart OTP is pending (ms) |
OTPPollMaxWaitMs | int | 60000 | How long EnsureAuthenticated waits for a Smart OTP approval (ms) |
Helper methods
| Method | Description |
|---|---|
Normalized() | Returns a copy with defaults applied (for example MaxBatchOrders below 1 becomes 20). The original is never modified |
TradingAPIURL() | (string, error) — base URL for trading calls, from TradingAPIDomain or APIURL |
TradingWSURL() | URL of the Trading WebSocket, built from TradingWSDomain |
String() / GoString() | Print the config without APISecret and PrivateKey (APIKey is shown only as set/unset), so log.Printf("%v", config) does not leak them |
Batch orders: MaxBatchOrders
Config.MaxBatchOrders defaults to 20 (constant ssisdk.MaxBatchOrders). An empty batch, or one larger than the limit, is rejected by the SDK immediately with a *ValidationError and no network call. According to the SDK code comments, 20 is the server-side default.
Note — not verified. The API reference (batch place order endpoint) describes up to 50 orders per batch, while the SDK enforces
Config.MaxBatchOrders(default 20) locally. Whether the server accepts more than 20 orders per batch was not verified. If you raiseMaxBatchOrders, test against your environment first.
See Batch Orders for the methods.
Trading WebSocket settings
The tradingws package is outside the facades. See Trading WebSocket.
| Setting | Where | Description |
|---|---|---|
Config.TradingWSDomain | Config | WebSocket domain (default wss://api.ssi.com.vn/ws/v3/trading). Only wss:// is accepted |
Config.PrivateKey | Config | Required for commands that change state. Without it the SDK sends nothing (fail closed) |
Config.TimeoutMs | Config | Default request timeout of tradingws.TradingWS (10000 ms when unset) and the handshake timeout |
Config.UserAgent | Config | User-Agent of the upgrade request |
WithRequestTimeoutMs, WithSignatureEncoding, WithUserAgent, WithHandshakeGraceMs, WithRespectRateLimit, WithMaxRateLimitWaitMs, WithPingIntervalMs | Options of tradingws.TradingWS | Override per connection, see the options table |
Advanced Configuration
Debug logging
config := ssi.NewConfig("YOUR_CLIENT_ID")
config.APIKey = os.Getenv("SSI_API_KEY")
config.APISecret = os.Getenv("SSI_API_SECRET")
config.LogLevel = "DEBUG"Custom retry & rate limit
config := ssi.NewConfig("YOUR_CLIENT_ID")
config.APIKey = os.Getenv("SSI_API_KEY")
config.APISecret = os.Getenv("SSI_API_SECRET")
config.MaxRetries = 3
config.RetryDelayMs = 1000
config.RateLimitPerSecond = 5
config.TimeoutMs = 30000Proxy
config.Proxy = "http://proxy.example.com:8080"Separate trading domain
config.TradingAPIDomain = "trading.example.com" // bare host: https:// is added
config.TradingWSDomain = "trading-ws.example.com" // bare host: wss:// and the path are addedAuthentication and market data keep using APIURL.
Rate limit and retry behaviour
The SDK retries a rate-limited read request up to ssisdk.RateLimitMaxRetries (3) times, starting at RateLimitDefaultWaitMs (1000 ms, doubling). If the wait would exceed RateLimitMaxWaitMs (30000 ms) it returns a *RateLimitError instead. Write requests (POST / PUT / DELETE) are not retried. See Enums & Constants for the full list of constants.
Recommendations
- Keep credentials (
APIKey,APISecret,PrivateKey) in environment variables or a secret manager. - Missing
APIKey/APISecretwill cause authentication to fail. - Missing
PrivateKeywill affect order signing operations. - Set
RateLimitPerSecondaccording to platform policy. - Only enable
LogLevel = "DEBUG"in development environments. - Tune
TimeoutMs,MaxRetries, andRetryDelayMsaccording to actual workload. - Keep the clock of the machine accurate (NTP): batch orders carry a timestamp checked against a replay window.