from contextlib import closing from tqsdk import TqApi, TqSim from datetime import date from tqsdk import TqApi, TqBacktest acc = TqSim(init_balance=100000) api = TqApi(account=acc, backtest=TqBacktest(start_dt=date(2020, 1, 15), end_dt=date(2020, 2, 9)), web_gui=False) SYMBOL = "SHFE.rb2005" quote = api.get_quote(SYMBOL) with closing(api): while True: api.wait_update() print("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" % (quote.instrument_id.split(".")[1], quote.datetime, quote.last_price, quote.open_interest, quote.amount, quote.volume, quote.bid_price1, quote.ask_price1, quote.bid_volume1, quote.ask_volume1, quote.average))
运行以上代码,打印如下:
rb2005,2020-01-14 14:59:59.999999,3570.0,1311222,nan,0,3569.0,nan,1,0,nan rb2005,2020-01-14 21:00:59.999999,3568.0,1313353,nan,0,3567.0,nan,1,0,nan rb2005,2020-01-14 21:00:59.999999,3568.0,1313353,nan,0,3567.0,nan,1,0,nan
成交额,成交量,买一量,卖一量,均价 等字段明显不对。这是一个bug吗?
en all 选择最佳答案 2020年2月12日
通过downloader下载的数据是正常的,datetime毫秒数据也是和ctp对应上的。quote datetime里的毫秒字段也不对。
以下是通过downloader下载的:
2020-01-14 14:59:58.500000000,3571.0,3572.0,3518.0,3569.0,21,3571.0,1436,915902,32485597590.0,1311233
2020-01-14 14:59:59.000000000,3568.0,3572.0,3518.0,3568.0,322,3570.0,2,916143,32494201800.0,1311218
2020-01-14 14:59:59.500000000,3569.0,3572.0,3518.0,3569.0,5,3570.0,240,916190,32495879490.0,1311222
2020-01-14 14:59:59.500001000,3570.0,3572.0,3518.0,3568.0,299,3570.0,238,916208,32496522040.0,1311222
2020-01-14 14:59:59.500002000,3570.0,3572.0,3518.0,3568.0,299,3570.0,238,916208,32496522040.0,1311222
2020-01-14 14:59:59.999500000,3570.0,3572.0,3518.0,3568.0,299,3570.0,238,916208,32496522040.0,1311222
2020-01-14 18:38:09.500000000,nan,nan,nan,nan,0,nan,0,0,0.0,1311222