QMT · 内置 Python行情函数
ContextInfo.get_trading_dates
ContextInfo.get_trading_dates(stockcode,start_date,end_date,count,period='1d')
原型
ContextInfo.get_trading_dates(stockcode,start_date,end_date,count,period='1d')
释义
ContextInfo.get_trading_dates(stockcode,start_date,end_date,count,period='1d')
参数
| 字段名 | 数据类型 | 解释 |
|---|---|---|
stockcode |
string |
股票代码,缺省值''默认为当前图代码,如:'600000.SH' |
start_date |
string |
开始时间,缺省值''为空时不使用,如:'20170101','20170101000000' |
end_date |
string |
结束时间,缺省值''默认为当前bar的时间,如:'20170102','20170102000000' |
count |
int |
K线个数,必须大于0,取包括end_date往前的count个K线,但最早不会早于start_date |
period |
string |
k线类型,'1d':日线,'1m':分钟线,'3m':三分钟线,'5m':5分钟线,'15m':15分钟线,'30m':30分钟线,'1h':小时线,'1w':周线,'1mon':月线,'1q':季线,'1hy':半年线,'1y':年线 |
返回值
list:K线周期(交易日)列表 period为日线时返回如['20170101','20170102',...]样式 其它返回如['20170101010000','20170102020000',...]样式
示例
示例
# coding:gbk
def init(C):
pass
def after_init(C):
print(C.get_trading_dates('600000.SH','','',30,'1d'))
def handlebar(C):
pass
返回值
['20231101', '20231102', '20231103', '20231106', '20231107', '20231108', '20231109', '20231110', '20231113', '20231114', '20231115', '20231116', '20231117', '20231120', '20231121', '20231122', '20231123', '20231124', '20231127', '20231128', '20231129', '20231130', '20231201', '20231204', '20231205', '20231206', '20231207', '20231208', '20231211', '20231212']
官方来源
QMT 官方文档:获取交易日信息。网页核对日期:2026-10-11。