Callbacks

IApiComposeCallback extends ISubscribeApiCallback; an implementation must provide every signature below. Quote, account, and subscription callbacks receive the model declared in their signature; connection and heartbeat callbacks receive primitive parameters or no parameters.

using TigerOpenAPI.Push;
using TigerOpenAPI.Push.Model;
using TigerOpenAPI.Quote.Pb;

sealed class PushCallback : IApiComposeCallback
{
    public void OrderStatusChange(OrderStatusData data) { }
    public void OrderTransactionChange(OrderTransactionData data) { }
    public void PositionChange(PositionData data) { }
    public void AssetChange(AssetData data) { }
    public void TradeTickChange(TradeTick data) { }
    public void FullTickChange(TickData data) { }
    public void QuoteChange(QuoteBasicData data) { }
    public void QuoteAskBidChange(QuoteBBOData data) { }
    public void OptionChange(QuoteBasicData data) { }
    public void OptionAskBidChange(QuoteBBOData data) { }
    public void FutureChange(QuoteBasicData data) { }
    public void FutureAskBidChange(QuoteBBOData data) { }
    public void DepthQuoteChange(QuoteDepthData data) { }
    public void KlineChange(KlineData data) { }
    public void StockTopPush(StockTopData data) { }
    public void OptionTopPush(OptionTopData data) { }
    public void SubscribeEnd(int id, string subject, string result) { }
    public void CancelSubscribeEnd(int id, string subject, string result) { }
    public void GetSubscribedSymbolEnd(SubscribedSymbol subscribedSymbol) { }
    public void Error(string errorMsg) { }
    public void Error(int id, int errorCode, string errorMsg) { }
    public void ConnectionClosed() { }
    public void ConnectionKickout(int errorCode, string errorMsg) { }
    public void ConnectionAck() { }
    public void ConnectionAck(int serverSendInterval, int serverReceiveInterval) { }
    public void HearBeat(string heartBeatContent) { }
    public void ServerHeartBeatTimeOut(string channelId) { }
}

Quote/option/future basic and BBO updates use separate callbacks. With UseFullTick=true, ticks go to FullTickChange(TickData); otherwise they go to TradeTickChange(TradeTick). Avoid blocking the callback thread.

Each callback receives the concrete data object shown in its signature; there is no common outer object. A subscribe or cancel command's uint return value correlates with the id in SubscribeEnd or CancelSubscribeEnd. Their result value is JSON; read its code field and require code == 0 for business success. GetSubscribedSymbolEnd receives only SubscribedSymbol and has no request ID, so the value returned by GetSubscribedSymbols() cannot be correlated with that callback.

Callback Payload Fields

The tables below list the available callback-object fields. For a field marked “Optional,” first check the corresponding Has... property; other value-type fields use their CLR default when absent.

Connection and Heartbeat Callbacks

CallbackParameterTypeDescription
ConnectionClosed()None-The connection closed; no payload
ConnectionKickout(int errorCode, string errorMsg)errorCode / errorMsgint / stringError code and message when a new connection for the same Tiger ID replaces this connection
ConnectionAck()None-Connection acknowledgement received; no payload
ConnectionAck(int serverSendInterval, int serverReceiveInterval)serverSendInterval / serverReceiveIntervalint / intSend and receive intervals the SDK uses to configure connection heartbeats, both in milliseconds
HearBeat(string heartBeatContent)heartBeatContentstringServer heartbeat content
ServerHeartBeatTimeOut(string channelId)channelIdstringIdentifier of the connection whose heartbeat timed out

AssetChange(AssetData)

FieldC# typeDescription
AccountstringAccount
CurrencystringCurrency
SegTypestringSecurities category
AvailableFunds / ExcessLiquidity / NetLiquidation / EquityWithLoan / BuyingPower / CashBalance / GrossPositionValue / InitMarginReq / MaintMarginReqdoubleFunds, liquidity, net liquidation, equity, buying power, cash, position value, and margin fields
TimestampulongTimestamp

PositionChange(PositionData)

