Contracts

Contract

Purpose

Retrieves matching contracts and unwraps the response item list. The client unwraps the server items envelope.

Signature

func (c *TradeClient) Contract(symbol, secType string) ([]model.Contract, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

ParameterTypeRequiredSDK defaultConstraints
symbolstringYesNoneInstrument or underlying symbol
secTypestringYesNoneSecurity type; see the SecurityType enum

Returns

([]model.Contract, error). Key fields from model.Contract:

FieldTypeDescription
ContractIdint64Contract ID
SymbolstringSymbol code
SecTypestringSecurity type
CurrencystringCurrency
ExchangestringExchange
ExpirystringExpiry date
Strikefloat64Strike price
RightstringOption right (PUT/CALL)
Multiplierfloat64Contract multiplier
IdentifierstringIdentifier
NamestringName
MarketstringMarket
TradeableboolWhether tradeable
Conidint64Internal contract ID

Invocation example

result, err := tc.Contract("AAPL", "STK")
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
{
  "symbol": "AAPL",
  "name": "Apple Inc",
  "secType": "STK",
  "exchange": "NASDAQ",
  "market": "US",
  "currency": "USD",
  "lotSize": 1,
  "minTick": 0.01,
  "contractId": 756733,
  "status": "NORMAL"
}

Contract3

Purpose

Retrieves one contract through API version 3.0. The client uses an explicit API version.

Signature

func (c *TradeClient) Contract3(symbol, secType string) (*model.Contract, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

ParameterTypeRequiredSDK defaultConstraints
symbolstringYesNoneInstrument or underlying symbol
secTypestringYesNoneSecurity type; see the SecurityType enum

Returns

(*model.Contract, error). Key fields from model.Contract:

FieldTypeDescription
ContractIdint64Contract ID
SymbolstringSymbol code
SecTypestringSecurity type
CurrencystringCurrency
ExchangestringExchange
ExpirystringExpiry date
Strikefloat64Strike price
RightstringOption right (PUT/CALL)
Multiplierfloat64Contract multiplier
IdentifierstringIdentifier
NamestringName
MarketstringMarket
TradeableboolWhether tradeable
Conidint64Internal contract ID

Invocation example

result, err := tc.Contract3("AAPL", "STK")
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
{
  "symbol": "AAPL",
  "name": "Apple Inc",
  "secType": "STK",
  "exchange": "NASDAQ",
  "market": "US",
  "currency": "USD",
  "lotSize": 1,
  "minTick": 0.01,
  "contractId": 756733,
  "status": "NORMAL",
  "shortableCount": 1500000,
  "marginable": true
}

Contracts

Purpose

Retrieves contracts for multiple symbols. The client unwraps the server items envelope.

Signature

func (c *TradeClient) Contracts(symbols []string, secType string) ([]model.Contract, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

ParameterTypeRequiredSDK defaultConstraints
symbols[]stringYesNoneInstrument symbols; the SDK does not enforce a batch limit
secTypestringYesNoneSecurity type; see the SecurityType enum

Returns

([]model.Contract, error). Key fields from model.Contract:

FieldTypeDescription
ContractIdint64Contract ID
SymbolstringSymbol code
SecTypestringSecurity type
CurrencystringCurrency
ExchangestringExchange
ExpirystringExpiry date
Strikefloat64Strike price
RightstringOption right (PUT/CALL)
Multiplierfloat64Contract multiplier
IdentifierstringIdentifier
NamestringName
MarketstringMarket
TradeableboolWhether tradeable
Conidint64Internal contract ID

Invocation example

result, err := tc.Contracts([]string{"AAPL"}, "STK")
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
[
  {
    "symbol": "AAPL",
    "name": "Apple Inc",
    "secType": "STK",
    "exchange": "NASDAQ",
    "market": "US",
    "currency": "USD",
    "lotSize": 1,
    "minTick": 0.01,
    "contractId": 756733,
    "status": "NORMAL"
  },
  {
    "symbol": "MSFT",
    "name": "Microsoft Corp",
    "secType": "STK",
    "exchange": "NASDAQ",
    "market": "US",
    "currency": "USD",
    "lotSize": 1,
    "minTick": 0.01,
    "contractId": 756734,
    "status": "NORMAL"
  }
]

QuoteContract

Purpose

Lists option, warrant, or callable bull/bear contracts for one underlying and expiry. The client unwraps the server items envelope.

Signature

func (c *TradeClient) QuoteContract(symbol, secType, expiry string) ([]model.Contract, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

ParameterTypeRequiredSDK defaultConstraints
symbolstringYesNoneInstrument or underlying symbol
secTypestringYesNoneSecurity type; see the SecurityType enum
expirystringYesNoneExpiry; format: YYYYMMDD

Returns

([]model.Contract, error). Key fields from model.Contract:

FieldTypeDescription
ContractIdint64Contract ID
SymbolstringSymbol code
SecTypestringSecurity type
CurrencystringCurrency
ExchangestringExchange
ExpirystringExpiry date
Strikefloat64Strike price
RightstringOption right (PUT/CALL)
Multiplierfloat64Contract multiplier
IdentifierstringIdentifier
NamestringName
MarketstringMarket
TradeableboolWhether tradeable
Conidint64Internal contract ID

Invocation example

result, err := tc.QuoteContract("AAPL", "OPT", "20260619")
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
{
  "symbol": "AAPL",
  "name": "Apple Inc",
  "secType": "STK",
  "exchange": "NASDAQ",
  "market": "US",
  "currency": "USD",
  "lotSize": 1,
  "minTick": 0.01
}

DerivativeContracts

Purpose

Lists derivative contracts using an account-aware request model. The client unwraps the server items envelope, and fills an empty account field from the client default.

Signature

func (c *TradeClient) DerivativeContracts(req model.DerivativeContractsRequest) ([]model.Contract, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

model.DerivativeContractsRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
SecTypestringNoOmitted if emptyAllowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

([]model.Contract, error). Key fields from model.Contract:

FieldTypeDescription
ContractIdint64Contract ID
SymbolstringSymbol code
SecTypestringSecurity type
CurrencystringCurrency
ExchangestringExchange
ExpirystringExpiry date
Strikefloat64Strike price
RightstringOption right (PUT/CALL)
Multiplierfloat64Contract multiplier
IdentifierstringIdentifier
NamestringName
MarketstringMarket
TradeableboolWhether tradeable
Conidint64Internal contract ID

Invocation example

result, err := tc.DerivativeContracts(model.DerivativeContractsRequest{
	Account: "U123456",
	Symbols: []string{"AAPL"},
	SecType: "STK",
	Expiry: "20260619",
	Lang: "en_US",
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
[
  {
    "symbol": "AAPL  250815C00300000",
    "name": "AAPL 15AUG25 300 C",
    "secType": "OPT",
    "exchange": "CBOE",
    "market": "US",
    "currency": "USD",
    "expiry": "2025-08-15",
    "strike": 300.0,
    "right": "CALL",
    "multiplier": 100.0,
    "underlying": "AAPL"
  }
]


Did this page help you?