已解决3.22K 浏览
0

请教回测时,为什么quote数据在两天时间里才更新了570次呀?不是一秒更新两次么?

#!/usr/bin/env python
#  -*- coding: utf-8 -*-
 from datetime import datetime,date
from tqsdk import TqApi,TqSim,TqBacktest,BacktestFinished, TargetPosTask
 api=TqApi(TqSim(), backtest=TqBacktest(start_dt=date(2020, 5, 6), end_dt=date(2020, 5, 7)))
SYMBOL = "SHFE.rb2010"  # 
CLOSE_HOUR, CLOSE_MINUTE = 14, 50  # 平仓时间
target_pos = TargetPosTask(api, SYMBOL)
quote = api.get_quote(SYMBOL)
iii=0
print("策略开始运行")
 while True:
    api.wait_update()
    if api.is_changing(quote, "datetime"):
        iii=iii+1
        print(iii)
        now = datetime.strptime(quote.datetime, "%Y-%m-%d %H:%M:%S.%f")
        print(now)
        if now.hour == CLOSE_HOUR and now.minute >= CLOSE_MINUTE:  # 
            print("临近本交易日收盘: 平仓")
            target_pos.set_target_volume(0)

Ian 选择最佳答案 2020年5月8日