Go

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

ParameterTypeDefaultDescription
ClientIDstring(required)Authentication client ID
APIKeystring""API key from SSI
APISecretstring""API secret from SSI
PrivateKeystring""Private key for order signing (REST orders and Trading WebSocket commands)
APIURLstring"https://api.ssi.com.vn"REST API URL. Auth and market data always use this URL
StreamingURLstring"wss://stream.ssi.com.vn/ws/v3"WebSocket streaming URL
TradingAPIDomainstringfollows APIURLOptional domain for trading, account and portfolio REST calls. A bare host gets https://
TradingWSDomainstring"wss://api.ssi.com.vn/ws/v3/trading"Domain of the Trading WebSocket. A bare host gets wss:// and the /ws/v3/trading path
TimeoutMsint60000HTTP request timeout and WebSocket handshake timeout (ms)
MaxRetriesint5Maximum retry attempts
RetryDelayMsint2000Base delay between retries (ms, doubles on each retry)
RateLimitPerSecondint10Client-side request rate limit per second (0 = unlimited). A limit reported by the server can only lower it
MaxBatchOrdersint20Largest batch accepted by PlaceBatchOrders / CancelBatchOrders (and the Trading WebSocket batch calls). Below 1 is normalized to 20
LogLevelstring"INFO"Log level: DEBUG, INFO, WARNING, ERROR
Proxystring""Proxy URL (REST only)
UserAgentstring(a browser-like default)Optional. Sent on HTTP requests and in order payloads. Also the User-Agent of the Trading WebSocket upgrade
AutoReconnectbooltrueThe stream reconnects and resubscribes by itself. See Connection events
OTPPollIntervalMsint5000How often EnsureAuthenticated polls while a Smart OTP is pending (ms)
OTPPollMaxWaitMsint60000How long EnsureAuthenticated waits for a Smart OTP approval (ms)

Helper methods

MethodDescription
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 raise MaxBatchOrders, test against your environment first.

See Batch Orders for the methods.

Trading WebSocket settings

The tradingws package is outside the facades. See Trading WebSocket.

SettingWhereDescription
Config.TradingWSDomainConfigWebSocket domain (default wss://api.ssi.com.vn/ws/v3/trading). Only wss:// is accepted
Config.PrivateKeyConfigRequired for commands that change state. Without it the SDK sends nothing (fail closed)
Config.TimeoutMsConfigDefault request timeout of tradingws.TradingWS (10000 ms when unset) and the handshake timeout
Config.UserAgentConfigUser-Agent of the upgrade request
WithRequestTimeoutMs, WithSignatureEncoding, WithUserAgent, WithHandshakeGraceMs, WithRespectRateLimit, WithMaxRateLimitWaitMs, WithPingIntervalMsOptions of tradingws.TradingWSOverride 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          = 30000

Proxy

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 added

Authentication 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/APISecret will cause authentication to fail.
  • Missing PrivateKey will affect order signing operations.
  • Set RateLimitPerSecond according to platform policy.
  • Only enable LogLevel = "DEBUG" in development environments.
  • Tune TimeoutMs, MaxRetries, and RetryDelayMs according to actual workload.
  • Keep the clock of the machine accurate (NTP): batch orders carry a timestamp checked against a replay window.

On this page