Go

Overview

Overview of SSI FastConnect Go SDK — REST API and WebSocket streaming

Go SDK for SSI securities trading platform. Supports REST API and WebSocket streaming.

Requirements: Go 1.22+

Version: 3.3.2 (ssisdk.Version)

Source code: github.com/SSI-Securities-Inc/ssi-sdk-go

Installation

go get github.com/SSI-Securities-Inc/ssi-sdk-go/v3

Client Architecture

The SDK uses a modular architecture with 4 specialized clients:

ClientDescriptionRequires
AuthAuthentication & token managementConfig
DataMarket data (OHLC, indexes, securities)Auth (no OTP needed)
TradingTrading + portfolio + accountAuth (OTP required)
StreamRealtime streaming via WebSocketAuth (OTP required)

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.TokenManagerAuthentication, OTP, token refresh
DataMarketDataServicedata.MarketDataOHLC, indexes, securities, master data, corporate actions
TradingTradingServicet.TradingPlace/modify/cancel orders, batch place/cancel, max buy/sell, conditional orders (FCO)
TradingAccountServicet.AccountAccount information
TradingPortfolioServicet.PortfolioBalances, positions, order book, PPMMR
StreamStreamingServices.StreamingSubscribe/unsubscribe realtime data (symbols, indexes, session flags) and order events

Besides these 4 clients, the tradingws package has a Trading WebSocket client for placing orders and querying over WebSocket. It sits outside the facades, see Trading WebSocket.

Examples in these docs use placeholders (YOUR_...) and read the OTP from an environment variable. Never hard-code OTPs, keys or account numbers in source code.

Quick Start

Market data only (no OTP needed)

package main

import (
    "fmt"
    "log"

    "github.com/SSI-Securities-Inc/ssi-sdk-go/v3/ssi"
)

func main() {
    config := ssi.NewConfig("YOUR_CLIENT_ID")
    config.APIKey    = "YOUR_API_KEY"
    config.APISecret = "YOUR_API_SECRET"

    auth := ssi.NewAuth(config)
    defer auth.Close()

    if _, err := auth.Authenticate(""); err != nil {
        log.Fatal(err)
    }

    data := ssi.NewData(auth)
    ohlc, err := data.MarketData.GetOHLC1Minute("SSI")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(ohlc)
}

Trading (OTP required)

package main

import (
    "fmt"
    "log"
    "os"

    "github.com/SSI-Securities-Inc/ssi-sdk-go/v3/ssi"
    "github.com/SSI-Securities-Inc/ssi-sdk-go/v3/trading"
)

func main() {
    config := ssi.NewConfig("YOUR_CLIENT_ID")
    config.APIKey     = "YOUR_API_KEY"
    config.APISecret  = "YOUR_API_SECRET"
    config.PrivateKey = "YOUR_PRIVATE_KEY"

    auth := ssi.NewAuth(config)
    defer auth.Close()

    if _, err := auth.Authenticate(os.Getenv("SSI_OTP")); err != nil { // YOUR_OTP
        log.Fatal(err)
    }

    t := ssi.NewTrading(auth)

    accounts, err := t.Account.GetAccountInfo()
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(accounts)

    // This is a real order: only run it on an environment and account you are allowed to trade on.
    result, err := t.Trading.PlaceLimitOrder("YOUR_ACCOUNT_NO", "SSI", trading.OrderSideBuy, 100, 66000)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(result)
}

Realtime streaming (OTP required)

package main

import (
    "fmt"
    "log"
    "os"

    "github.com/SSI-Securities-Inc/ssi-sdk-go/v3/ssi"
    "github.com/SSI-Securities-Inc/ssi-sdk-go/v3/stream"
)

func main() {
    config := ssi.NewConfig("YOUR_CLIENT_ID")
    config.APIKey     = "YOUR_API_KEY"
    config.APISecret  = "YOUR_API_SECRET"
    config.PrivateKey = "YOUR_PRIVATE_KEY"

    auth := ssi.NewAuth(config)
    defer auth.Close()

    if _, err := auth.Authenticate(os.Getenv("SSI_OTP")); err != nil { // YOUR_OTP
        log.Fatal(err)
    }

    s := ssi.NewStream(auth)
    defer s.Disconnect()

    s.Streaming.SetOnData(func(msg interface{}) {
        switch m := msg.(type) {
        case *stream.TradeMessage:
            fmt.Printf("[TRADE] %s | %.0f | %d\n", m.Symbol, m.Price, m.Quantity)
        }
    })

    if err := s.Connect(); err != nil {
        log.Fatal(err)
    }

    s.Streaming.SubscribeSymbolTrade([]string{"SSI"}, nil)
    s.Wait(nil)
}

Use Case Mapping

Use caseClientAuthentication
Market data (OHLC, indexes, securities)DataNo OTP needed
Place/modify/cancel orders, account, portfolioTradingOTP required
Realtime WebSocket streamingStreamOTP required
Orders / queries over WebSockettradingws.TradingWSOTP required

Documentation Navigation

  • Installation & Configuration: environment, packages, Config.
  • Client Classes: Auth, Data, Trading, Stream — initialization and usage.
  • Service Classes: detailed API methods for each service, including batch orders, index streaming and the Trading WebSocket.
  • Configuration: full Config parameter reference.
  • Error Handling: error types and handling patterns.
  • Enums: constants like OrderSide, OrderType, Board, ...
  • Models: response data models and streaming message types.

On this page