Skip to main content

Books

接收訂閱股票最新最佳五檔委買委賣資訊

Parameters

NameTypeDescription
channel*string訂閱頻道:trades, candles, books, aggregates, indices
symbol*string股票代碼
intradayOddLotbooleanintradayOddLot true: 盤中零股, false: 股票, default: false

Response

NameTypeDescription
symbol*string股票代碼
type*stringTicker 類型
exchange*string交易所
marketstring市場別
time*number時間
bidsobject[]最佳五檔委買
bids[0].pricenumber最佳五檔委買價格
bids[0].sizenumber最佳五檔委買數量
asksobject[]最佳五檔委賣
asks[0].pricenumber最佳五檔委賣價格
asks[0].sizenumber最佳五檔委賣數量

Example

Subscribe channel

from fugle_marketdata import WebSocketClient

def handle_message(message):
print(message)

def main():
client = WebSocketClient(api_key='YOUR_API_KEY')
stock = client.stock
stock.on('message', handle_message)
stock.connect()
stock.subscribe({
'channel': 'books',
'symbol': '2330'
})

if __name__ == '__main__':
main()

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