FieldC# typeDescription
Account / Symbol / Expiry / Strike / Right / Identifier / Market / Currency / SegType / SecType / NamestringAccount, contract, market, and symbol text fields; Expiry, Strike, and Right apply to options
MultiplieruintContract multiplier
PositionlongTotal position
PositionScaleintPosition scale
AverageCost / LatestPrice / MarketValue / UnrealizedPnldoubleCost, latest price, market value, and unrealized PnL
TimestampulongTimestamp
SaleablelongOptional; saleable quantity for China A-share stocks, tested with HasSaleable

OrderStatusChange(OrderStatusData)

FieldC# typeDescription
IdlongOrder ID
Account / Symbol / Expiry / Strike / Right / Identifier / Action / Market / Currency / SegType / SecType / OrderType / Status / ReplaceStatus / CancelStatus / Name / Source / ErrorMsg / AttrDesc / UserMark / TimeInForcestringOrder, contract, status, and text fields
MultiplieruintContract multiplier
IsLong / OutsideRth / CanModify / CanCancel / LiquidationboolLong, extended-hours, modifiable, cancellable, and liquidation flags
TotalQuantity / FilledQuantitylongOrdered and filled quantity
TotalQuantityScale / FilledQuantityScaleintQuantity scale
AvgFillPrice / LimitPrice / StopPrice / RealizedPnl / TotalCashAmount / FilledCashAmount / GstdoublePrices, realized PnL, cash amounts, and GST
CommissionAndFeefloatCommission and fee
OpenTime / Timestamp / UpdateTime / LatestTimeulongOrder-open, push, order-info-update, and status-update timestamps
AttrListRepeatedField<string>Order attribute list

OrderTransactionChange(OrderTransactionData)

FieldC# typeDescription
Id / OrderIdlongTransaction ID / order ID
Account / Symbol / Identifier / Action / Market / Currency / SegType / SecTypestringAccount, contract, and market text fields
MultiplieruintContract multiplier
FilledPricedoubleFill price
FilledQuantitylongFilled quantity
CreateTime / UpdateTime / TransactTime / TimestampulongCreation, update, transaction, and push timestamps

QuoteChange / OptionChange / FutureChange (QuoteBasicData)

FieldC# typeDescription
SymbolstringSymbol
TypeSocketCommon.Types.QuoteTypeQuote type
TimestampulongPush timestamp
ServerTimestampulongOptional; server timestamp, tested with HasServerTimestamp
AvgPrice / LatestPrice / PreClose / Amount / Open / High / LowdoubleOptional; basic-quote prices and turnover
LatestPriceTimestampulongOptional; latest-price timestamp
LatestTime / HourTradingTag / MarketStatusstringOptional; time, extended-hours tag, and market status
VolumelongOptional; volume
IdentifierstringOptional; option identifier
OpenIntlongOptional; option open interest
TradeTimeulongOptional; latest futures trade time
PreSettlementdoubleOptional; prior futures settlement
MinTickfloatOptional; futures minimum tick
MiQuoteData.Types.MinuteOptional minute data; test for a null value before reading its fields below

Mi (QuoteData.Types.Minute)

FieldC# typeDescription
PdoubleMinute latest price
AdoubleMinute average price
TulongMinute timestamp
VlongMinute volume
O / H / LdoubleOptional minute open, high, and low, checked with HasO, HasH, and HasL respectively

QuoteAskBidChange / OptionAskBidChange / FutureAskBidChange (QuoteBBOData)

FieldC# typeDescription
SymbolstringSymbol
TypeSocketCommon.Types.QuoteTypeQuote type
TimestampulongPush timestamp
AskPrice / BidPricedoubleBest ask / bid price
AskSize / BidSizelongBest ask / bid size
AskTimestamp / BidTimestampulongOptional; best ask / bid timestamp, tested with the corresponding Has... property

TradeTickChange(TradeTick)

FieldC# typeDescription
Symbol / QuoteLevelstringSymbol / quote level
SecTypeSecTypeSecurity type
TimestamplongPush timestamp
TicksList<Tick>Tick list
Ticks[].Sn / Ticks[].Volume / Ticks[].TimelongSequence, volume, and trade time
Ticks[].PricedoubleTrade price
Ticks[].TickType / Cond / PartCode / PartNamestringSide, decoded condition, participant code, and participant name

FullTickChange(TickData)

