當前 K 線
GET/v1/quote/{symbol}/cur-kline獲取標的當前 K 線數據,返回距今最新 num 根 K 線,支持分鐘/日/週/月/年/季多種週期與復權方式。僅返回最新 N 條,不能指定歷史區間——指定時間區間請用 get_history_kline。
請求參數
| 參數 | 類型 | 位置 | 必填 | 說明 |
|---|---|---|---|---|
symbol | string | 路徑 | 是 | 標的代碼,如 HK.00700。 |
num | int | 查詢 | 是 | K 線數量,1~370。 |
ktype | int | 查詢 | 否 | K 線類型,默認 2。詳見下方 ktype 枚舉表。 |
autype | int | 查詢 | 否 | 復權類型,默認 1。詳見下方 autype 枚舉表。 |
extended_time | int | 查詢 | 否 | 盤前盤後/夜盤開關,默認 0(僅美股 1 分 K 生效)。詳見下方 extended_time 枚舉表。 |
枚舉 ktype(K 線類型)
| 取值 | 含義 |
|---|---|
| 1 | 1 分鐘 |
| 2 | 日 |
| 3 | 週 |
| 4 | 月 |
| 5 | 年 |
| 6 | 5 分鐘 |
| 7 | 15 分鐘 |
| 8 | 30 分鐘 |
| 9 | 60 分鐘 |
| 10 | 3 分鐘 |
| 11 | 季 |
| 14 | 120 分鐘 |
| 15 | 240 分鐘 |
| 26 | 10 分鐘 |
| 29 | 180 分鐘 |
枚舉 autype(復權類型)
| 取值 | 含義 |
|---|---|
| 0 | 不復權 |
| 1 | 前復權(不含股息) |
| 2 | 後復權(不含股息) |
| 3 | 前復權(含股息) |
| 4 | 後復權(含股息) |
枚舉 extended_time(盤前盤後 / 夜盤開關)
| 取值 | 含義 |
|---|---|
| 0 | 默認(不含盤前盤後) |
| 1 | 含盤前盤後 |
| 2 | 含夜盤 |
請求示例
bash
curl -s "$ip/v1/quote/HK.00700/cur-kline?num=2&ktype=2&autype=1" | jq響應字段
返回 data.kline_list[],每個元素一根 K 線:
| 字段 | 類型 | 說明 |
|---|---|---|
| code | string | 標的代碼,例 HK.00700 |
| name | string | 標的名稱 |
| time_key | int | K 線時間,毫秒時間戳 |
| date | int | K 線日期,YYYYMMDD 整數(分 K 為所屬交易日,日 K 及以上為本地日期),例 20260601 |
| open_price | float | 開盤價 |
| close_price | float | 收盤價(最新一根為最新價) |
| high_price | float | 最高價 |
| low_price | float | 最低價 |
| last_close_price | float | 昨收價 |
| volume | int | 成交量(股) |
| turnover | float | 成交額 |
| turnover_rate | float | 換手率(百分數,20 表示 20%);值為 0 時字段可能省略 |
| pe | float | 市盈率 |
| change_rate | float | 漲跌幅(百分數)= (close_price - last_close_price) / last_close_price x 100 |
限制範圍
- 盤前盤後:
extended_time=1僅對美股 1 分 K(ktype=1)生效;其他 ktype 或非美股市場該開關被忽略。
錯誤碼
| ret_code | error.code | 觸發場景 | 處理建議 |
|---|---|---|---|
| 0 | — | 成功 | — |
| -3 | invalid_parameter | 必填缺失(如 num)/ 類型錯 / 越界(num>370)/ 枚舉非法(ktype/autype 不在合法值集) | 檢查請求參數是否符合入參約束 |
| -4 | — | 標的代碼非法或參數裝配失敗(如 HK.99999999 查不到證券) | 校驗標的代碼是否真實存在 |
| -5 | — | 後端調用失敗(網絡/超時) | 重試;持續失敗請聯繫後端排查 |
| >0 | — | 後端業務錯誤透傳(無權限、風控、限頻等) | 按 ret_msg 文案判斷;權限類錯誤請確認賬號已開通對應市場實時行情 |
響應示例
json
{
"ret_code": 0,
"ret_msg": "success",
"data": {
"kline_list": [
{
"code": "HK.00700",
"name": "腾讯控股",
"time_key": 1780243200000,
"date": 20260601,
"open_price": 432.4,
"close_price": 436,
"high_price": 442,
"low_price": 430,
"last_close_price": 505,
"volume": 35164391,
"turnover": 15331009622,
"turnover_rate": 0.00386,
"pe": 15.97,
"change_rate": -13.663366336633665
},
{
"code": "HK.00700",
"name": "腾讯控股",
"time_key": 1780329600000,
"date": 20260602,
"open_price": 438,
"close_price": 481.6,
"high_price": 484.8,
"low_price": 437.4,
"last_close_price": 436,
"volume": 101874275,
"turnover": 47789124229,
"turnover_rate": 0.01117,
"pe": 17.64,
"change_rate": 10.458715596330276
}
]
}
}