Skip to main content

Books

Subscribe to the latest top five bid and ask information for contract

Parameters

NameTypeDescription
channel*stringChannel : trades, books
symbol*stringContract Code
afterHours*boolSubscription AfterHours Session true : AfterHours false : Regular default : false

Response

NameTypeDescription
symbol*stringContract Code
type*stringTicker Type
exchange*stringExchange
marketstringMarket Typ
time*numberTime
bidsobject[]Top 5 bid
>> pricenumberTop 5 bid price
>> sizenumberTop 5 bid volume
asksobject[]Top 5 ask
>> pricenumberTop 5 ask price
>> sizenumberTop 5 ask volume
info

'*' Indicates mandatory disclosure fields.

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

sdk.init_realtime()

futopt = sdk.marketdata.websocket_client.futopt
futopt.on('message', handle_message)
futopt.connect()
futopt.subscribe({
'channel': 'books',
'symbol': 'TXFA4
#'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"
}