Skip to main content

Historical Candles

Retrieve historical stock prices within 1 year (query by stock number))

historical/candles/{symbol}

Parameters

NameTypeDescription
symbol*stringStock Number
fromstringStart Date(Format:yyyy-MM-dd
tostringEnd Date(Format:yyyy-MM-dd
timeframestringKLine TimeFrame,offer 1 1m;5 5m;10 10m;15 15m;30 30m;60 60m;D day;W week;M month
fieldsstringFields,offer:open,high,low,close,volume,turnover,change
sortstringSorting,default desc descent, Also offer asc ascent
caution

Currently, for K-line data, you cannot specify a start date (from) and end date (to) on minute timeframe. The API will always return data for the most recent five days, and you cannot choose the turnover and change on the fields."。

Example

from fubon_neo.sdk import FubonSDK, Order

sdk = FubonSDK()

accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password")

sdk.init_realtime() # Establish market-data

reststock = sdk.marketdata.rest_client.stock

print(reststock.historical.candles(**{"symbol": "0050", "from": "2023-02-06", "to": "2023-02-08"}))

Response Body:

{
"symbol": "0050",
"type": "EQUITY",
"exchange": "TWSE",
"market": "TSE",
"data": [
{
"date": "2023-02-08",
"open": 120.1,
"high": 120.95,
"low": 120,
"close": 120.85,
"volume": 9239321,
"change": 1.85
},
{
"date": "2023-02-07",
"open": 119.1,
"high": 119.25,
"low": 118.55,
"close": 119,
"volume": 8787291,
"change": -0.25
},
{
"date": "2023-02-06",
"open": 120.1,
"high": 120.1,
"low": 119.25,
"close": 119.25,
"volume": 14297030,
"change": -1.75
}
]
}

Response

NameTypeDescription
date*stringDate
type*stringData Type
exchange*stringExchange
marketstringMarket Type
symbol*stringStokc Number
timeframe*stringKLine Timeframe
dataCandleKLine Data
info

'*' Indicates mandatory disclosure fields.