Overview
Overview of SSI FastConnect Python SDK 3.3.2 — REST API and WebSocket streaming
Python SDK for SSI securities trading platform. Supports REST API and WebSocket streaming, both synchronous (sync) and asynchronous (async). This documentation covers version 3.3.2.
Requirements: Python 3.10+
Installation
pip install ssi-sdkClient Architecture
The SDK uses a modular architecture with 4 specialized clients:
| Client | Async | Description | Requires |
|---|---|---|---|
Auth | AsyncAuth | Authentication & token management | Config |
Data | AsyncData | Market data (OHLC, indexes, securities) | Auth (no OTP needed) |
Trading | AsyncTrading | Trading + portfolio + account | Auth (OTP required) |
Stream | AsyncStream | Realtime streaming via WebSocket | Auth (OTP required) |
Besides these 4 clients, the SDK has a Trading WebSocket, created with the trading_ws(auth) function (import from ssi_sdk). See Client Classes.
Initialization flow:
Config → Auth → authenticate(otp=...) → Data / Trading / StreamAuth is the root client — manages REST client and tokens. Data, Trading, and Stream all receive Auth as a parameter and share the same HTTP connection.
Services provided by each client:
| Client | Service | Access | Description |
|---|---|---|---|
Auth | TokenManager | auth.token_manager | Authentication, OTP, Smart OTP, token refresh |
Data | MarketDataService | data.market_data | OHLC, indexes, securities, securities summary, master data, corporate actions |
Trading | TradingService | trading.trading | Place/modify/cancel orders, batch orders, max buy/sell, conditional orders (FCO) |
Trading | AccountService | trading.account | Account information |
Trading | PortfolioService | trading.portfolio | Balances, positions, order book, PPMMR |
Stream | StreamingService | stream.streaming | Subscribe/unsubscribe realtime data, including real-time index data |
Quick Start
Replace the <...> values with your own. Never put real credentials or OTPs in source code; read them from environment variables or a secret manager.
Async (recommended)
import asyncio
from ssi_sdk import AsyncAuth, AsyncData, AsyncTrading, AsyncStream, Config
async def main():
config = Config(
client_id="<CLIENT_ID>",
api_key="<API_KEY>",
api_secret="<API_SECRET>",
private_key="<PRIVATE_KEY_CONTENT>",
)
async with AsyncAuth(config) as auth:
await auth.authenticate(otp="<OTP>")
# Market data
async with AsyncData(auth) as data:
ohlc = await data.market_data.get_ohlc_1minute("SSI")
print(ohlc)
# Trading & portfolio
async with AsyncTrading(auth) as trading:
accounts = await trading.account.get_account_info()
print(accounts)
# Streaming
async with AsyncStream(auth) as stream:
await stream.streaming.connect()
stream.streaming.on_data = lambda msg: print(msg)
await stream.streaming.subscribe_symbol_trade(["SSI"])
await stream.streaming.wait()
asyncio.run(main())Sync
from ssi_sdk import Auth, Data, 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)Market data only (no OTP needed)
from ssi_sdk import Auth, Data, Config
with Auth(config) as auth:
auth.authenticate() # No OTP needed for market data
with Data(auth) as data:
ohlc = data.market_data.get_ohlc_1minute("SSI")Use Case Mapping
| Use case | Recommended Client | Authentication |
|---|---|---|
| Market data (OHLC, indexes, securities) | Data / AsyncData | No OTP needed |
| Place/modify/cancel orders, batch orders, account, portfolio | Trading / AsyncTrading | OTP required |
| Realtime WebSocket streaming (including real-time index data) | Stream / AsyncStream | OTP required |
| Place orders over WebSocket | trading_ws(auth) | OTP and private_key required |
Documentation Navigation
- Installation & Configuration: environment, packages,
Config. - Client Classes:
Auth,Data,Trading,Streamand the Trading WebSocket — initialization and usage. - Service Classes: detailed API methods for each service, including Batch Order (section 5.4), real-time index data (section 6.7) and the Trading WebSocket (section 7).
- Configuration: full
Configparameter reference (durations in milliseconds,_mssuffix). - Error Handling: exception hierarchy, Smart OTP,
ServerErrorCode. - Enums & Constants (the
transport-classespage):OrderSide,OrderType,Board,from_value, ... - Models (the
utilitiespage): response data models, streaming messages and constants.