3.10K 浏览
0

报错信息如下,这种遇到资金不足的情况该如何解决,保证程序继续运行不退出?

2020-12-01 09:00:07 – WARNING – 通知: 下单失败,CTP:资金不足
2020-12-01 09:00:07 – WARNING – 通知: 撤单失败,CTP:撤单找不到相应报单
2020-12-01 09:00:07 – WARNING – 通知: 撤单失败,CTP:撤单找不到相应报单
2020-12-01 09:00:07 – WARNING – 通知: 下单失败,CTP:资金不足
2020-12-01 09:00:07 – WARNING – 通知: 撤单失败,CTP:撤单找不到相应报单
2020-12-01 09:00:07 – WARNING – 通知: 撤单失败,CTP:撤单找不到相应报单
Traceback (most recent call last):
File “.\py\boll_real.py”, line 286, in <module>
while gapi.wait_update(deadline=deadline):
File “C:\Program Files\Python37\lib\site-packages\tqsdk\api.py”, line 1377, in
wait_update
self._run_until_idle()
File “C:\Program Files\Python37\lib\site-packages\tqsdk\api.py”, line 2396, in
_run_until_idle
self._run_once()
File “C:\Program Files\Python37\lib\site-packages\tqsdk\api.py”, line 2389, in
_run_once
raise self._exceptions.pop(0)
File “C:\Program Files\Python37\lib\site-packages\tqsdk\lib.py”, line 210, in
_target_pos_task
await gather(*[each._task for each in all_tasks])
File “C:\Program Files\Python37\lib\site-packages\tqsdk\lib.py”, line 294, in
_run
self._symbol, self._direction, self._offset, self._volume, limit_price, orde
r.last_msg))
Exception: 遇到错单: SHFE.ag2102 SELL OPEN 1手 4784.000000 CTP:资金不足
Task was destroyed but it is pending!
task: <Task pending coro=<TqApi._windows_patch() running at C:\Program Files\Pyt
hon37\lib\site-packages\tqsdk\api.py:2423> wait_for=<Future pending cb=[<TaskWak
eupMethWrapper object at 0x000000AD4D8F7E28>()]> cb=[TqApi._on_task_done()]>
Task was destroyed but it is pending!
task: <Task pending coro=<TqApi._notify_watcher() running at C:\Program Files\Py
thon37\lib\site-packages\tqsdk\api.py:2431> wait_for=<Future pending cb=[<TaskWa
keupMethWrapper object at 0x000000AD4D8E5F48>()]> cb=[TqApi._on_task_done()]>
Exception ignored in: <coroutine object TqApi._notify_watcher at 0x000000AD40AC0
9C8>

ringo 已回答的问题 2020年12月3日

可以用可用资金和大概的保证金率计算下单手数呀。。

关键点是这种业务正常流程不应该导致程序异常退出,而应该继续运行。所以请版主看下具体原因,谢谢!

0

是否使用的是targetpostask,targetpostask的处理逻辑是遇到错单会退出程序

insert_order不会

ringo 已回答的问题 2020年12月3日