Candles
Subscribe to the latest minute K-line data for contract
Parameters
Name | Type | Description |
---|---|---|
channel * | string | Channel:trades , candles , books , aggregates |
symbol * | string | Contract code |
afterHours * | bool | Subscription AfterHours Session true : AfterHours false : Regular default : false |
Response
Name | Type | Description |
---|---|---|
date * | string | Date |
type * | string | Ticker Type |
exchange * | string | Exchange |
market | string | Market Type |
symbol * | string | Contract Code |
timeframe * | number | KLine Timeframe |
open * | number | Open Price |
high * | number | Highest Price |
low * | number | Lowest Price |
close * | number | Close Price |
volume * | number | Volume |
average * | number | Average Price |
Example
Subscribe channel
- Python
- Node.js
- C#
from fubon_neo.sdk import FubonSDK, Order
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)
futopt = sdk.marketdata.websocket_client.futopt
futopt.on('message', handle_message)
futopt.connect()
futopt.subscribe({
'channel': 'candles',
'symbol': 'TXFA4'
})
const { FubonSDK } = 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); // 建立行情連線
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;
var sdk = new FubonSDK();
var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password");
sdk.InitRealtime(Mode.Normal); // 建立行情連線
var futopt = sdk.MarketData.WebSocketClient.FutureOption;
futopt.OnMessage += (msg) => Console.WriteLine($"receive: { msg }");
await futopt.Connect();
await futopt.Subscribe(FugleMarketData.WebsocketModels.FutureOptionChannel.Candles, "TXFA4");
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"
}