返回列表 发布新帖

Tick周期为什么只有最近一个交易日有数据

Tick周期为什么只有最近一个交易日有数据,数据补充过了,也显示下载完成。

#encoding:gbk
from datetime import datetime, timedelta

class GlobalVariable:pass

g = GlobalVariable()
g.accountID = 'test'
g.accountType = 'STOCK'
g.stock_list = ['518660.SH']


def init(c):

    c.set_account(g.accountID,g.accountType)
    c.capital = et.prepare_invest
    c.start = '2021-01-01 00:00:00'
    c.end = datetime.today().strftime('%Y-%m-%d %M:%H:%S')

def handlebar(c):

    # print({datetime.fromtimestamp(c.get_bar_timetag(c.barpos)/1000)})
    current_bar_date = datetime.fromtimestamp(c.get_bar_timetag(c.barpos)/1000)
    start_time = (current_bar_date - timedelta(minutes=5)).strftime('%Y%m%d%H%M%S')
    end_time = current_bar_date.replace(hour=23, minute=59, second=59).strftime('%Y%m%d%H%M%S')

    print(f's{start_time}e{end_time}')

    data = c.get_market_data_ex([],g.stock_list,'tick',start_time,end_time=end_time)

    for stock_code, d in data.items():
        print(f'stock_code:{stock_code}:{d["lastPrice"]}')




回复

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

客服专线

400-080-8112

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