Books
Subscribe to the latest top five bid and ask information for stocks
Parameters
Name | Type | Description |
---|---|---|
channel * | string | Subscribe Channel:trades , books , indices |
symbol * | string | Stock Number |
intradayOddLot | boolean | intradayOddLot true: intraday OddLot, false: Common Stock, default: false |
Response
Name | Type | Description |
---|---|---|
symbol * | string | Stock Number |
type * | string | Ticker Type |
exchange * | string | Exchange |
market | string | Market Typ |
time * | number | Time |
bids | object[] | Top 5 bid |
>> price | number | Top 5 bid price |
>> size | number | Top 5 bid volume |
asks | object[] | Top 5 ask |
>> price | number | Top 5 ask price |
>> size | number | Top 5 ask volume |
info
'*' Indicates mandatory disclosure fields.
Example
Subscribe channel
- Python
- Node.js
- C#
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'
})
const { FubonSDK } = require('fubon-neo');
const sdk = new FubonSDK();
const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password");
sdk.initRealtime(); // Establish market-data
const stock = sdk.marketdata.webSocketClient.stock;
stock.connect().then(() => {
stock.subscribe({ channel: "books", symbol: "2330" });
});
stock.on("message", (message) => {
const data = JSON.parse(message);
console.log(data);
});
using FubonNeo.Sdk;
using FugleMarketData.WebsocketModels;
var sdk = new FubonSDK();
var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password");
sdk.InitRealtime(); // Establish market-data
var stock = sdk.MarketData.WebSocketClient.Stock;
stock.OnMessage += (msg) => Console.WriteLine($"receive: { msg }");
await stock.Connect();
await stock.Subscribe(StockChannel.Books, "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"
}