Skip to main content

Books

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

Parameters

NameTypeDescription
channel*stringSubscribe Channel:trades, books, indices
symbol*stringStock Number
intradayOddLotbooleanintradayOddLot true: intraday OddLot, false: Common Stock, default: false

Response

NameTypeDescription
symbol*stringStock Number
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() # Establish market-data

stock = sdk.marketdata.websocket_client.stock
stock.on('message', handle_message)
stock.connect()
stock.subscribe({
'channel': 'books',
'symbol': '2330'
})

Receive data

{
"event": "data",
"data": {
"symbol": "2330",
"type": "EQUITY",
"exchange": "TWSE",
"market": "TSE",
"bids": [
{
"price": 567,
"size": 87
},
{
"price": 566,
"size": 2454
},
{
"price": 565,
"size": 611
},
{
"price": 564,
"size": 609
},
{
"price": 563,
"size": 636
}
],
"asks": [
{
"price": 568,
"size": 800
},
{
"price": 569,
"size": 806
},
{
"price": 570,
"size": 3643
},
{
"price": 571,
"size": 1041
},
{
"price": 572,
"size": 2052
}
],
"time": 1685338200000000
},
"id": "<CHANNEL_ID>",
"channel": "books"
}