index_quote — 规格报价明细
获取 specification 级的每日报价明细:每个指数每个交易日的各规格权重与单价。
- 接口:
index_quote
- 数据示例:见下文
- 权限要求:scope
quote:read
- 更新频率:随后台报价导入实时更新
- 时效限制:有。与
index_daily 相同的会员时效规则(免费用户默认延迟 7 个交易日)。
输入参数
| 名称 |
类型 |
必选 |
描述 |
| index_code |
str |
N |
指数代码,如 Server_Index |
| trade_date |
str |
N |
报价日期 YYYYMMDD(不能与 start_date/end_date 同用) |
| start_date |
str |
N |
开始日期 YYYYMMDD(含边界) |
| end_date |
str |
N |
结束日期 YYYYMMDD(含边界) |
| specification |
str |
N |
规格名称,精确匹配,不做模糊搜索,如 B300 |
所有条件都可省略;省略时分页返回当前 Key 有权访问的全部报价明细。单日明细推荐 index_code + trade_date 组合查询。
Hardware_Index 为系统根据基础指数日涨跌幅生成的派生指数,没有规格报价明细,因此不属于 index_quote 的查询范围。
输出参数
| 名称 |
类型 |
描述 |
| trade_date |
str |
报价日期,YYYYMMDD |
| index_code |
str |
指数代码 |
| specification |
str |
规格名称,Excel 中填写的原文,例如 B300 |
| weight |
str(decimal) |
权重,"0.60000000" 表示 60%;同组合计 = 1 |
| price |
str(decimal) |
规格报价(单价) |
默认字段(省略 fields 时返回全部):
| ["trade_date", "index_code", "specification", "weight", "price"]
|
接口使用
| import tokease
pro = tokease.Client()
# 查询某指数单日全部规格报价
df = pro.query("index_quote", params={
"index_code": "Server_Index",
"trade_date": "20260820",
})
# 查询某个规格的历史报价
df = pro.query("index_quote", params={
"index_code": "Server_Index",
"specification": "B300",
"start_date": "20260801",
"end_date": "20260831",
})
|
数据样例
| trade_date |
index_code |
specification |
weight |
price |
| 20260820 |
Server_Index |
A100 |
0.10000000 |
1200000.000000 |
| 20260820 |
Server_Index |
B300 |
0.60000000 |
13950000.000000 |
| 20260820 |
Server_Index |
H200 |
0.30000000 |
5100000.000000 |
同一"日期 + 指数"的一组规格权重合计精确等于 1。
cURL 示例
| curl -X POST "https://your-domain/api/v1/query" \
-H "Content-Type: application/json" \
-H "X-API-Key: $WHALE_KEY" \
-d '{
"api_name": "index_quote",
"params": {
"index_code": "Server_Index",
"trade_date": "20260820"
},
"fields": ["specification", "weight", "price"]
}'
|
响应:
| {
"request_id": "req_01J5KR2DW3M6W9Y0C7X4J2HZ8N",
"code": 0,
"message": "ok",
"data": {
"fields": ["specification", "weight", "price"],
"items": [
["A100", "0.10000000", "1200000.000000"],
["B300", "0.60000000", "13950000.000000"],
["H200", "0.30000000", "5100000.000000"]
],
"limit": 1000,
"offset": 0,
"returned": 3,
"has_more": false
}
}
|
Go 示例
| package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"time"
)
type queryRequest struct {
APIName string `json:"api_name"`
Params map[string]any `json:"params"`
Fields []string `json:"fields,omitempty"`
Limit int `json:"limit"`
Offset int `json:"offset"`
}
func main() {
payload := queryRequest{
APIName: "index_quote",
Params: map[string]any{
"index_code": "Server_Index",
"trade_date": "20260820",
},
Fields: []string{"specification", "weight", "price"},
Limit: 1000,
}
body, err := json.Marshal(payload)
if err != nil {
panic(err)
}
req, err := http.NewRequest(
http.MethodPost,
"https://your-domain/api/v1/query",
bytes.NewReader(body),
)
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-API-Key", os.Getenv("WHALEINDEX_API_KEY"))
client := &http.Client{Timeout: 30 * time.Second}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
if resp.StatusCode >= 400 {
panic(fmt.Sprintf("HTTP %d: %s", resp.StatusCode, responseBody))
}
fmt.Println(string(responseBody))
}
|
相关页面