Candles
接收訂閱股票最新分鐘K
Parameters
Name | Type | Description |
---|---|---|
channel * | string | 訂閱頻道:trades , candles , books , aggregates , indices |
symbol * | string | 股票代碼 |
intradayOddLot | boolean | intradayOddLot true: 盤中零股, false: 股票, default: false |
Response
Name | Type | Description |
---|---|---|
date * | string | 日期 |
type * | string | Ticker 類型 |
exchange * | string | 交易所 |
market | string | 市場別 |
symbol * | string | 股票代號 |
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')
stock = client.stock
stock.on('message', handle_message)
stock.connect()
stock.subscribe({
'channel': 'candles',
'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: "candles", 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",
"date": "2023-05-29T13:30:00.000+08:00",
"open": 568,
"high": 568,
"low": 568,
"close": 568,
"volume": 4778,
"average": 568.77
},
"id": "<CHANNEL_ID>",
"channel": "candles"
}