Go SDK

Tiger Open API Go SDK, providing market data queries, order placement, account management, and real-time push notifications.

Installation

go get github.com/tigerfintech/openapi-go-sdk

Requires Go 1.20 or higher.

Configuration

The SDK supports multiple configuration methods. Priority: Environment Variables > Code Settings (including config file) > Auto-discovered config file > Defaults.

The SDK automatically searches for a config file at these locations (no explicit path needed):

  1. Current directory: ./tiger_openapi_config.properties
  2. Home directory: ~/.tigeropen/tiger_openapi_config.properties

Method 1: Load from properties file (recommended)

// Specify a config file path
cfg, err := config.NewClientConfig(
	config.WithPropertiesFile("/path/to/tiger_openapi_config.properties"),
)

// Or pass no arguments — SDK auto-discovers the config file
cfg, err := config.NewClientConfig()

Configuration file format:

tiger_id=your_developer_id
private_key=your_rsa_private_key
account=your_trading_account
license=TBUS

Method 2: Set directly in code

cfg, err := config.NewClientConfig(
	config.WithTigerID("your_tiger_id"),
	config.WithPrivateKey("your_rsa_private_key"),
	config.WithAccount("your_trading_account"),
)

Method 3: Environment variables

export TIGEROPEN_TIGER_ID=your_developer_id
export TIGEROPEN_PRIVATE_KEY=your_rsa_private_key
export TIGEROPEN_ACCOUNT=your_trading_account
export TIGEROPEN_TOKEN=your_token  # Required for TBHK license

Configuration Options

OptionDescriptionRequiredDefault
tiger_idDeveloper IDYes-
private_keyRSA private key (PK1 and PK8 compatible)Yes-
accountTrading accountNo-
licenseLicense type (e.g. TBUS)No-
languageLanguage (zh_CN/zh_TW/en_US)Nozh_CN
timeoutRequest timeoutNo15s
tokenTBHK license tokenNo-

Auto-Detection

  • Device ID: Automatically detected from network interface MAC address
  • Dynamic domains: SDK fetches the latest server addresses from the domain garden (enabled by default)
  • Quote server: SDK resolves a dedicated quote server URL (LICENSE-QUOTE domain key)
  • Signature verification: Built-in Tiger public key for HTTP response signature verification

Quote Client

The SDK provides a dedicated quote HTTP client NewQuoteHttpClient that automatically uses the quote server URL:

cfg, _ := config.NewClientConfig()
quoteHttpClient := client.NewQuoteHttpClient(cfg)
qc := quote.NewQuoteClient(quoteHttpClient)

Requests and Responses

All responses are strongly typed

Every method returns a concrete struct (or slice/pointer) defined in the model package — you don't have to call json.Unmarshal yourself:

briefs, _ := qc.GetBrief(model.BriefRequest{Symbols: []string{"AAPL", "TSLA"}})
for _, b := range briefs {
    fmt.Printf("%s latestPrice=%.2f\n", b.Symbol, b.LatestPrice)
}

placed, _ := tc.PlaceOrder(order)
fmt.Println("order id:", placed.ID)

Common return types:

Data shapeReturn type
Multi-symbol quotes / positions / orders[]model.Brief / []model.Position / []model.Order
Single aggregate object*model.PrimeAsset / *model.CapitalDistribution / *model.PreviewResult
Place / modify / cancel order*model.PlaceOrderResult / *model.OrderIDResult

Request parameter style (Go idioms)

  • Few required parameters (≤3) — positional arguments: GetBrief(symbols) / GetKline(symbol, period) / GetCapitalFlow(symbol, market, period).
  • Many parameters or optional fields — Request struct: GetFinancialDaily(FinancialDailyRequest{...}) / GetFutureKline(FutureKlineRequest{...}) / MarketScanner(MarketScannerRequest{...}) / PlaceOrder(OrderRequest{...}).
  • Request struct json tags are snake_case to match the server wire format; response struct json tags are camelCase.