212 浏览
0

from datetime import date 
from time import sleep
from tqsdk import TqAccount, TqAuth, TqApi, TqReplay

api = TqApi(backtest=TqReplay(date(2021, 7, 5)), 
            auth=TqAuth("*", "**"))
quote = api.get_quote("SHFE.cu2109") 
# quote = api.get_quote("DCE.SP c2111&c2201")

while True:
    api.wait_update()
    if api.is_changing(quote):
        print(quote.datetime)
        print('卖一', quote.bid_price1, quote.bid_volume1)
        print('买一', quote.ask_price1, quote.ask_volume1) 

sleep(30)
api.close()

可能是因为标准套利没有last_price, 没有K线.

但还是希望复盘一下, 历史的买一卖一

编辑问题