Skip to content

Update api.py #484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tqsdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class TqApi(TqBaseApi):
"""

def __init__(self, account: Optional[Union[TqMultiAccount, UnionTradeable]] = None,
auth: Union[TqAuth, str, None] = None,
auth: Union[TqAuth, str, None] = None,deadline: Optional[float] = 60,
url: Optional[str] = None, backtest: Union[TqBacktest, TqReplay, None] = None,
web_gui: Union[bool, str] = False, debug: Union[bool, str, None] = None,
loop: Optional[asyncio.AbstractEventLoop] = None, disable_print: bool = False, _stock: bool = True,
Expand Down Expand Up @@ -290,12 +290,12 @@ def __init__(self, account: Optional[Union[TqMultiAccount, UnionTradeable]] = No
self._setup_connection() # 初始化通讯连接

# 等待初始化完成
deadline = time.time() + 60
_deadline = time.time() + deadline
try:
# 多账户时,所有账户需要初始化完成
trade_more_data = True
while self._data.get("mdhis_more_data", True) or trade_more_data:
if not self.wait_update(deadline=deadline): # 等待连接成功并收取截面数据
if not self.wait_update(_deadline=deadline): # 等待连接成功并收取截面数据
Copy link

@coderabbitai coderabbitai bot May 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait_update 方法调用中,应将参数名从 _deadline 改为 deadline,以保持一致性和清晰性。

- if not self.wait_update(_deadline=deadline):
+ if not self.wait_update(deadline=_deadline):

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
_deadline = time.time() + deadline
try:
# 多账户时,所有账户需要初始化完成
trade_more_data = True
while self._data.get("mdhis_more_data", True) or trade_more_data:
if not self.wait_update(deadline=deadline): # 等待连接成功并收取截面数据
if not self.wait_update(_deadline=deadline): # 等待连接成功并收取截面数据
_deadline = time.time() + deadline
try:
# 多账户时,所有账户需要初始化完成
trade_more_data = True
while self._data.get("mdhis_more_data", True) or trade_more_data:
if not self.wait_update(deadline=_deadline): # 等待连接成功并收取截面数据

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

写错了。。。 SORRY

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WangJieCIFCO, no worries at all! If there's anything else you need help with or if you have further modifications, feel free to let me know. I'm here to help! 😊

raise TqTimeoutError("接收数据超时,请检查客户端及网络是否正常")
trade_more_data = self._account._get_trade_more_data(self._data)
except:
Expand Down