Aggregates
Receive aggregated market data for subscribed futures/options contracts.
Parameters
| Name | Type | Description |
|---|---|---|
channel* | string | Subscription channel: trades, books, aggregates, candles |
symbol* | string | Futures/options contract symbol |
afterHours* | bool | Subscribe to after-hours market data. true: after-hours session; false: regular session; default: false |
Response
| Name | Type | Description |
|---|---|---|
date* | string | Date |
type* | string | Futures/options contract type |
exchange | string | Exchange |
symbol | string | Product symbol |
name | string | Product name |
previousClose | number | Previous closing price |
openPrice | number | Opening price |
openTime | number | Time of the opening-price trade |
highPrice | number | Highest price |
highTime | number | Time of the highest-price trade |
lowPrice | number | Lowest price |
lowTime | number | Time of the lowest-price trade |
closePrice | number | Closing price (latest trade price) |
closeTime | number | Time of the closing-price (latest-price) trade |
avgPrice | number | Average trade price for the day |
change | number | Change in the latest trade price |
changePercent | number | Percentage change in the latest trade price |
amplitude | number | Intraday amplitude |
lastPrice | number | Latest price (including trial matching) |
lastSize | number | Latest trade size (including trial matching) |
total | object | Trading statistics |
>> tradeVolume | number | Cumulative trade volume |
>> tradeVolumeAtBid | number | Bid-side matched volume |
>> tradeVolumeAtAsk | number | Ask-side matched volume |
lastTrade | object | Latest trade details |
>> price | number | Latest trade price |
>> size | number | Latest trade size |
>> time | number | Latest trade time |
>> serial | number | Latest trade serial number |
lastTrial | object | Latest trial-matching details (available during trial matching only) |
>> bid | number | Latest trial bid price |
>> ask | number | Latest trial ask price |
>> price | number | Latest trial-matching price |
>> size | number | Latest trial-matching size |
>> time | number | Latest trial-matching time |
>> serial | string | Latest trial-matching serial number |
serial | number | Serial number |
lastUpdated | number | Last 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
- Python
- Node.js
- C#
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'
})
const { FubonSDK, Mode } = require('fubon-neo');
const sdk = new FubonSDK();
const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password");
sdk.initRealtime(Mode.Normal); // Initialize the market-data connection
const futopt = sdk.marketdata.webSocketClient.futopt;
futopt.connect().then(() => {
futopt.subscribe({ channel: "aggregates", symbol: "TXFA4" });
});
futopt.on("message", (message) => {
const data = JSON.parse(message);
console.log(data);
});
using FubonNeo.Sdk;
using FugleMarketData.WebsocketModels;
var sdk = new FubonSDK();
var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password");
sdk.InitRealtime(Mode.Normal); // Initialize the market-data connection
var futopt = sdk.MarketData.WebSocketClient.FutureOption;
futopt.OnMessage += (msg) => Console.WriteLine($"receive: { msg }");
await futopt.Connect();
await futopt.Subscribe(FugleMarketData.WebsocketModels.FutureOptionChannel.Aggregates, "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"
}