from datetime import date from tqsdk import TqApi, TqAuth, TqBacktest, BacktestFinished import pandas as pd import numpy as np api = TqApi(backtest=TqBacktest(start_dt=date(2021, 9, 24), end_dt=date(2021, 9, 26)), auth=TqAuth()) quote_1 = api.get_tick_serial("KQ.m@SHFE.rb", data_length = 10*60*2) quote_2 = api.get_kline_serial("KQ.m@SHFE.rb", 60, data_length = 10) quote = api.get_quote("KQ.m@SHFE.rb") print(quote.datetime, quote.underlying_symbol) try: while True: api.wait_update() tick_temp = pd.DataFrame() kline_tmp = pd.DataFrame() tick_temp['datatime'] = pd.to_datetime(quote_1.datetime) tick_temp['amount'] = quote_1.amount kline_tmp['datatime'] = pd.to_datetime(quote_2.datetime) print(quote_1.datetime) print(tick_temp) print(kline_tmp) #if api.is_changing(quote, "underlying_symbol"): #print(quote.datetime, quote.underlying_symbol) except BacktestFinished: api.close()
在回测模式下通过get_tick_serial获取醉经1000条最新的tick数据时,用pd.to_datetime()转换纳秒时间轴时发现很多条螺纹钢主力合约的数据是早上6点的。请问早上6点是对应的早上九点还是前一天的夜盘数据?
谢谢
李思恒 已回答的问题 2021年9月28日
更夸张的是到后半段,直接从早上6点跳越至下午1点
1195 2021-09-23 06:59:59.800005120 1.301694e+11
1196 2021-09-23 13:00:00.772000000 2.409473e+08
1197 2021-09-23 13:00:01.268999936 3.273375e+08
1198 2021-09-23 13:00:01.772000000 3.941118e+08
1199 2021-09-23 13:00:02.272000000 4.629986e+08