api = TqApi(backtest=TqReplay(date(2023, 6, 28)),web_gui=True, auth=TqAuth("账号", "密码")) quote = api.get_quote("CZCE.RM309") while True: api.wait_update() if api.is_changing(quote): print("最新价", quote.datetime, quote.last_price)
Traceback (most recent call last):
File “D:\Anaconda\anaconda3\lib\site-packages\urllib3\connection.py”, line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File “D:\Anaconda\anaconda3\lib\site-packages\urllib3\util\connection.py”, line 84, in create_connection
raise err
File “D:\Anaconda\anaconda3\lib\site-packages\urllib3\util\connection.py”, line 74, in create_connection
sock.connect(sa)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “D:\Anaconda\anaconda3\lib\site-packages\urllib3\connectionpool.py”, line 677, in urlopen
chunked=chunked,
File “D:\Anaconda\anaconda3\lib\site-packages\urllib3\connectionpool.py”, line 392, in _make_request
conn.request(method, url, **httplib_request_kw)
File “D:\Anaconda\anaconda3\lib\http\client.py”, line 1277, in request
self._send_request(method, url, body, headers, encode_chunked)
File “D:\Anaconda\anaconda3\lib\http\client.py”, line 1323, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “D:\Anaconda\anaconda3\lib\http\client.py”, line 1272, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “D:\Anaconda\anaconda3\lib\http\client.py”, line 1032, in _send_output
self.send(msg)
File “D:\Anaconda\anaconda3\lib\http\client.py”, line 972, in send
self.connect()
File “D:\Anaconda\anaconda3\lib\site-packages\urllib3\connection.py”, line 187, in connect
conn = self._new_conn()
File “D:\Anaconda\anaconda3\lib\site-packages\urllib3\connection.py”, line 167, in _new_conn
% (self.host, self.timeout),
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPConnection object at 0x000001F49444D348>, ‘Connection to replay.api.shinnytech.com timed out. (connect timeout=5)’)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “D:\Anaconda\anaconda3\lib\site-packages\requests\adapters.py”, line 449, in send
timeout=timeout
File “D:\Anaconda\anaconda3\lib\site-packages\urllib3\connectionpool.py”, line 727, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File “D:\Anaconda\anaconda3\lib\site-packages\urllib3\util\retry.py”, line 446, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=’replay.api.shinnytech.com’, port=80): Max retries exceeded with url: /t/rmd/replay/create_session (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x000001F49444D348>, ‘Connection to replay.api.shinnytech.com timed out. (connect timeout=5)’))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “D:\Anaconda\anaconda3\lib\site-packages\tqsdk\api.py”, line 286, in __init__
self._setup_connection() # 初始化通讯连接
File “D:\Anaconda\anaconda3\lib\site-packages\tqsdk\api.py”, line 3150, in _setup_connection
self._ins_url, self._md_url = self._backtest._create_server(self)
File “D:\Anaconda\anaconda3\lib\site-packages\tqsdk\backtest\replay.py”, line 57, in _create_server
session = self._prepare_session()
File “D:\Anaconda\anaconda3\lib\site-packages\tqsdk\backtest\replay.py”, line 91, in _prepare_session
timeout=5)
File “D:\Anaconda\anaconda3\lib\site-packages\requests\api.py”, line 119, in post
return request(‘post’, url, data=data, json=json, **kwargs)
File “D:\Anaconda\anaconda3\lib\site-packages\requests\api.py”, line 61, in request
return session.request(method=method, url=url, **kwargs)
File “D:\Anaconda\anaconda3\lib\site-packages\requests\sessions.py”, line 530, in request
resp = self.send(prep, **send_kwargs)
File “D:\Anaconda\anaconda3\lib\site-packages\requests\sessions.py”, line 643, in send
r = adapter.send(request, **kwargs)
File “D:\Anaconda\anaconda3\lib\site-packages\requests\adapters.py”, line 504, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPConnectionPool(host=’replay.api.shinnytech.com’, port=80): Max retries exceeded with url: /t/rmd/replay/create_session (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x000001F49444D348>, ‘Connection to replay.api.shinnytech.com timed out. (connect timeout=5)’))
Task was destroyed but it is pending!
task: <Task pending coro=<TqBaseApi._windows_patch() running at D:\Anaconda\anaconda3\lib\site-packages\tqsdk\baseApi.py:116> cb=[TqBaseApi._on_task_done()]>
Task was destroyed but it is pending!
task: <Task pending coro=<TqApi._notify_watcher() running at D:\Anaconda\anaconda3\lib\site-packages\tqsdk\api.py:3617> cb=[TqBaseApi._on_task_done()]>
sys:1: RuntimeWarning: coroutine ‘TqBaseApi._windows_patch’ was never awaited
sys:1: RuntimeWarning: coroutine ‘TqApi._notify_watcher’ was never awaited
Process finished with exit code 1