3.86K 浏览
0

Traceback (most recent call last):
File “H:/coding/trading/Trade.py”, line 99, in <module>
mtrade.next()
File “H:/coding/trading/Trade.py”, line 75, in next
tradeStrategy = Strategy.invoke(self.tradeStrategy, price)
File “H:\coding\trading\Strategies\Interface.py”, line 9, in invoke
return obj.Run().next(price)
File “H:\coding\trading\Strategies\NPL.py”, line 165, in next
Trade().order(volume, direction)
File “H:\coding\trading\Trade.py”, line 24, in order
self.util.order(volume=volume, direction=direction)
File “H:\coding\trading\Interfaces\Future\TradeUtils.py”, line 42, in order
while self.getContractVolume() != volume:
File “H:\coding\trading\Interfaces\Future\TradeUtils.py”, line 157, in getContractVolume
self._wait()
File “H:\coding\trading\Interfaces\Future\TradeUtils.py”, line 36, in _wait
self.api.wait_update(time.time() + 10)
File “H:\coding\trading\venv\lib\site-packages\tqsdk\api.py”, line 746, in wait_update
self._run_until_idle()
File “H:\coding\trading\venv\lib\site-packages\tqsdk\api.py”, line 1154, in _run_until_idle
self._run_once()
File “H:\coding\trading\venv\lib\site-packages\tqsdk\api.py”, line 1147, in _run_once
raise self._exceptions.pop(0)
File “H:\coding\trading\venv\lib\site-packages\tqsdk\lib.py”, line 138, in _target_pos_task
await gather(*[each.task for each in all_tasks])
File “H:\coding\trading\venv\lib\site-packages\tqsdk\lib.py”, line 215, in _run
self.symbol, self.direction, self.offset, self.volume, limit_price, order.last_msg))
Exception: 遇到错单: DCE.m2001 SELL OPEN 1手 2857.000000 CTP:资金不足
Task was destroyed but it is pending!
task: <Task pending coro=<TqApi._notify_watcher() running at H:\coding\trading\venv\lib\site-packages\tqsdk\api.py:1188> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000001E16FCD6A38>()]> cb=[TqApi._on_task_done()]>
Task was destroyed but it is pending!
task: <Task pending coro=<TqApi._connect() running at H:\coding\trading\venv\lib\site-packages\tqsdk\api.py:1223> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000001E1744D9828>()]> cb=[TqApi._on_task_done()]>
Task was destroyed but it is pending!
task: <Task pending coro=<TqApi._windows_patch() running at H:\coding\trading\venv\lib\site-packages\tqsdk\api.py:1181> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000001E16FCD64F8>()]> cb=[TqApi._on_task_done()]>
Task was destroyed but it is pending!
task: <Task pending coro=<TqApi._connect() running at H:\coding\trading\venv\lib\site-packages\tqsdk\api.py:1223> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000001E16FCD6978>()]> cb=[TqApi._on_task_done()]>
Task was destroyed but it is pending!
task: <Task pending coro=<TqAccount._run() running at H:\coding\trading\venv\lib\site-packages\tqsdk\api.py:1792> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000001E1744D9B28>()]> cb=[TqApi._on_task_done()]>
Exception ignored in: <coroutine object TqApi._notify_watcher at 0x000001E16FCF3620>
Traceback (most recent call last):
File “H:\coding\trading\venv\lib\site-packages\tqsdk\api.py”, line 1188, in _notify_watcher
File “H:\coding\trading\venv\lib\site-packages\tqsdk\api.py”, line 1913, in __anext__
File “D:\userApps\Python\lib\asyncio\queues.py”, line 169, in get
File “H:\coding\trading\venv\lib\site-packages\tqsdk\api.py”, line 954, in _call_soon
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 575, in call_soon
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 358, in _check_closed
RuntimeError: Event loop is closed
Exception ignored in: <coroutine object TqApi._connect at 0x000001E16FCF3FC0>
Traceback (most recent call last):
File “H:\coding\trading\venv\lib\site-packages\tqsdk\api.py”, line 1323, in _connect
File “H:\coding\trading\venv\lib\site-packages\websockets\client.py”, line 527, in __aexit__
File “H:\coding\trading\venv\lib\site-packages\websockets\protocol.py”, line 649, in close
File “D:\userApps\Python\lib\asyncio\tasks.py”, line 342, in wait_for
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 544, in call_later
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 554, in call_at
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 358, in _check_closed
RuntimeError: Event loop is closed
sys:1: RuntimeWarning: coroutine ‘WebSocketCommonProtocol.write_close_frame’ was never awaited
Task was destroyed but it is pending!
task: <Task pending coro=<TqApi._send_handler() running at H:\coding\trading\venv\lib\site-packages\tqsdk\api.py:1344> wait_for=<Future cancelled>>
Exception ignored in: <coroutine object TqApi._connect at 0x000001E16FCF3C50>
Traceback (most recent call last):
File “H:\coding\trading\venv\lib\site-packages\tqsdk\api.py”, line 1323, in _connect
File “H:\coding\trading\venv\lib\site-packages\websockets\client.py”, line 527, in __aexit__
File “H:\coding\trading\venv\lib\site-packages\websockets\protocol.py”, line 649, in close
File “D:\userApps\Python\lib\asyncio\tasks.py”, line 342, in wait_for
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 544, in call_later
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 554, in call_at
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 358, in _check_closed
RuntimeError: Event loop is closed
Task was destroyed but it is pending!
task: <Task pending coro=<TqApi._send_handler() running at H:\coding\trading\venv\lib\site-packages\tqsdk\api.py:1344> wait_for=<Future cancelled>>
Exception ignored in: <coroutine object TqAccount._run at 0x000001E16FCF3BF8>
Traceback (most recent call last):
File “H:\coding\trading\venv\lib\site-packages\tqsdk\api.py”, line 1798, in _run
File “H:\coding\trading\venv\lib\site-packages\tqsdk\api.py”, line 954, in _call_soon
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 575, in call_soon
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 358, in _check_closed
RuntimeError: Event loop is closed
Task was destroyed but it is pending!
task: <Task pending coro=<TqAccount._md_handler() running at H:\coding\trading\venv\lib\site-packages\tqsdk\api.py:1802> wait_for=<Future cancelled>>
Task was destroyed but it is pending!
task: <Task pending coro=<TqAccount._td_handler() running at H:\coding\trading\venv\lib\site-packages\tqsdk\api.py:1809> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000001E16FCD6BB8>()]>>
Exception ignored in: <coroutine object TqAccount._td_handler at 0x000001E172E14258>
Traceback (most recent call last):
File “H:\coding\trading\venv\lib\site-packages\tqsdk\api.py”, line 1809, in _td_handler
File “H:\coding\trading\venv\lib\site-packages\tqsdk\api.py”, line 1913, in __anext__
File “D:\userApps\Python\lib\asyncio\queues.py”, line 169, in get
File “H:\coding\trading\venv\lib\site-packages\tqsdk\api.py”, line 954, in _call_soon
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 575, in call_soon
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 358, in _check_closed
RuntimeError: Event loop is closed
Task was destroyed but it is pending!
task: <Task pending coro=<WebSocketCommonProtocol.transfer_data() running at H:\coding\trading\venv\lib\site-packages\websockets\protocol.py:795> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000001E1744D98B8>()]> cb=[<TaskWakeupMethWrapper object at 0x000001E16FCD6D68>(), _wait.<locals>._on_completion() at D:\userApps\Python\lib\asyncio\tasks.py:380]>
Task was destroyed but it is pending!
task: <Task pending coro=<WebSocketCommonProtocol.keepalive_ping() running at H:\coding\trading\venv\lib\site-packages\websockets\protocol.py:1084> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000001E16FCD6D08>()]>>
Task was destroyed but it is pending!
task: <Task pending coro=<WebSocketCommonProtocol.close_connection() running at H:\coding\trading\venv\lib\site-packages\websockets\protocol.py:1129> wait_for=<Task pending coro=<WebSocketCommonProtocol.transfer_data() running at H:\coding\trading\venv\lib\site-packages\websockets\protocol.py:795> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000001E1744D98B8>()]> cb=[<TaskWakeupMethWrapper object at 0x000001E16FCD6D68>(), _wait.<locals>._on_completion() at D:\userApps\Python\lib\asyncio\tasks.py:380]>>
Task was destroyed but it is pending!
task: <Task pending coro=<WebSocketCommonProtocol.transfer_data() running at H:\coding\trading\venv\lib\site-packages\websockets\protocol.py:795> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000001E1744D9AC8>()]> cb=[<TaskWakeupMethWrapper object at 0x000001E16FCD68E8>(), _wait.<locals>._on_completion() at D:\userApps\Python\lib\asyncio\tasks.py:380]>
Task was destroyed but it is pending!
task: <Task pending coro=<WebSocketCommonProtocol.keepalive_ping() running at H:\coding\trading\venv\lib\site-packages\websockets\protocol.py:1084> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000001E16FCD6918>()]>>
Task was destroyed but it is pending!
task: <Task pending coro=<WebSocketCommonProtocol.close_connection() running at H:\coding\trading\venv\lib\site-packages\websockets\protocol.py:1129> wait_for=<Task pending coro=<WebSocketCommonProtocol.transfer_data() running at H:\coding\trading\venv\lib\site-packages\websockets\protocol.py:795> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000001E1744D9AC8>()]> cb=[<TaskWakeupMethWrapper object at 0x000001E16FCD68E8>(), _wait.<locals>._on_completion() at D:\userApps\Python\lib\asyncio\tasks.py:380]>>
Exception ignored in: <coroutine object WebSocketCommonProtocol.close_connection at 0x000001E172E140F8>
Traceback (most recent call last):
File “H:\coding\trading\venv\lib\site-packages\websockets\protocol.py”, line 1171, in close_connection
File “H:\coding\trading\venv\lib\site-packages\websockets\protocol.py”, line 1195, in wait_for_connection_lost
File “D:\userApps\Python\lib\asyncio\tasks.py”, line 342, in wait_for
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 544, in call_later
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 554, in call_at
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 358, in _check_closed
RuntimeError: Event loop is closed
Exception ignored in: <coroutine object WebSocketCommonProtocol.close_connection at 0x000001E172E14728>
Traceback (most recent call last):
File “H:\coding\trading\venv\lib\site-packages\websockets\protocol.py”, line 1171, in close_connection
File “H:\coding\trading\venv\lib\site-packages\websockets\protocol.py”, line 1195, in wait_for_connection_lost
File “D:\userApps\Python\lib\asyncio\tasks.py”, line 342, in wait_for
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 544, in call_later
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 554, in call_at
File “D:\userApps\Python\lib\asyncio\base_events.py”, line 358, in _check_closed
RuntimeError: Event loop is closed

0

请问是实盘账号吗? “CTP:资金不足” 是order中的last_msg字段,这应该是CTP返回的信息,tqsdk模拟账号中没有这个提示信息(其对应提示信息为“开仓资金不足”)。请检查您的可用资金(account的available字段)是否充足

我的问题,用app也显示资金不足。麻烦了。