Installation & Setup
Installation and setup guide for Python SDK 3.3.2
Environment Requirements
- Python
>=3.10 - Network access to REST API and WebSocket endpoints
client_id,api_key,api_secretfrom SSIprivate_keyfor order signing- OTP for Trading/Stream authentication flows (or Smart OTP approval in the app)
Installation
pip install ssi-sdkThis documentation covers version 3.3.2.
Upgrading from 3.3.1 or earlier
3.3.2 has one breaking change: the Trading WebSocket is no longer experimental, and the ssi_sdk.experimental module was removed with no alias. The old import raises ModuleNotFoundError. Import from the package root instead:
# before (3.3.1 and earlier)
from ssi_sdk.experimental import trading_ws, async_trading_ws, TradingWSClient, AsyncTradingWSClient, TradingWSError
# after (3.3.2)
from ssi_sdk import trading_ws, async_trading_ws, TradingWSClient, AsyncTradingWSClient, TradingWSErrorNames, signatures and defaults are unchanged. 3.3.2 also adds the corporate actions methods in MarketData, see Services, section 3.7.
Configuration
Replace the <...> values with your own; never put credentials in source code.
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>",
)Or pass config as keyword arguments directly to Auth:
from ssi_sdk import Auth
auth = Auth(
client_id="<CLIENT_ID>",
api_key="<API_KEY>",
api_secret="<API_SECRET>",
private_key="<PRIVATE_KEY_CONTENT>",
timeout_ms=60000,
log_level="DEBUG",
)Every duration in Config is in milliseconds (_ms suffix, for example timeout_ms, retry_delay_ms). Full list: Configuration.
Initialization Flow
Config → Auth → authenticate(otp=...) → Data / Trading / Stream- Create
Configwith credentials. - Initialize
Auth/AsyncAuthwithConfig. - Call
auth.authenticate(otp=...)— OTP is optional for market data only. - Initialize the needed client (
Data,Trading,Stream) withauth. - For
Stream, callstream.streaming.connect()before subscribing.
For accounts that use Smart OTP (approve in the app), see Client Classes: Smart OTP.
Setup Examples by Use Case
Market data only (no OTP needed)
from ssi_sdk import Auth, Data, Config
config = Config(
client_id="<CLIENT_ID>",
api_key="<API_KEY>",
api_secret="<API_SECRET>",
)
with Auth(config) as auth:
auth.authenticate() # No OTP needed
with Data(auth) as data:
ohlc = data.market_data.get_ohlc_1minute("SSI")
print(ohlc)Trading (OTP required)
from ssi_sdk import Auth, Trading, Config
config = Config(
client_id="<CLIENT_ID>",
api_key="<API_KEY>",
api_secret="<API_SECRET>",
private_key="<PRIVATE_KEY_CONTENT>",
)
with Auth(config) as auth:
auth.authenticate(otp="<OTP>")
with Trading(auth) as trading:
accounts = trading.account.get_account_info()
print(accounts)Realtime streaming (OTP required)
from ssi_sdk import Auth, Stream, Config
config = Config(
client_id="<CLIENT_ID>",
api_key="<API_KEY>",
api_secret="<API_SECRET>",
private_key="<PRIVATE_KEY_CONTENT>",
)
with Auth(config) as auth:
auth.authenticate(otp="<OTP>")
with Stream(auth) as stream:
stream.streaming.connect()
stream.streaming.on_data = lambda msg: print(msg)
stream.streaming.subscribe_symbol_trade(["SSI"])
stream.streaming.wait()Tips
- Authenticate before calling token-protected APIs.
- For streaming, call
connect()after successful authentication. - Use
log_level="DEBUG"for troubleshooting, and only in development. - Keep credentials (
api_key,api_secret,private_key) in a secret manager; do not print or log tokens and OTPs.