Trades
接收訂閱股票最新成交資訊
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 | 時間 |
serial * | number | 流水號 |
bid | number | 成交買價 |
ask | number | 成交賣價 |
price | number | 成交價格 |
size | number | 成交單量 |
volume | number | 成交總量 |
isLimitDownPrice | boolean | 最後成交價為跌停價:true |
isLimitUpPrice | boolean | 最後成交價為漲停價:true |
isLimitDownBid | boolean | 最佳一檔委買跌停價:true |
isLimitUpBid | boolean | 最佳一檔委買漲停價:true |
isLimitDownAsk | boolean | 最佳一檔委賣跌停價:true |
isLimitUpAsk | boolean | 最佳一檔委賣漲停價:true |
isLimitDownHalt | boolean | 暫緩撮合且瞬間趨跌:true |
isLimitUpHalt | boolean | 暫緩撮合且瞬間趨漲:true |
isTrial | boolean | 試撮階段:true |
isDelayedOpen | boolean | 延後開盤信號:true |
isDelayedClose | boolean | 延後收盤信號:true |
isContinuous | boolean | 最後成交為逐筆交易:true |
isOpen | boolean | 開盤信號:true |
isClose | boolean | 收盤信號:true |
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': 'trades',
'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: "trades", symbol: "0050" });
});
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",
"bid": 567,
"ask": 568,
"price": 568,
"size": 4778,
"volume": 54538,
"isClose": true,
"time": 1685338200000000,
"serial": 6652422
},
"id": "<CHANNEL_ID>",
"channel": "trades"
}