Candles
Subscribe to the latest minute K-line data for stocks
Parameters
| Name | Type | Description |
|---|---|---|
channel* | string | Subscribe Channel:trades, candles, books, aggregates, indices |
symbol* | string | Stock Number |
intradayOddLot | boolean | intradayOddLot true: intradayOddLot , false: Common Stock, default: false |
Response
| Name | Type | Description |
|---|---|---|
date* | string | Date |
type* | string | Ticker Type |
exchange* | string | Exchange |
market | string | Market Type |
symbol* | string | Stock Number |
timeframe* | number | KLine Timeframe |
open* | number | Opening Price |
high* | number | Highest Price |
low* | number | Lowest Price |
close* | number | Close Price |
volume* | number | Volume (Common: sheets ; Emg / Odd-lot : share ; Index : Value) |
average* | number | Average Price |
Example
Subscribe channel
- Python
- Node.js
- C#
from fubon_neo.sdk import FubonSDK, Order, Mode
def handle_message(message):
print(f'market data message: {message}')
sdk = FubonSDK()
accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password")
sdk.init_realtime(Mode.Normal) # Establish market-data
stock = sdk.marketdata.websocket_client.stock
stock.on('message', handle_message)
stock.connect()
stock.subscribe({
'channel': 'candles',
'symbol': '2330'
})
const { FubonSDK, Mode } = require('fubon-neo');
const sdk = new FubonSDK();
const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password");
sdk.initRealtime(Mode.Normal); // Establish market-data
const stock = sdk.marketdata.webSocketClient.stock;
stock.connect().then(() => {
stock.subscribe({ channel: "candles", 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(Mode.Normal); // Establish market-data
var stock = sdk.MarketData.WebSocketClient.Stock;
stock.OnMessage += (msg) => Console.WriteLine($"receive: { msg }");
await stock.Connect();
await stock.Subscribe(StockChannel.Candles, "2330");
Multiple Products
The command to subscribe multiple products at once, please refer to Subscribe Channel
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"
}