Market Subscriptions
For unsubscribe methods that accept symbols or indicators, passing nil sends an empty symbols field and clears the subject's entire local cache. A non-nil empty slice produces the same wire field but does not clear the local cache. Pass nil explicitly when unsubscribing and clearing all local records.
SubscribeQuote
SubscribeQuotePurpose
Creates a market data subscription on the connected client and records it locally.
Signature
func (c *PushClient) SubscribeQuote(symbols []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
symbols | []string | Yes | None | Instrument symbols; the SDK does not enforce a batch limit |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.SubscribeQuote([]string{"AAPL"}); err != nil {
log.Fatal(err)
}Callback data JSON example
Quote (BASIC):
{
"symbol": "AAPL",
"type": "BASIC",
"timestamp": "1684766012120",
"serverTimestamp": "1684766012129",
"avgPrice": 174.1721,
"latestPrice": 174.175,
"latestPriceTimestamp": "1684766011918",
"latestTime": "05-22 10:33:31 EDT",
"preClose": 175.16,
"volume": "12314802",
"amount": 2144365591.41,
"open": 173.98,
"high": 174.71,
"low": 173.45,
"marketStatus": "Trading",
"mi": {
"p": 174.175,
"a": 174.1721,
"t": "1684765980000",
"v": "57641",
"o": 174.21,
"h": 174.22,
"l": 174.14
}
}Best Bid/Offer (BBO):
{
"symbol": "AAPL",
"type": "BBO",
"timestamp": "1676992715509",
"askPrice": 149.96,
"askSize": "200",
"askTimestamp": "1676992715367",
"bidPrice": 149.94,
"bidSize": "700",
"bidTimestamp": "1676992715367"
}UnsubscribeQuote
UnsubscribeQuotePurpose
Cancels the market data subscription on the connected client and removes the local subscription record.
Signature
func (c *PushClient) UnsubscribeQuote(symbols []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
symbols | []string | Yes | None | Instrument symbols; the SDK does not enforce a batch limit |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.UnsubscribeQuote([]string{"AAPL"}); err != nil {
log.Fatal(err)
}SubscribeTick
SubscribeTickPurpose
Subscribes the connected client to tick events and records the subscription locally. Trade ticks are pushed every 200ms in snapshot mode, with the latest 50 records in each push.
Signature
func (c *PushClient) SubscribeTick(symbols []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
symbols | []string | Yes | None | Instrument symbols; the SDK does not enforce a batch limit |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.SubscribeTick([]string{"AAPL"}); err != nil {
log.Fatal(err)
}Callback data JSON example
{
"symbol": "AAPL",
"secType": "STK",
"quoteLevel": "usQuoteBasic",
"timestamp": 1676993925700,
"ticks": [
{
"sn": 116202,
"volume": 50,
"tickType": "*",
"price": 149.665,
"time": 1676993924289,
"cond": "US_REGULAR_SALE"
}
]
}In the default mode, OnTick receives push.PushTradeTick, whose Cond values are decoded by the SDK; see Trade Tick Conditions. When the client is created with WithUseFullTick(true), OnFullTick receives *pb.TickData with raw one-character conditions, and the same message is not also sent to OnTick.
UnsubscribeTick
UnsubscribeTickPurpose
Unsubscribes the connected client from tick events and removes the local subscription record.
Signature
func (c *PushClient) UnsubscribeTick(symbols []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
symbols | []string | Yes | None | Instrument symbols; the SDK does not enforce a batch limit |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.UnsubscribeTick([]string{"AAPL"}); err != nil {
log.Fatal(err)
}SubscribeDepth
SubscribeDepthPurpose
Subscribes the connected client to depth events and records the subscription locally. US market depth updates every 300ms, while Hong Kong market depth updates every 2s.
Signature
func (c *PushClient) SubscribeDepth(symbols []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
symbols | []string | Yes | None | Instrument symbols; the SDK does not enforce a batch limit |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.SubscribeDepth([]string{"AAPL"}); err != nil {
log.Fatal(err)
}Callback data JSON example
{
"symbol": "AAPL",
"timestamp": "1676993368405",
"ask": {
"price": [149.69, 149.70, 149.71],
"volume": ["100", "200", "185"]
},
"bid": {
"price": [149.68, 149.67, 149.66],
"volume": ["84", "100", "100"]
}
}UnsubscribeDepth
UnsubscribeDepthPurpose
Unsubscribes the connected client from depth events and removes the local subscription record.
Signature
func (c *PushClient) UnsubscribeDepth(symbols []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
symbols | []string | Yes | None | Instrument symbols; the SDK does not enforce a batch limit |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.UnsubscribeDepth([]string{"AAPL"}); err != nil {
log.Fatal(err)
}SubscribeOption
SubscribeOptionPurpose
Subscribes the connected client to option events and records the subscription locally.
Signature
func (c *PushClient) SubscribeOption(symbols []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
symbols | []string | Yes | None | Instrument symbols; the SDK does not enforce a batch limit |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.SubscribeOption([]string{"AAPL 260619C00200000"}); err != nil {
log.Fatal(err)
}Callback data JSON example
{
"symbol": "AAPL 20230317 150.0 CALL",
"type": "BASIC",
"timestamp": "1676994444927",
"latestPrice": 4.83,
"preClose": 6.21,
"volume": "3181",
"amount": 939117.01,
"open": 4.85,
"high": 5.6,
"low": 4.64,
"identifier": "AAPL 230317C00150000",
"openInt": "82677"
}UnsubscribeOption
UnsubscribeOptionPurpose
Unsubscribes the connected client from option events and removes the local subscription record.
Signature
func (c *PushClient) UnsubscribeOption(symbols []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
symbols | []string | Yes | None | Instrument symbols; the SDK does not enforce a batch limit |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.UnsubscribeOption([]string{"AAPL 260619C00200000"}); err != nil {
log.Fatal(err)
}SubscribeFuture
SubscribeFuturePurpose
Subscribes the connected client to future events and records the subscription locally.
Signature
func (c *PushClient) SubscribeFuture(symbols []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
symbols | []string | Yes | None | Instrument symbols; the SDK does not enforce a batch limit |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.SubscribeFuture([]string{"ES2609"}); err != nil {
log.Fatal(err)
}Callback data JSON example
{
"symbol": "ESmain",
"type": "BASIC",
"timestamp": "1684766824130",
"avgPrice": 4206.476,
"latestPrice": 4202.5,
"preClose": 4204.75,
"volume": "557570",
"open": 4189,
"high": 4221.75,
"low": 4186.5,
"marketStatus": "Trading",
"preSettlement": 4204.75,
"minTick": 0.25
}UnsubscribeFuture
UnsubscribeFuturePurpose
Unsubscribes the connected client from future events and removes the local subscription record.
Signature
func (c *PushClient) UnsubscribeFuture(symbols []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
symbols | []string | Yes | None | Instrument symbols; the SDK does not enforce a batch limit |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.UnsubscribeFuture([]string{"ES2609"}); err != nil {
log.Fatal(err)
}SubscribeKline
SubscribeKlinePurpose
Subscribes the connected client to kline events and records the subscription locally.
Signature
func (c *PushClient) SubscribeKline(symbols []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
symbols | []string | Yes | None | Instrument symbols; the SDK does not enforce a batch limit |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.SubscribeKline([]string{"AAPL"}); err != nil {
log.Fatal(err)
}Callback data JSON example
{
"symbol": "AAPL",
"time": "1712584560000",
"open": 168.9779,
"high": 169.0015,
"low": 168.9752,
"close": 169.0,
"avg": 168.778,
"volume": "3664",
"count": 114,
"amount": 617820.6508,
"serverTimestamp": "1712584569746"
}UnsubscribeKline
UnsubscribeKlinePurpose
Unsubscribes the connected client from kline events and removes the local subscription record.
Signature
func (c *PushClient) UnsubscribeKline(symbols []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
symbols | []string | Yes | None | Instrument symbols; the SDK does not enforce a batch limit |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.UnsubscribeKline([]string{"AAPL"}); err != nil {
log.Fatal(err)
}SubscribeStockTop
SubscribeStockTopPurpose
Subscribes the connected client to stock top events and records the subscription locally. The server runs the ranking push task every 30 seconds; ranking size is configurable and defaults to 10.
Signature
func (c *PushClient) SubscribeStockTop(market string, indicators []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
market | string | Yes | None | Supported values: US, HK |
indicators | []string | Yes | None | Supported values: changeRate, changeRate5Min, turnoverRate, amount, volume, amplitude; the SDK does not validate them |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.SubscribeStockTop("US", []string{"changeRate", "volume"}); err != nil {
log.Fatal(err)
}Callback data JSON example
{
"market": "US",
"timestamp": "1687271010482",
"topData": [
{
"targetName": "changeRate",
"item": [
{"symbol": "ICAD", "latestPrice": 1.63, "targetValue": 0.393162}
]
},
{
"targetName": "volume",
"item": [
{"symbol": "TSLA", "latestPrice": 263.21, "targetValue": 40190416}
]
}
]
}UnsubscribeStockTop
UnsubscribeStockTopPurpose
Unsubscribes the connected client from stock top events and removes the local subscription record.
Signature
func (c *PushClient) UnsubscribeStockTop(market string, indicators []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
market | string | Yes | None | Supported values: US, HK |
indicators | []string | Yes | None | Supported values: changeRate, changeRate5Min, turnoverRate, amount, volume, amplitude; the SDK does not validate them |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.UnsubscribeStockTop("US", []string{"changeRate", "volume"}); err != nil {
log.Fatal(err)
}SubscribeOptionTop
SubscribeOptionTopPurpose
Subscribes the connected client to option top events and records the subscription locally. The server runs the ranking push task every 30 seconds; ranking size is configurable and defaults to 10.
Signature
func (c *PushClient) SubscribeOptionTop(market string, indicators []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
market | string | Yes | None | Only US is supported |
indicators | []string | Yes | None | Supported values: bigOrder, volume, amount, openInt; the SDK does not validate them |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.SubscribeOptionTop("US", []string{"volume", "openInt"}); err != nil {
log.Fatal(err)
}Callback data JSON example
{
"market": "US",
"timestamp": "1687277160445",
"topData": [
{
"targetName": "volume",
"item": [
{
"symbol": "SPY",
"expiry": "20230620",
"strike": "435.0",
"right": "PUT",
"totalVolume": 212478
}
]
}
]
}UnsubscribeOptionTop
UnsubscribeOptionTopPurpose
Unsubscribes the connected client from option top events and removes the local subscription record.
Signature
func (c *PushClient) UnsubscribeOptionTop(market string, indicators []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
market | string | Yes | None | Only US is supported |
indicators | []string | Yes | None | Supported values: bigOrder, volume, amount, openInt; the SDK does not validate them |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.UnsubscribeOptionTop("US", []string{"volume", "openInt"}); err != nil {
log.Fatal(err)
}SubscribeCc
SubscribeCcPurpose
Subscribes the connected client to cc events and records the subscription locally.
Signature
func (c *PushClient) SubscribeCc(symbols []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
symbols | []string | Yes | None | Instrument symbols; the SDK does not enforce a batch limit |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.SubscribeCc([]string{"BTCUSD"}); err != nil {
log.Fatal(err)
}UnsubscribeCc
UnsubscribeCcPurpose
Unsubscribes the connected client from cc events and removes the local subscription record.
Signature
func (c *PushClient) UnsubscribeCc(symbols []string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
symbols | []string | Yes | None | Instrument symbols; the SDK does not enforce a batch limit |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.UnsubscribeCc([]string{"BTCUSD"}); err != nil {
log.Fatal(err)
}SubscribeMarket (HK whole-market quotes)
SubscribeMarket (HK whole-market quotes)Purpose
Subscribes to quote updates for the whole Hong Kong market and records the subscription locally. The server delivers ongoing per-symbol QuoteData through the ordinary OnQuote callback; this is neither a market-status subscription nor a one-time market snapshot.
Signature
func (c *PushClient) SubscribeMarket(market string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
market | string | Yes | None | Only HK is supported |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.SubscribeMarket("HK"); err != nil {
log.Fatal(err)
}UnsubscribeMarket (HK whole-market quotes)
UnsubscribeMarket (HK whole-market quotes)Purpose
Unsubscribes from whole-market Hong Kong quote updates and removes the local subscription record.
Signature
func (c *PushClient) UnsubscribeMarket(market string) errorCall Connect successfully before subscribing or unsubscribing. Access depends on instrument and data type.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
market | string | Yes | None | Only HK is supported |
Returns
error; nil means the message was written to the current connection.
Invocation example
if err := pc.UnsubscribeMarket("HK"); err != nil {
log.Fatal(err)
}Updated about 1 month ago
