Trades
Subscribe to the latest contract trade information
Parameters
Name | Type | Description |
---|---|---|
channel * | string | Channel:trades , books |
symbol * | string | Contract code |
afterHours * | bool | Subscription AfterHours Session true : AfterHours false : Regular default : false |
Response
Name | Type | Description |
---|---|---|
symbol * | string | Contract code |
type * | string | Ticker Type |
exchange * | string | Exchange |
market | string | Market Type |
trades | object | List |
>> price | number | Trading Price |
>> size | number | Trading Volume |
>> bid | number | Bid Price |
>> ask | number | Ask Price |
total | object | List |
>> tradeVolume | number | Total Trading Volume |
>> totalBidMatch | number | Total Trading Bid Volume |
>> totalAskMatch | number | Total Trading Ask Volume |
time * | number | Time |
serial * | number | Serial Number |
info
'*' Indicates mandatory disclosure fields.
Example
Subscribe channel
- Python
- Node.js
- C#
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")
sdk.init_realtime()
futopt = sdk.marketdata.websocket_client.futopt
futopt.on('message', handle_message)
futopt.connect()
futopt.subscribe({
'channel': 'trades',
'symbol': 'TXFA4'
#'afterHours' : True
})
const { FubonSDK } = require('fubon-neo');
const sdk = new FubonSDK();
const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password");
sdk.initRealtime();
const futopt = sdk.marketdata.webSocketClient.futopt;
futopt.connect().then(() => {
futopt.subscribe({
channel: "trades",
symbol: "TXFA4"
// afterHours: true
});
});
futopt.on("message", (message) => {
const data = JSON.parse(message);
console.log(data);
});
using FubonNeo.Sdk;
var sdk = new FubonSDK();
var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password");
sdk.InitRealtime();
var futopt = sdk.MarketData.WebSocketClient.FutureOption;
futopt.OnMessage += (msg) => Console.WriteLine($"receive: { msg }");
await futopt.Connect();
await futopt.Subscribe(FugleMarketData.WebsocketModels.FutureOptionChannel.Trades, "TXFA4");
// await futopt.Subscribe(FugleMarketData.WebsocketModels.FutureOptionChannel.Trades, new FutureOptionParams { Symbol = "TXFC4", AfterHours = true });
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"
}