Historical Candles
Retrieve historical stock prices within 1 year (query by stock number))
historical/candles/{symbol}
Parameters
Name | Type | Description |
---|---|---|
symbol * | string | Stock Number |
from | string | Start Date(Format:yyyy-MM-dd ) |
to | string | End Date(Format:yyyy-MM-dd ) |
timeframe | string | KLine TimeFrame,offer 1 1m;5 5m;10 10m;15 15m;30 30m;60 60m;D day;W week;M month |
fields | string | Fields,offer:open,high,low,close,volume,turnover,change |
sort | string | Sorting,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
- Python
- Node.js
- C#
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"}))
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(); // Establish market-data
const client = sdk.marketdata.restClient
client.stock.historical.candles({ symbol: '0050', from: '2023-02-06', to: '2023-02-08', fields: 'open,high,low,close,volume,change' })
.then(data => console.log(data));
using FubonNeo.Sdk;
using FugleMarketData.QueryModels.Stock.History; //import HistoryTimeFrame
using FugleMarketData.QueryModels; //import FieldsType
var sdk = new FubonSDK();
var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password");
sdk.InitRealtime(); // Establish market-data
var rest = sdk.MarketData.RestClient.Stock;
var candle = await rest.History.Candles("2330", new(DateTime.Today.AddDays(-100),DateTime.Today,HistoryTimeFrame.Week,FieldsType.High|FieldsType.Low));
var candle_con = candle.Content.ReadAsStringAsync().Result;
Console.WriteLine(candle_con);
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
Name | Type | Description |
---|---|---|
date * | string | Date |
type * | string | Data Type |
exchange * | string | Exchange |
market | string | Market Type |
symbol * | string | Stokc Number |
timeframe* | string | KLine Timeframe |
data | Candle | KLine Data |
info
'*' Indicates mandatory disclosure fields.