142 views
0

#######################################################################################参数设置
    api_master = TqApi(TqAccount(my_corp, my_account, my_pass))
     account = api_master.get_account()
    print("可用资金", account.available)
     # Create new threads
    thread1 = WorkerThread(api_master.copy(), near_contract1, far_contract1, my_ask_price_list1)
    #thread2 = WorkerThread(api_master.copy(), near_contract2, far_contract2, my_ask_price_list2)
    #thread3 = WorkerThread(api_master.copy(), near_contract3, far_contract3, my_ask_price_list2)
     # Start new Threads
    thread1.start()
    #thread2.start()
    #thread3.start()
    while True:
        api_master.wait_update()

在程序启动10分钟后,程序出现中断,提示如下错误:

C:\Python37\python.exe C:/TianQin/strategies/my_handle_multi.py
2019-12-02 21:44:59,393 – INFO – 通知: 已经连接到交易前置
2019-12-02 21:44:59,409 – INFO – 通知: 登录成功
可用资金 1268219.6877000001
2019-12-02 21:45:03,558 – INFO – 通知: 下单成功
Traceback (most recent call last):
File “C:/TianQin/strategies/my_handle_multi.py”, line 73, in <module>
api_master.wait_update()
File “C:\Python37\lib\site-packages\tqsdk\api.py”, line 783, in wait_update
self._merge_diff(self._data, d, self._prototype, False)
File “C:\Python37\lib\site-packages\tqsdk\api.py”, line 1423, in _merge_diff
TqApi._merge_diff(target, diff[key], tpt, tpersist)
File “C:\Python37\lib\site-packages\tqsdk\api.py”, line 1423, in _merge_diff
TqApi._merge_diff(target, diff[key], tpt, tpersist)
File “C:\Python37\lib\site-packages\tqsdk\api.py”, line 1423, in _merge_diff
TqApi._merge_diff(target, diff[key], tpt, tpersist)
[Previous line repeated 1 more time]
File “C:\Python37\lib\site-packages\tqsdk\api.py”, line 1427, in _merge_diff
result[key] == diff[key] or (diff[key] != diff[key] and result[key] != result[key])):
KeyError: ‘pos_short_his’

Process finished with exit code -1

不知道该怎么解决?如果程序出问题应该是马上中断的啊,他这个一直运行了10分钟。

Posted new comment

simnow账号,等待1个小时就会出现这种情况。每次都会出现。

你这个代码我跑过几次了,用的simnow账号,没有触发问题,你可以把api实例化那一句改成这样,
api_master = TqApi(TqAccount(“simnow”, “xxxxxx”, “xxxxxx”),debug=”debug.log”)
保存日志信息,如果再报错就把它发给我,每次运行之前把已经存在的这个文件删掉,因为下一次它会把信息追加进去,不用了可以把它去掉

0

请问这个会稳定重现吗?

Posted new comment

simnow账号,等待1个小时就会出现这种情况。每次都会出现。

好像是历史持仓取得不对?

You are viewing 1 out of 2 answers, click here to view all answers.