Books
接收訂閱股票最新最佳五檔委買委賣資訊
Parameters
Name | Type | Description |
---|---|---|
channel * | string | 訂閱頻道:trades , candles , books , aggregates , indices |
symbol * | string | 股票代碼 |
intradayOddLot | boolean | intradayOddLot true: 盤中零股, false: 股票, default: false |
Response
Name | Type | Description |
---|---|---|
symbol * | string | 股票代碼 |
type * | string | Ticker 類型 |
exchange * | string | 交易所 |
market | string | 市場別 |
time * | number | 時間 |
bids | object[] | 最佳五檔委買 |
bids[0].price | number | 最佳五檔委買價格 |
bids[0].size | number | 最佳五檔委買數量 |
asks | object[] | 最佳五檔委賣 |
asks[0].price | number | 最佳五檔委賣價格 |
asks[0].size | number | 最佳五檔委賣數量 |
Example
Subscribe channel
- Python
- Node.js
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()
const { WebSocketClient } = require("@fugle/marketdata");
const client = new WebSocketClient({ apiKey: "YOUR_API_KEY" });
const stock = client.stock;
stock.connect().then(() => {
stock.subscribe({ channel: "books", symbol: "2330" });
});
stock.on("message", (message) => {
const data = JSON.parse(message);
console.log(data);
});
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"
}