Python

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

ParameterTypeDefaultDescription
client_idstr""Client ID for authentication
api_keystr""API key from SSI
api_secretstr""API secret from SSI
private_keystr""Private key for signing trading orders
api_urlstr"https://api.ssi.com.vn"REST API URL (authentication and market data always use it)
streaming_urlstr"wss://stream.ssi.com.vn/ws/v3"WebSocket streaming URL
trading_api_domainstr"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_domainstr"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_msint60000Request timeout (milliseconds)
max_retriesint5Maximum retry attempts (only GET requests are retried)
retry_delay_msint2000Base delay between retries (exponential backoff, milliseconds). Streaming also uses it as the base for reconnect backoff
rate_limit_per_secondint10Request limit per second (0 = unlimited)
max_batch_ordersint20Most 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
proxystr | NoneNoneProxy URL
user_agentstr | NoneNoneOptional User-Agent for HTTP requests and order payloads
auto_reconnectboolTrueRe-open a dropped streaming socket automatically; set False to turn it off
otp_poll_interval_msint5000Time between Smart OTP approval polls (milliseconds)
otp_poll_max_wait_msint60000Total time to keep polling for Smart OTP approval (milliseconds)
log_levelstr"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_secret makes the authentication flow fail.
  • A missing private_key affects trading operations that require signing.
  • Configure rate_limit_per_second according to your system policy.
  • Only enable log_level="DEBUG" in development.
  • Set timeout_ms, max_retries, retry_delay_ms according to actual load.

On this page