日期工具
交易日查询
查询交易日信息
接口基本信息
- 接口名称:
query_trading_dates - 功能描述: 查询指定市场的交易日历,返回区间内的交易日期列表或数量
- 数据更新频率: 实时
- 请求方法:
POST - API 路径:
https://api.wanxingai.com/openapi/query_trading_dates/
使用示例
import requests
url = "https://api.wanxingai.com/openapi/query_trading_dates/"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer sk-********"
}
# 返回所有交易日
payload = {
"marketcode": "212001",
"startdate": "2026-04-01",
"enddate": "2026-04-18",
"mode": "1"
}
resp = requests.post(url, json=payload, headers=headers)
print(resp.json())
import java.net.http.*;
import java.net.URI;
HttpClient client = HttpClient.newHttpClient();
String json = """
{"marketcode": "212001", "startdate": "2026-04-01", "enddate": "2026-04-18", "mode": "1"}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.wanxingai.com/openapi/query_trading_dates/"))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer sk-********")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
curl -X POST https://api.wanxingai.com/openapi/query_trading_dates/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-********" \
-d '{"marketcode": "212001", "startdate": "2026-04-01", "enddate": "2026-04-18", "mode": "1"}'
输入参数说明
| 参数名 | 类型 | 必选 | 默认值 | 描述 | 示例 |
|---|---|---|---|---|---|
marketcode |
str | 是 | — | 交易所代码(212001-上交所, 212100-深交所, 212200-港交所) | 212001 |
startdate |
str | 是 | — | 开始日期,格式 YYYY-MM-DD | 2026-04-01 |
enddate |
str | 是 | — | 结束日期,格式 YYYY-MM-DD | 2026-04-18 |
date_type |
str | 否 | "0" | 日期类型:"0"-交易日, "1"-日历日 | 0 |
period |
str | 否 | "D" | 时间周期:D-日, W-周, M-月, Q-季, S-半年, Y-年 | D |
date_format |
str | 否 | "0" | 返回日期格式:"0"-YYYY-MM-DD, "1"-YYYY/MM/DD, "2"-YYYYMMDD | 0 |
mode |
str | 否 | "1" | "1"-返回区间所有日期, "2"-仅返回日期数量 | 1 |
返回数据说明
| 字段名 | 类型 | 描述 |
|---|---|---|
time |
array[str] | 偏移后的日期(singledate 时为单元素数组,sequencedate 时为完整序列) |