Books
Subscribe to the latest top five bid and ask information for contract
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 Typ |
time * | number | Time |
bids | object[] | Top 5 bid |
>> price | number | Top 5 bid price |
>> size | number | Top 5 bid volume |
asks | object[] | Top 5 ask |
>> price | number | Top 5 ask price |
>> size | number | Top 5 ask volume |
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': 'books',
'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: "books",
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.Books, "TXFA4");
// await futopt.Subscribe(FugleMarketData.WebsocketModels.FutureOptionChannel.Books, new FutureOptionParams { Symbol = "TXFC4", AfterHours = true });
Receive data
{
"event": "data",
"data": {
"symbol": "TXFA4",
"type": "FUTURE",
"exchange": "TAIFEX",
"bids": [
{
"price": 17539,
"size": 2
},
{
"price": 17538,
"size": 4
},
{
"price": 17537,
"size": 3
},
{
"price": 17536,
"size": 10
},
{
"price": 17535,
"size": 10
}
],
"asks": [
{
"price": 17541,
"size": 2
},
{
"price": 17542,
"size": 15
},
{
"price": 17543,
"size": 3
},
{
"price": 17544,
"size": 5
},
{
"price": 17545,
"size": 4
}
],
"time": 1702956500113000
},
"id": "<CHANNEL_ID>",
"channel": "books"
}