Python

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-sdk

Client Architecture

The SDK uses a modular architecture with 4 specialized clients:

ClientAsyncDescriptionRequires
AuthAsyncAuthAuthentication & token managementConfig
DataAsyncDataMarket data (OHLC, indexes, securities)Auth (no OTP needed)
TradingAsyncTradingTrading + portfolio + accountAuth (OTP required)
StreamAsyncStreamRealtime streaming via WebSocketAuth (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 / Stream

Auth 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:

ClientServiceAccessDescription
AuthTokenManagerauth.token_managerAuthentication, OTP, Smart OTP, token refresh
DataMarketDataServicedata.market_dataOHLC, indexes, securities, securities summary, master data, corporate actions
TradingTradingServicetrading.tradingPlace/modify/cancel orders, batch orders, max buy/sell, conditional orders (FCO)
TradingAccountServicetrading.accountAccount information
TradingPortfolioServicetrading.portfolioBalances, positions, order book, PPMMR
StreamStreamingServicestream.streamingSubscribe/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.

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 caseRecommended ClientAuthentication
Market data (OHLC, indexes, securities)Data / AsyncDataNo OTP needed
Place/modify/cancel orders, batch orders, account, portfolioTrading / AsyncTradingOTP required
Realtime WebSocket streaming (including real-time index data)Stream / AsyncStreamOTP required
Place orders over WebSockettrading_ws(auth)OTP and private_key required

Documentation Navigation

  • Installation & Configuration: environment, packages, Config.
  • Client Classes: Auth, Data, Trading, Stream and 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 Config parameter reference (durations in milliseconds, _ms suffix).
  • Error Handling: exception hierarchy, Smart OTP, ServerErrorCode.
  • Enums & Constants (the transport-classes page): OrderSide, OrderType, Board, from_value, ...
  • Models (the utilities page): response data models, streaming messages and constants.

On this page