Go

Installation & Setup

Installation and setup guide for Go SDK

Environment Requirements

  • Go >=1.22
  • Network access to REST API and WebSocket endpoints
  • ClientID, APIKey, APISecret from SSI
  • PrivateKey for order signing
  • OTP for Trading/Stream authentication flows

Installation

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

Configuration

Create a Config object with your credentials:

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

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

Initialization Flow

Config → Auth → Authenticate(otp) → Data / Trading / Stream
  1. Create Config with ssi.NewConfig(clientID).
  2. Initialize Auth with ssi.NewAuth(config).
  3. Call auth.Authenticate(otp) — pass empty string "" for market data only.
  4. Initialize the needed client (Data, Trading, Stream) with auth.
  5. For Stream, call s.Connect() before subscribing.
  6. Use defer auth.Close() and defer s.Disconnect() for cleanup.

Setup Examples by Use Case

Market data only (no OTP needed)

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

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")

Trading (OTP required)

import (
    "os"

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

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()

Realtime streaming (OTP required)

import (
    "os"

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

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{}) {
    fmt.Println(msg)
})

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

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

Accounts with Smart OTP enabled can approve in the app instead of entering a code, see Approve OTP (Smart OTP push-approval). The Trading WebSocket client lives in the tradingws package, see Trading WebSocket.

Tips

  • Never hard-code the OTP, APIKey, APISecret, PrivateKey or account numbers in source code. The examples above use placeholders (YOUR_...) and read the OTP from the SSI_OTP environment variable.
  • Authenticate before calling token-protected APIs.
  • For streaming, call s.Connect() after successful authentication.
  • Use config.LogLevel = "DEBUG" for troubleshooting.
  • Keep credentials (APIKey, APISecret, PrivateKey) in environment variables or a secret manager.
  • Always use defer auth.Close() and defer s.Disconnect() for proper cleanup.

On this page