shinnytech / tqsdk-python

天勤量化开发包, 期货量化, 实时行情/历史数据/实盘交易
https://doc.shinnytech.com/tqsdk/latest
Apache License 2.0
3.63k stars 650 forks source link

Error: Tianqin Api will lose websocket connection every night after 19:30 #493

Open zhengyoungzy opened 2 months ago

zhengyoungzy commented 2 months ago

Brief description of bug

The TQ Api will lose WSS connection every night after 19:30.

image

Unfortunately, it will raise an error in ops time and cause the asyncio loop to collapse. And there is no other parameter I can use to get the connection status of the WSS connection. To solve the problem currently, I have to restart the program every night.

Self-Diagnosis

Environment(for bug reports)

My configuration/Related code

import time
from datetime import datetime
from tqsdk import TqApi, TqAuth

tq_user = ''
tq_pwd = ''

tq_api = TqApi(auth=TqAuth(tq_user, tq_pwd))

tq_lst = tq_api.get_quote_list(['SHFE.au2504'])

print(tq_lst)

while True:
    tq_api.wait_update(deadline=time.time() + 2.0)

    dt = datetime.strptime(tq_lst[0]['datetime'], '%Y-%m-%d %H:%M:%S.%f')
    print(dt.timestamp())

Steps to Reproduce the Issue

  1. connect to TQ API
  2. no other network error before 19:00
  3. wait until 19:00

Current Result

连接失败,每日 19:00-19:30 为日常运维时间,请稍后再试