Historical K-Line Data Query
Query historical K-line data for global stocks, forex, futures, cryptocurrencies, and other instruments. Supports multiple timeframes, returning open, high, low, close, and volume, suitable for financial data analysis.
Documentation
API Capabilities
This API provides historical K-line market data queries for various global financial instruments (including stocks, forex, futures, precious metals, cryptocurrencies, stock indices, etc.). It supports multiple timeframes from 1 minute to monthly (e.g., 1M, 5M, 15M, 30M, 1H, 4H, D, W, M). Based on the specified date and period, the API returns K-line data containing core metrics such as timestamp, open price, high price, low price, close price, and volume.
Request and Response
The request requires the instrument contract code (symbol), timeframe (period), base date (date), and whether to include the latest dynamic K-line (withlast). In the response, the Obj field contains a semicolon-separated string of K-line data. Each data group is comma-separated, representing: timestamp, open price, high price, low price, close price, open interest (for some instruments), and volume, respectively. Data is sorted from the start time to the end time.
Use Cases
- Quantitative Trading Backtesting: Obtain historical K-line data for writing and validating quantitative trading strategies and performing historical market backtesting.
- Financial Charting: Provide historical K-line data sources for financial news apps or websites, used for drawing K-line charts and technical indicator analysis.
- Market Data Analysis: For financial researchers or developers to conduct historical price trend analysis, volatility calculations, and academic research.
Usage Instructions and Limitations
- The time span of data returned by the API is affected by the timeframe: 1-minute timeframe returns up to 30 days of data, 5-minute and hourly timeframes up to 180 days, daily up to 10 years, weekly up to 2 years, and monthly up to 5 years.
- The data provided by this API is for historical market query and technical analysis reference only. It does not constitute any investment advice and must not be used to predict market trends or guide actual trading bets.
- Note the differences in trading hours for various instruments; no data may be returned during non-trading periods. Please handle exceptions based on the returned status code (
Code) and message (Msg).
Integration Examples
Includes ready-to-use Shell, Python, Go, Java, and PHP examples for direct integration.
Request Example
{
"symbol": "品种合约代码(查询连接 http://demo.konpn.com/symbols.shtml",
"period": "取 1M,3M,5M,10M,15M,30M,1H,2H,3H,4H,D,W,M。周期是1,5,15分钟则返回date当日的数据。 周期是30分钟或1小时则返回...",
"date": "日期,返回结果排序顺序。接口输出的日周期数据最多只有10年,1分钟周期数据只有最近30天,5分钟及小时周期最多180天",
"withlast": "是否包含最新的一个动态k线数据,(填写1是,0否)"
}Response Example
{
"Code": 0,
"Msg": "",
"Obj": "1600854240,10452.6,10455.8,10456.2,10452.5,0,5.37;1600854180,10455.8,10452.6,10455.8,10452.6,0,5.08"
}Request Fields
The fields below are derived from example JSON for integration reference only.
| Path | Type | Sample |
|---|---|---|
| type | string | object |
| properties | object | {...} |
| properties.symbol | object | {...} |
| properties.symbol.type | string | string |
| properties.symbol.description | string | 品种合约代码(查询连接 http://demo.konpn.com/symbols.shtml |
| properties.period | object | {...} |
| properties.period.type | string |
Response Fields
The fields below are derived from example JSON for integration reference only.
| Path | Type | Sample |
|---|---|---|
| type | string | object |
| properties | object | {...} |
| properties.Code | object | {...} |
| properties.Code.type | string | number |
| properties.Code.example | number | 0 |
| properties.Msg | object | {...} |
| properties.Msg.type | string | string |