Skip to main content

Trades

Receive the latest trade information for subscribed futures/options contracts.

Parameters​

NameTypeDescription
channel*stringSubscription channel: trades, books, aggregates, candles
symbol*stringFutures product symbol
afterHoursbooleanSubscribe to after-hours market data. true: after-hours session; false: regular session; default: false

Response​

NameTypeDescription
symbol*stringProduct symbol
type*stringTicker type
exchange*stringExchange
tradesobject[]Trade quote
>> pricenumberTrade price
>> sizenumberTrade size
>> bidnumberBid price at the trade
>> asknumberAsk price at the trade
totalobjectTrade volume statistics
>> tradeVolumenumberTotal trade volume
>> totalBidMatchnumberBid-side match count
>> totalAskMatchnumberAsk-side match count
time*numberTime
serial*numberSerial number
isTrialbooleantrue during trial matching (present only during trial matching and omitted after the market opens)
info

'*' indicates fields that are always disclosed.

Trial field

isTrial is only present (true) during the pre-market trial matching session; once trial matching ends at market open, official matching resumes and this field no longer appears. During trial matching, trades carries trial-matching results rather than actual executions — do not count them as trades:

  • Trial-matching messages do not accumulate totals: total.tradeVolume, total.totalBidMatch and total.totalAskMatch are all 0.
  • When a trial match produces no price, trades[0].price/trades[0].size are 0, meaning that trial produced no match — not that the trade price was 0.

Trial-matching messages on this channel are pushed only over v1.1; the aggregates channel pushes updates during the trial-matching session on v1.0 as well. See Getting Started for the streaming version setting. Available since v2.2.9.

Example​

Subscribe channel​

from fubon_neo.sdk import FubonSDK, Order

def handle_message(message):
print(f'market data message: {message}')

sdk = FubonSDK()
accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login is required to obtain market-data permissions

sdk.init_realtime() # Initialize the market-data connection

futopt = sdk.marketdata.websocket_client.futopt
futopt.on('message', handle_message)
futopt.connect()
futopt.subscribe({
'channel': 'trades',
'symbol': 'TXFA4'
#'afterHours' : True # After-hours market data
})

Subscribe to multiple products

To subscribe to multiple products at the same time, see Subscribe Channel.

Receive data​

{
"event": "data",
"data": {
"symbol": "TXFA4",
"type": "FUTURE",
"exchange": "TAIFEX",
"trades": [
{
"price": 17540,
"size": 1,
"bid": 17539,
"ask": 17540
}
],
"total": {
"tradeVolume": 12174,
"totalBidMatch": 8760,
"totalAskMatch": 7907
},
"time": 1702956487023000,
"serial": 159250
},
"id": "<CHANNEL_ID>",
"channel": "trades"
}

Trial-matching phase (isTrial)​

During pre-open trial matching, data also includes isTrial: true:

{
"event": "data",
"data": {
"symbol": "TXFF6",
"type": "FUTURE_AH",
"exchange": "TAIFEX",
"trades": [
{
"price": 45380,
"size": 1
}
],
"total": {
"tradeVolume": 0,
"totalBidMatch": 0,
"totalAskMatch": 0
},
"isTrial": true,
"time": 1781506205000000,
"serial": 3
},
"channel": "trades"
}