Candles
Receive the latest one-minute candlestick for subscribed futures/options contracts.
Parameters
| Name | Type | Description |
|---|---|---|
channel* | string | Subscription channel: trades, books, aggregates, candles |
symbol* | string | Contract symbol |
afterHours* | bool | Subscribe to after-hours market data. true: after-hours session; false: regular session; default: false |
Response
| Name | Type | Description |
|---|---|---|
date* | string | Date |
type* | string | Ticker type |
exchange* | string | Exchange |
market | string | Market type |
symbol* | string | Product symbol |
timeframe* | number | Candlestick timeframe |
open* | number | Candlestick opening price |
high* | number | Candlestick high price |
low* | number | Candlestick low price |
close* | number | Candlestick closing price |
volume* | number | Candlestick volume (board lots for regular-lot trades; shares for Emerging Stock and intraday odd-lot trades; transaction value for indices) |
average* | number | Average trade 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") # Login is required to obtain market-data permissions
sdk.init_realtime(Mode.Normal) # Initialize the market-data connection
futopt = sdk.marketdata.websocket_client.futopt
futopt.on('message', handle_message)
futopt.connect()
futopt.subscribe({
'channel': 'candles',
'symbol': 'TXFA4'
})
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); // Initialize the market-data connection
const futopt = sdk.marketdata.webSocketClient.futopt;
futopt.connect().then(() => {
futopt.subscribe({ channel: "candles", symbol: "TXFA4" });
});
futopt.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); // Initialize the market-data connection
var futopt = sdk.MarketData.WebSocketClient.FutureOption;
futopt.OnMessage += (msg) => Console.WriteLine($"receive: { msg }");
await futopt.Connect();
await futopt.Subscribe(FugleMarketData.WebsocketModels.FutureOptionChannel.Candles, "TXFA4");
Subscribe to multiple products
To subscribe to multiple products at the same time, see Subscribe Channel.
Receive data
{
"event": "data",
"data": {
"symbol": "TXFA4",
"type": "FUTURE",
"exchange": "TAIFEX",
"date": "2023-12-28T12:01:00.000+08:00",
"open": 17861,
"high": 17862,
"low": 17859,
"close": 17862,
"volume": 22,
"average": 17820.19
},
"id": "<CHANNEL_ID>",
"channel": "candles"
}