Skip to main content

Candles

Subscribe to the latest minute K-line data for contract

Parameters

NameTypeDescription
channel*stringChannel:trades, candles, books, aggregates
symbol*stringContract code
afterHours*boolSubscription AfterHours Session true : AfterHours false : Regular default : false

Response

NameTypeDescription
date*stringDate
type*stringTicker Type
exchange*stringExchange
marketstringMarket Type
symbol*stringContract Code
timeframe*numberKLine Timeframe
open*numberOpen Price
high*numberHighest Price
low*numberLowest Price
close*numberClose Price
volume*numberVolume
average*numberAverage Price

Example

Subscribe channel

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'
})

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"
}