返回列表 发布新帖

在分钟级别回测模式下 如何获取时间, 日线下的函数老是返回错误的时间

135 2
发表于 2025-5-22 13:56:23 | 显示全部楼层 阅读模式
    index  = ContextInfo.barpos
    realtimetag = ContextInfo.get_bar_timetag(index)

返回的都是错误时间, 不是设置的回测时间

评论2

蓝墨
发表于 2025-5-22 14:05:27 | 显示全部楼层
def handlebar(ContextInfo):

    index = ContextInfo.barpos
    now_timestamp = ContextInfo.get_bar_timetag(index)
    timestamp = now_timestamp / 1000  # 将时间戳转换为以秒为单位
    dt_object = datetime.fromtimestamp(timestamp)
试一下,dt_object是当前k线的时间
*******8987_v7ik0楼主
发表于 2025-5-22 18:24:27 | 显示全部楼层
试了        index = ContextInfo.barpos
        now_timestamp = ContextInfo.get_bar_timetag(index)
        timestamp = now_timestamp / 1000  # 将时间戳转换为以秒为单位
        dt_object = datetime.datetime.fromtimestamp(timestamp)   返回的是2025年时间,不是我设置的回测时间

回复

您需要登录后才可以回帖 登录 | 立即注册

客服专线

400-080-8112

用思考的速度交易,用真诚的态度合作,我们是认真的!
  • 关注公众号
  • 添加微信客服
Copyright © 2001-2025 迅投QMT社区 版权所有 All Rights Reserved. 京ICP备2025122616号-3
关灯 快速发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表