Trades
Subscribe to the latest stock trade information
Parameters
Name | Type | Description |
---|---|---|
channel * | string | Channel:trades , books , indices |
symbol * | string | Stock Number |
intradayOddLot | boolean | intradayOddLot true: intradayOddLot, false: Common Stock, default: false |
Response
Name | Type | Description |
---|---|---|
symbol * | string | Stock NUmber |
type * | string | Ticker Type |
exchange * | string | Exchange |
market | string | Market Type |
time * | number | Time |
serial * | number | Serial Number |
bid | number | Bid Price |
ask | number | Ask Price |
price | number | Trading Price |
size | number | Trading Volume |
volume | number | Total Trading Volume |
isLimitDownPrice | boolean | Last Matched is Fall Stop Price:true |
isLimitUpPrice | boolean | Last Matched is Rise Stop Price:true |
isLimitDownBid | boolean | Optimal position purchase Fall remarks:true |
isLimitUpBid | boolean | Optimal position purchase Rise remarks:true |
isLimitDownAsk | boolean | Optimal position sale Fall remarks:true |
isLimitUpAsk | boolean | Optimal position sale Fall remarkstrue |
isLimitDownHalt | boolean | Held Match And Instantaneous Fall Trend:true |
isLimitUpHalt | boolean | Held Match And Instantaneous Rise Trend:true |
isTrial | boolean | Trial:true |
isDelayedOpen | boolean | Delayed Open:true |
isDelayedClose | boolean | Delayed Close:true |
isContinuous | boolean | Last Matched is Continuous Market:true |
isOpen | boolean | Open Mark:true |
isClose | boolean | Close Mark:true |
time | number | Trading Time |
info
'*' Indicates mandatory disclosure fields.
Example
Subscribe channel
- Python
- Node.js
- C#
from fubon_neo.sdk import FubonSDK
def handle_message(message):
print(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': 'trades',
'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: "trades", symbol: "0050" });
});
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.Trades, "2330");
Receive data
{
"event": "data",
"data": {
"symbol": "2330",
"type": "EQUITY",
"exchange": "TWSE",
"market": "TSE",
"bid": 567,
"ask": 568,
"price": 568,
"size": 4778,
"volume": 54538,
"isClose": true,
"time": 1685338200000000,
"serial": 6652422
},
"id": "<CHANNEL_ID>",
"channel": "trades"
}