Configuration
Full Config parameter reference for Python SDK
Config
The Config class is the central configuration for the SDK. Create a Config object with your credentials:
from ssi_sdk import Config
config = Config(
client_id="<CLIENT_ID>",
api_key="<API_KEY>",
api_secret="<API_SECRET>",
private_key="<PRIVATE_KEY_CONTENT>",
)Every duration in Config is in milliseconds and has an _ms suffix. The old names timeout, retry_delay, retry_after and poll_interval were renamed in 3.3.0 and now raise TypeError. Any parameter that is not in Config (including the removed device_id) also raises TypeError.
All Configuration Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
client_id | str | "" | Client ID for authentication |
api_key | str | "" | API key from SSI |
api_secret | str | "" | API secret from SSI |
private_key | str | "" | Private key for signing trading orders |
api_url | str | "https://api.ssi.com.vn" | REST API URL (authentication and market data always use it) |
streaming_url | str | "wss://stream.ssi.com.vn/ws/v3" | WebSocket streaming URL |
trading_api_domain | str | "https://api.ssi.com.vn" | Trading REST API URL (orders, FCO, account, portfolio). While left at the default it follows api_url; it also accepts host or host:port (the SDK adds https://). Token and rate limit are shared. Read the effective URL from Config.trading_api_url |
trading_ws_domain | str | "wss://api.ssi.com.vn/ws/v3/trading" | Trading WebSocket URL. Accepts host or host:port (the SDK adds wss:// and /ws/v3/trading). Read the effective URL from Config.trading_ws_url |
timeout_ms | int | 60000 | Request timeout (milliseconds) |
max_retries | int | 5 | Maximum retry attempts (only GET requests are retried) |
retry_delay_ms | int | 2000 | Base delay between retries (exponential backoff, milliseconds). Streaming also uses it as the base for reconnect backoff |
rate_limit_per_second | int | 10 | Request limit per second (0 = unlimited) |
max_batch_orders | int | 20 | Most orders in one batch request (place or cancel); also the batch limit of the Trading WebSocket. A value that is not an integer or is less than 1 is reset to 20 |
proxy | str | None | None | Proxy URL |
user_agent | str | None | None | Optional User-Agent for HTTP requests and order payloads |
auto_reconnect | bool | True | Re-open a dropped streaming socket automatically; set False to turn it off |
otp_poll_interval_ms | int | 5000 | Time between Smart OTP approval polls (milliseconds) |
otp_poll_max_wait_ms | int | 60000 | Total time to keep polling for Smart OTP approval (milliseconds) |
log_level | str | "INFO" | Log level: DEBUG, INFO, WARNING, ERROR, CRITICAL |
An endpoint (api_url, streaming_url, trading_api_domain, trading_ws_domain) that is blank or None falls back to its default. repr(Config) masks api_secret and private_key.
Advanced Configuration
Debug logging
config = Config(
client_id="<CLIENT_ID>",
api_key="<API_KEY>",
api_secret="<API_SECRET>",
log_level="DEBUG",
)Custom retry & rate limit
config = Config(
client_id="<CLIENT_ID>",
api_key="<API_KEY>",
api_secret="<API_SECRET>",
max_retries=3,
retry_delay_ms=1000,
rate_limit_per_second=5,
)Custom Smart OTP Polling and Streaming
config = Config(
client_id="<CLIENT_ID>",
api_key="<API_KEY>",
api_secret="<API_SECRET>",
otp_poll_interval_ms=3000,
otp_poll_max_wait_ms=90000,
auto_reconnect=True,
)Batch Order
max_batch_orders defaults to 20. The API reference (trade-order-batch-place) states a server-side limit of 50 orders per request, while the SDK default is 20. Raising Config.max_batch_orders is the caller's decision; follow the limit that applies to your API Key. A batch larger than this value is rejected by the SDK immediately (no request is sent). See Batch Order.
Trading WebSocket
trading_api_domain and trading_ws_domain point at the trading REST service and the Trading WebSocket. The Trading WebSocket's own options (request_timeout_ms, signature_encoding, ping_interval_ms, ...) are not in Config; pass them to trading_ws(auth, **options). See Trading WebSocket. The Trading WebSocket needs private_key for state-changing commands.
Recommendations
- Keep key material (
api_key,api_secret,private_key) in a secret manager. - A missing
api_key/api_secretmakes the authentication flow fail. - A missing
private_keyaffects trading operations that require signing. - Configure
rate_limit_per_secondaccording to your system policy. - Only enable
log_level="DEBUG"in development. - Set
timeout_ms,max_retries,retry_delay_msaccording to actual load.