Skip to content

QMT 的 run_time 回测为什么不跑

这是机制,不是你写错了。

结论

run_time / schedule_run模型回测里不会执行。回测只按 K 线驱动 handlebar

要回测定时逻辑:把同样的判断写进 handlebar,用 C.is_last_bar() 或 K 线时间过滤。

对照

写法回测实盘运行
handlebar可以可以
subscribe_quote可以
run_time可以

见手册 运行机制对比

改法

python
#coding:gbk
def init(C):
    pass

def handlebar(C):
    if not C.is_last_bar():
        return
    # 原来写在 run_time 回调里的买卖条件,挪到这里
    pass

盘中仍可用 C.run_time("f", "5nSecond", "2019-01-01 09:30:00") 做秒级轮询,但那条路径没有回测。

API 查询 run_time · run_time 短页