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,APISecretfrom SSIPrivateKeyfor order signing- OTP for Trading/Stream authentication flows
Installation
go get github.com/SSI-Securities-Inc/ssi-sdk-go/v3Configuration
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- Create
Configwithssi.NewConfig(clientID). - Initialize
Authwithssi.NewAuth(config). - Call
auth.Authenticate(otp)— pass empty string""for market data only. - Initialize the needed client (
Data,Trading,Stream) withauth. - For
Stream, calls.Connect()before subscribing. - Use
defer auth.Close()anddefer 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,PrivateKeyor account numbers in source code. The examples above use placeholders (YOUR_...) and read the OTP from theSSI_OTPenvironment 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()anddefer s.Disconnect()for proper cleanup.