Skip to main content

Books

Receive the latest five best bids and asks for subscribed futures/options contracts.

Parameters

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

Response

NameTypeDescription
symbol*stringFutures/options contract symbol
type*stringTicker type
exchange*stringExchange
marketstringMarket type
time*numberTime
bidsobject[]Five best bids
>> pricenumberBid price
>> sizenumberBid size
asksobject[]Five best asks
>> pricenumberAsk price
>> sizenumberAsk size
derivedBidobjectDerived best bid (one additional level; price/size are 0 when no derived level is available)
>> pricenumberDerived bid price
>> sizenumberDerived bid size
derivedAskobjectDerived best ask (one additional level; price/size are 0 when no derived level is available)
>> pricenumberDerived ask price
>> sizenumberDerived ask size
isTrialbooleantrue during trial matching (present only during the trial-matching phase)
info

'*' indicates fields that are always disclosed.

Derived levels and trial-matching field
  • derivedBid/derivedAsk provide an additional derived quote level, primarily for spread contracts. For ordinary futures contracts, price=0 and size=0 are typical.
  • isTrial may be true whenever the instrument is in trial matching, including pre-open trial matching and an intraday auction/cooling period. During normal continuous matching, the field may be false or omitted.
  • These advanced futures/options market data fields appear only when supported by the service.

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") # Login is required to obtain market-data permissions

sdk.init_realtime() # Initialize the market-data connection

futopt = sdk.marketdata.websocket_client.futopt
futopt.on('message', handle_message)
futopt.connect()
futopt.subscribe({
'channel': 'books',
'symbol': 'TXFA4'
#'afterHours' : True # After-hours market data
})

Subscribe to multiple products

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

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
}
],
"derivedBid": {
"price": 17540,
"size": 1
},
"derivedAsk": {
"price": 0,
"size": 0
},
"time": 1702956500113000
},
"id": "<CHANNEL_ID>",
"channel": "books"
}