Candles BETA
接收訂閱期權商品最新分鐘K
Parameters
Name | Type | Description |
---|---|---|
channel * | string | 訂閱頻道:trades , candles , books , aggregates |
symbol * | string | 商品代碼 |
afterHours | boolean | true: 夜盤, false: 日盤, default: false |
Response
Name | Type | Description |
---|---|---|
date * | string | 日期 |
type * | string | Ticker 類型 |
exchange * | string | 交易所 |
market | string | 市場別 |
symbol * | string | 商品代碼 |
timeframe * | number | K線週期 |
open * | number | K線開盤價 |
high * | number | K線最高價 |
low * | number | K線最低價 |
close * | number | K線收盤價 |
volume * | number | K線成交量(整股:成交張數;興櫃股票及盤中零股:成交股數;指數:成交金額) |
average * | 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': 'candles',
'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: "candles", 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",
"date": "2024-06-21T11:59:00.000+08:00",
"open": 23194,
"high": 23195,
"low": 23187,
"close": 23187,
"volume": 215,
"average": 23176.58
},
"id": "<CHANNEL_ID>",
"channel": "candles"
}