FieldC# typeDescription
Symbol / SourcestringSymbol / data source
TimestamplongPush timestamp
TicksRepeatedField<TickData.Types.Tick>Full-tick list
Ticks[].Sn / TimelongSequence / trade time
Ticks[].PricefloatTrade price
Ticks[].VolumeintTrade volume
Ticks[].Type / Cond / PartCodestringSide, raw condition code, and participant code

DepthQuoteChange(QuoteDepthData)

FieldC# typeDescription
SymbolstringSymbol
TimestampulongPush timestamp
Ask / BidQuoteDepthData.Types.OrderBookAsk / bid book
Ask.Price / Bid.PriceRepeatedField<double>Prices by level
Ask.Volume / Bid.Volume / Ask.Time / Bid.TimeRepeatedField<long>Sizes and option-exchange times by level
Ask.OrderCount / Bid.OrderCountRepeatedField<uint>Order counts by level
Ask.Exchange / Bid.ExchangeRepeatedField<string>Option exchanges

KlineChange(KlineData)

FieldC# typeDescription
Time / VolumelongBar time / volume
Open / High / Low / Close / AvgfloatPrice fields
CountintTrade count
SymbolstringSymbol
AmountdoubleTurnover
ServerTimestampulongOptional; server timestamp, tested with HasServerTimestamp

StockTopPush(StockTopData)

FieldC# typeDescription
MarketstringMarket
TimestamplongPush timestamp
TopDataRepeatedField<StockTopData.Types.TopData>Ranking list
TopData[].TargetNamestringIndicator name
TopData[].ItemRepeatedField<StockTopData.Types.StockItem>Indicator items
TopData[].Item[].SymbolstringSymbol
TopData[].Item[].LatestPricedoubleLatest price
TopData[].Item[].TargetValuedoubleIndicator value

OptionTopPush(OptionTopData)

FieldC# typeDescription
MarketstringMarket
TimestamplongPush timestamp
TopDataRepeatedField<OptionTopData.Types.TopData>Ranking list
TopData[].TargetNamestringIndicator name
TopData[].BigOrderRepeatedField<OptionTopData.Types.BigOrder>Large-order list
TopData[].ItemRepeatedField<OptionTopData.Types.OptionItem>Indicator items
TopData[].BigOrder[].Symbol / Expiry / Strike / Right / DirstringLarge-order contract and side
TopData[].BigOrder[].VolumedoubleLarge-order volume
TopData[].BigOrder[].PricedoubleLarge-order price
TopData[].BigOrder[].AmountdoubleLarge-order amount
TopData[].BigOrder[].TradeTimelongLarge-order trade time
TopData[].Item[].Symbol / Expiry / Strike / RightstringOption contract
TopData[].Item[].TotalAmountdoubleAggregate amount
TopData[].Item[].TotalVolumedoubleAggregate volume
TopData[].Item[].TotalOpenIntdoubleAggregate open interest
TopData[].Item[].VolumeToOpenIntdoubleVolume-to-open-interest ratio
TopData[].Item[].LatestPricedoubleLatest price
TopData[].Item[].UpdateTimelongUpdate time

GetSubscribedSymbolEnd(SubscribedSymbol)

FieldC# typeDescription
Limit / Used / AskBidLimit / AskBidUsed / TradeTickLimit / TradeTickUsed / KlineLimit / KlineUsedintSubscription limit and used count for the corresponding subject
SubscribedSymbols / SubscribedAskBidSymbols / SubscribedTradeTickSymbols / SubscribedMarketQuote / SubscribedKlineSymbolsISet<string>Subscribed quote, depth, tick, whole-market, and bar subjects

SubscribeEnd(int id, string subject, string result) / CancelSubscribeEnd(int id, string subject, string result)

ParameterC# typeDescription
idintRequest ID; correlate it with the command's uint return by its identical 32-bit pattern
subjectstringSubject name converted by the SDK from response DataType
resultstringServer-result JSON; its schema is not defined by a C# model. Parse at least code; only code == 0 means success

Error(string errorMsg) / Error(int id, int errorCode, string errorMsg)

ParameterC# typeDescription
errorMsgstringError message
idintID overload only; available for errors that include a request ID, which can be correlated with the command's uint request ID
errorCodeintID overload only; same limitation

Did this page help you?