Skip to main content

Aggregates

Receive aggregated market data for subscribed futures/options contracts.

Parameters

NameTypeDescription
channel*stringSubscription channel: trades, books, aggregates, candles
symbol*stringFutures/options contract symbol
afterHours*boolSubscribe to after-hours market data. true: after-hours session; false: regular session; default: false

Response

NameTypeDescription
date*stringDate
type*stringFutures/options contract type
exchangestringExchange
symbolstringProduct symbol
namestringProduct name
previousClosenumberPrevious closing price
openPricenumberOpening price
openTimenumberTime of the opening-price trade
highPricenumberHighest price
highTimenumberTime of the highest-price trade
lowPricenumberLowest price
lowTimenumberTime of the lowest-price trade
closePricenumberClosing price (latest trade price)
closeTimenumberTime of the closing-price (latest-price) trade
avgPricenumberAverage trade price for the day
changenumberChange in the latest trade price
changePercentnumberPercentage change in the latest trade price
amplitudenumberIntraday amplitude
lastPricenumberLatest price (including trial matching)
lastSizenumberLatest trade size (including trial matching)
totalobjectTrading statistics
>> tradeVolumenumberCumulative trade volume
>> tradeVolumeAtBidnumberBid-side matched volume
>> tradeVolumeAtAsknumberAsk-side matched volume
lastTradeobjectLatest trade details
>> pricenumberLatest trade price
>> sizenumberLatest trade size
>> timenumberLatest trade time
>> serialnumberLatest trade serial number
lastTrialobjectLatest trial-matching details (available during trial matching only)
>> bidnumberLatest trial bid price
>> asknumberLatest trial ask price
>> pricenumberLatest trial-matching price
>> sizenumberLatest trial-matching size
>> timenumberLatest trial-matching time
>> serialstringLatest trial-matching serial number
serialnumberSerial number
lastUpdatednumberLast updated time
Trial-matching fields

lastTrial contains the latest pre-open trial-matching indication (bid/ask/price/size/time/serial). Availability depends on advanced futures/options market data support. Once trial matching ends at market open, refer to the current specification for its update behavior.

Example

Subscribe channel

from fubon_neo.sdk import FubonSDK, Order, Mode

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(Mode.Normal) # Initialize the market-data connection

futopt = sdk.marketdata.websocket_client.futopt
futopt.on('message', handle_message)
futopt.connect()
futopt.subscribe({
'channel': 'aggregates',
'symbol': 'TXFA4'
})

Subscribe to multiple products

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

Receive data

{
"event": "data",
"data": {
"date": "2023-12-26",
"type": "FUTURE",
"exchange": "TAIFEX",
"symbol": "TXFA4",
"name": "臺股期貨014",
"previousClose": 17622,
"openPrice": 17651,
"openTime": 1703551500020000,
"highPrice": 17740,
"highTime": 1703560921393000,
"lowPrice": 17634,
"lowTime": 1703552892448000,
"closePrice": 17735,
"closeTime": 1703569500075000,
"avgPrice": 17700.51,
"change": 113,
"changePercent": 0.64,
"amplitude": 0.6,
"lastPrice": 17735,
"lastSize": 7,
"total": {
"tradeVolume": 52553,
"totalBidMatch": 26280,
"totalAskMatch": 26273
},
"lastTrade": {
"price": 17735,
"size": 7,
"time": 1703569500075000,
"serial": "00136127"
},
"lastTrial": {
"bid": 17734,
"ask": 17736,
"price": 17735,
"size": 1,
"time": 1703551499000000,
"serial": "00000003"
},
"serial": 136127,
"lastUpdated": 1703569500075000
},
"id": "<CHANNEL_ID>",
"channel": "aggregates"
}