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
afterHours*boolSubscribe to after-hours market data. true: after-hours session; false: regular session; default: false

Response

NameTypeDescription
symbol*stringProduct symbol
type*stringTicker type
exchange*stringExchange
marketstringMarket type
tradesobjectTrade 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-matching field

isTrial is disclosed as true only during pre-open trial matching. After the market opens, regular matching data resumes and this field is omitted. If no trial trade occurs during trial matching, trades[0].price and trades[0].size are 0.

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"
}