Trades 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 | 市場別 |
trades | object[] | 成交報價 |
trades[0].price | number | 成交價格 |
trades[0].size | number | 成交單量 |
trades[0].bid | number | 成交買價 |
trades[0].ask | number | 成交賣價 |
total | object | 成交量 |
total.tradeVolume | number | 成交總量 |
total.totalBidMatch | number | 累計委買成交筆數 |
total.totalAskMatch | number | 累計委賣成交筆數 |
time * | number | 時間 |
serial * | 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': 'trades',
'symbol': 'TXFG4',
'afterHours': True
})
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: "trades", symbol: "TXFG4", afterHours: true });
});
stock.on("message", (message) => {
const data = JSON.parse(message);
console.log(data);
});
Receive data
{
"event": "data",
"data": {
"symbol": "TXFG4",
"type": "FUTURE_AH",
"exchange": "TAIFEX",
"trades": [
{
"price": 23379,
"size": 1,
"bid": 23379,
"ask": 23380
}
],
"total": {
"tradeVolume": 12431,
"totalBidMatch": 8191,
"totalAskMatch": 7964
},
"time": 1718880340342000,
"serial": 23143
},
"id": "<CHANNEL_ID>",
"channel": "trades"
}