Books BETA
接收訂閱期權商品最新最佳五檔委買委賣資訊
Parameters
Name | Type | Description |
---|---|---|
channel * | string | 訂閱頻道:trades , candles , books , aggregates |
symbol * | string | 商品代碼 |
afterHours | boolean | 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')
futopt = client.futopt
futopt.on('message', handle_message)
futopt.connect()
futopt.subscribe({
'channel': 'books',
'symbol': 'TXFG4',
})
if __name__ == '__main__':
main()
const { WebSocketClient } = require("@fugle/marketdata");
const client = new WebSocketClient({ apiKey: "YOUR_API_KEY" });
const futopt = client.futopt;
stock.connect().then(() => {
stock.subscribe({ channel: "books", symbol: "TXFG4" });
});
stock.on("message", (message) => {
const data = JSON.parse(message);
console.log(data);
});
Receive data
{
"event": "data",
"data": {
"symbol": "TXFG4",
"type": "FUTURE",
"exchange": "TAIFEX",
"bids": [
{
"price": 23187,
"size": 13
},
{
"price": 23186,
"size": 15
},
{
"price": 23185,
"size": 21
},
{
"price": 23184,
"size": 11
},
{
"price": 23183,
"size": 15
}
],
"asks": [
{
"price": 23189,
"size": 5
},
{
"price": 23190,
"size": 14
},
{
"price": 23191,
"size": 17
},
{
"price": 23192,
"size": 19
},
{
"price": 23193,
"size": 15
}
],
"time": 1718942376775000
},
"id": "<CHANNEL_ID>",
"channel": "books"
}