2.72K 浏览
0

环境 deepin 15.11

代码如下:

#!/usr/bin/python
from tqsdk import TqApi
api = TqApi()
quote = api.get_quote("SHFE.au2012")
print(quote)

在终端运行后报错,

提示如下:在使用天勤量化之前,默认您已经知晓并同意以下免责条款,如果不同意请立即停止使用:https://www.shinnytech.com/blog/disclaimer/
2020-06-09 23:56:00,679 – INFO – 通知: 与 wss://openmd.shinnytech.com/t/md/front/mobile 的网络连接已建立
{‘datetime’: ‘2020-06-09 23:56:00.500000’, ‘ask_price1’: 390.12, ‘ask_volume1’: 1, ‘bid_price1’: 390.1, ‘bid_volume1’: 16, ‘ask_price2’: 390.16, ‘ask_volume2’: 10, ‘bid_price2’: 390.08, ‘bid_volume2’: 15, ‘ask_price3’: 390.18, ‘ask_volume3’: 6, ‘bid_price3’: 390.06, ‘bid_volume3’: 38, ‘ask_price4’: 390.2, ‘ask_volume4’: 8, ‘bid_price4’: 390.04, ‘bid_volume4’: 7, ‘ask_price5’: 390.22, ‘ask_volume5’: 8, ‘bid_price5’: 390.02, ‘bid_volume5’: 14, ‘last_price’: 390.12, ‘highest’: 390.92, ‘lowest’: 389.66, ‘open’: 390.4, ‘close’: nan, ‘average’: 390.314, ‘volume’: 65092, ‘amount’: 25406328440.0, ‘open_interest’: 210020, ‘settlement’: nan, ‘upper_limit’: 408.98, ‘lower_limit’: 362.68, ‘pre_open_interest’: 208235, ‘pre_settlement’: 385.84, ‘pre_close’: 386.3, ‘price_tick’: 0.02, ‘price_decs’: 2, ‘volume_multiple’: 1000, ‘max_limit_order_volume’: 500, ‘max_market_order_volume’: 0, ‘min_limit_order_volume’: 0, ‘min_market_order_volume’: 0, ‘underlying_symbol’: ”, ‘strike_price’: nan, ‘ins_class’: ‘FUTURE’, ‘instrument_id’: ‘SHFE.au2012’, ‘expired’: False, ‘trading_time’: <tqsdk.objs.TradingTime object at 0x7f4dd3c7d890>, D({‘day’: [[’09:00:00′, ’10:15:00′], [’10:30:00′, ’11:30:00′], [’13:30:00′, ’15:00:00′]], ‘night’: [[’21:00:00′, ’26:30:00′]]}), ‘expire_datetime’: 1608015600.0, ‘delivery_month’: 12, ‘delivery_year’: 2020, ‘option_class’: ”, ‘product_id’: ‘au’, ‘margin’: 19292.0, ‘commission’: 10.0}
Task was destroyed but it is pending!
task: <Task pending coro=<TqApi._notify_watcher() running at /home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/api.py:1567> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f4dcdd17dd0>()]> cb=[TqApi._on_task_done()]>
Exception ignored in: <coroutine object TqApi._notify_watcher at 0x7f4dd4358440>
Traceback (most recent call last):
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/api.py”, line 1567, in _notify_watcher
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/channel.py”, line 110, in anext
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/queues.py”, line 161, in get
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/api.py”, line 1157, in _call_soon
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/base_events.py”, line 687, in call_soon
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/base_events.py”, line 479, in _check_closed
RuntimeError: Event loop is closed
Task was destroyed but it is pending!
task: <Task pending coro=<TqApi._connect() running at /home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/api.py:1629> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f4dcf354090>()]> cb=[TqApi._on_task_done()]>
Task was destroyed but it is pending!
task: <Task pending coro=<TqSim._run() running at /home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/sim.py:93> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f4dcdca53d0>()]> cb=[TqApi._on_task_done()]>
Task was destroyed but it is pending!
task: <Task pending coro=<TqWebHelper._run() running at /home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/tqwebhelper.py:62> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f4dcdca5a90>()]> cb=[TqApi._on_task_done()]>
Exception ignored in: <coroutine object TqApi._connect at 0x7f4de6706170>
Traceback (most recent call last):
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/api.py”, line 1729, in _connect
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/websockets/client.py”, line 525, in aexit
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/websockets/protocol.py”, line 679, in close
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/tasks.py”, line 426, in wait_for
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/base_events.py”, line 656, in call_later
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/base_events.py”, line 666, in call_at
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/base_events.py”, line 479, 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 /home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/api.py:1766> wait_for=>
2020-06-09 23:56:00,969 – WARNING – 模拟交易成交记录
2020-06-09 23:56:00,969 – WARNING – 模拟交易账户资金
2020-06-09 23:56:00,970 – WARNING – 日期:2020-06-10,账户权益:10000000.00,可用资金:10000000.00,浮动盈亏:0.00,持仓盈亏:0.00,平仓盈亏:0.00,市值:0.00,保证金:0.00,手续费:0.00,风险度:0.00%
2020-06-09 23:56:00,970 – WARNING – 胜率:0.00%,盈亏额比例:inf,收益率:0.00%,年化收益率:0.00%,最大回撤:0.00%,年化夏普率:inf
Exception ignored in: <coroutine object TqSim._run at 0x7f4dd4346b90>
Traceback (most recent call last):
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/sim.py”, line 126, in _run
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/sim.py”, line 169, in _send_stat_report
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/channel.py”, line 49, in send
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/queues.py”, line 136, in put
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/queues.py”, line 148, in put_nowait
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/queues.py”, line 66, in _wakeup_next
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/api.py”, line 1157, in _call_soon
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/base_events.py”, line 687, in call_soon
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/base_events.py”, line 479, in _check_closed
RuntimeError: Event loop is closed
Exception ignored in: <coroutine object TqWebHelper._run at 0x7f4de5422b00>
RuntimeError: coroutine ignored GeneratorExit
Task was destroyed but it is pending!
task: <Task cancelling coro=<TqWebHelper._data_handler_without_web() running at /home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/tqwebhelper.py:136> wait_for= cb=[gather.._done_callback() at /home/yanglu/anaconda3/lib/python3.7/asyncio/tasks.py:691]>
Task was destroyed but it is pending!
task: <Task pending coro=<WebSocketCommonProtocol.transfer_data() running at /home/yanglu/anaconda3/lib/python3.7/site-packages/websockets/protocol.py:827> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f4dcdca54d0>()]> cb=[<TaskWakeupMethWrapper object at 0x7f4dcdca5650>()]>
Task was destroyed but it is pending!
task: <Task pending coro=<WebSocketCommonProtocol.keepalive_ping() running at /home/yanglu/anaconda3/lib/python3.7/site-packages/websockets/protocol.py:1121> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f4dcdca5610>()]>>
Task was destroyed but it is pending!
task: <Task pending coro=<WebSocketCommonProtocol.close_connection() running at /home/yanglu/anaconda3/lib/python3.7/site-packages/websockets/protocol.py:1169> wait_for=<Task pending coro=<WebSocketCommonProtocol.transfer_data() running at /home/yanglu/anaconda3/lib/python3.7/site-packages/websockets/protocol.py:827> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f4dcdca54d0>()]> cb=[<TaskWakeupMethWrapper object at 0x7f4dcdca5650>()]>>
Task was destroyed but it is pending!
task: <Task pending coro=<TqSim._md_handler() running at /home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/sim.py:131> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f4dcdca58d0>()]>>
Exception ignored in: <coroutine object WebSocketCommonProtocol.close_connection at 0x7f4dcdd1b3b0>
Traceback (most recent call last):
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/websockets/protocol.py”, line 1206, in close_connection
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/websockets/protocol.py”, line 1229, in wait_for_connection_lost
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/tasks.py”, line 426, in wait_for
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/base_events.py”, line 656, in call_later
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/base_events.py”, line 666, in call_at
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/base_events.py”, line 479, in _check_closed
RuntimeError: Event loop is closed
Exception ignored in: <coroutine object TqSim._md_handler at 0x7f4dcfc1b290>
Traceback (most recent call last):
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/sim.py”, line 131, in _md_handler
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/channel.py”, line 110, in anext
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/queues.py”, line 161, in get
File “/home/yanglu/anaconda3/lib/python3.7/site-packages/tqsdk/api.py”, line 1157, in _call_soon
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/base_events.py”, line 687, in call_soon
File “/home/yanglu/anaconda3/lib/python3.7/asyncio/base_events.py”, line 479, in _check_closed
RuntimeError: Event loop is closed

ringo 已回答的问题 2020年6月10日