2021-02-01 14:00:00.000000 – 通知: 与交易服务器的网络连接已建立.
2021-02-01 14:00:00.000000 – 通知: 与合约服务器的网络连接已建立.
Traceback (most recent call last):
File “.\main.py”, line 20, in <module>
aa = api.get_quote(“SHFE.au2106”)
RuntimeError: 合约代码 SHFE.au2106 不存在, 请检查合约代码是否填写正确. —>合约代码检测了几遍,没发现问题,这是什么原因?
代码如下:
from tqsdk2 import TqApi,TqAccount,TqKq,TqSim,TqAuth,TqBacktest,BacktestFinished
api = TqApi(TqSim(), backtest=TqBacktest(start_dt=date(2021, 2, 1), end_dt=date(2021, 2, 2)),
auth=TqAuth(“realchongge”,”83chongge”))
aa = api.get_quote(“SHFE.au2106”)
api.wait_update()
print(aa)
ringo 已回答的问题 2021年11月9日
并不总是失败,偶尔能查至,如下
在使用天勤量化之前,默认您已经知晓并同意以下免责条款,如果不同意请立即停止使用:https://www.shinnytech.com/blog/disclaimer/
2021-02-01 14:00:00.000000 – 通知: 与交易服务器的网络连接已建立.
2021-02-01 14:00:00.000000 – 通知: 与合约服务器的网络连接已建立.
{‘exchange_id’: ‘KQ’, ‘instrument_id’: ‘m@SHFE.au’, ‘last_price’: 390.5, ‘ask_price1’: 390.52, ‘ask_price2’: 0, ‘ask_price3’: 0, ‘ask_price4’: 0, ‘ask_price5’: 0, ‘ask_volume1’: 1, ‘ask_volume2’: 0, ‘ask_volume3’: 0, ‘ask_volume4’: 0, ‘ask_volume5’: 0, ‘bid_price1’: 390.48, ‘bid_price2’: 0, ‘bid_price3’: 0, ‘bid_price4’: 0, ‘bid_price5’: 0, ‘bid_volume1’: 1, ‘bid_volume2’: 0, ‘bid_volume3’: 0, ‘bid_volume4’: 0, ‘bid_volume5’: 0, ‘highest’: nan, ‘lowest’: nan, ‘open’: nan, ‘close’: nan, ‘average’: nan, ‘volume’: 0, ‘amount’: nan, ‘open_interest’: 115170, ‘settlement’: nan, ‘upper_limit’: nan, ‘lower_limit’: nan, ‘instrument_name’: ‘沪金主连’}
{‘exchange_id’: ‘SHFE’, ‘instrument_id’: ‘au2106’, ‘last_price’: 390.5, ‘ask_price1’: 390.5, ‘ask_price2’: 0, ‘ask_price3’: 0, ‘ask_price4’: 0, ‘ask_price5’: 0, ‘ask_volume1’: 1, ‘ask_volume2’: 0, ‘ask_volume3’: 0, ‘ask_volume4’: 0, ‘ask_volume5’: 0, ‘bid_price1’: 390.5, ‘bid_price2’: 0, ‘bid_price3’: 0, ‘bid_price4’: 0, ‘bid_price5’: 0, ‘bid_volume1’: 1, ‘bid_volume2’: 0, ‘bid_volume3’: 0, ‘bid_volume4’: 0, ‘bid_volume5’: 0, ‘highest’: nan, ‘lowest’: nan, ‘open’: nan, ‘close’: nan, ‘average’: nan, ‘volume’: 0, ‘amount’: nan, ‘open_interest’: 115170, ‘settlement’: nan, ‘upper_limit’: nan, ‘lower_limit’: nan, ‘instrument_name’: ”}