-
Notifications
You must be signed in to change notification settings - Fork 687
[Tqsdk-Ci] Update Version 3.7.6 #499
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
Conversation
📝 Walkthrough📝 WalkthroughWalkthrough此次更改主要涉及 Changes
Possibly related PRs
Suggested reviewers
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
tqsdk/tradeable/otg/tqrohon.py (1)
25-25
: 建议修改示例中的服务器地址文档中增加格式说明很有帮助,但建议将示例IP地址替换为示例域名或保留地址(如 192.0.2.0/24 范围内的地址)。
建议修改为:
- front_url (str): 融航柜台地址,格式为 tcp://ip:port,如 tcp://129.211.138.170:10001 + front_url (str): 融航柜台地址,格式为 tcp://ip:port,如 tcp://192.0.2.100:10001tqsdk/tradeable/otg/tqjees.py (1)
25-25
: 文档改进很好,建议增加参数格式验证文档中明确指定了
front_url
参数的格式要求,这对用户很有帮助。不过建议添加参数格式验证,以确保用户输入的 URL 符合要求。建议添加如下格式验证代码:
def __init__(self, account_id: str, password: str, front_broker: str, front_url: str, app_id: str, auth_code: str) -> None: + if not front_url.startswith('tcp://') or ':' not in front_url.split('/')[-1]: + raise ValueError("front_url 格式错误,应为 tcp://ip:port,如 tcp://129.211.138.170:10001") self._account_id = account_id self._front_broker = front_broker self._front_url = front_urldoc/version.rst (1)
Line range hint
1-24
: 建议优化版本历史文档的结构当前文档结构采用了按时间倒序排列的方式记录版本历史,建议考虑:
- 为每个主要版本(如 3.x)添加一个小节标题,便于快速导航
- 对重大更新添加更详细的说明和升级指南
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (10)
PKG-INFO
(1 hunks)doc/conf.py
(1 hunks)doc/version.rst
(1 hunks)setup.py
(1 hunks)tqsdk/__version__.py
(1 hunks)tqsdk/connect.py
(5 hunks)tqsdk/tradeable/otg/tqctp.py
(1 hunks)tqsdk/tradeable/otg/tqjees.py
(1 hunks)tqsdk/tradeable/otg/tqrohon.py
(1 hunks)tqsdk/tradeable/otg/tqyida.py
(1 hunks)
✅ Files skipped from review due to trivial changes (3)
- PKG-INFO
- setup.py
- tqsdk/version.py
🔇 Additional comments (10)
tqsdk/tradeable/otg/tqyida.py (1)
23-23
: 文档改进很好!
参数格式说明更加清晰具体,添加实际示例有助于用户正确使用接口。
tqsdk/tradeable/otg/tqctp.py (2)
25-25
: 文档改进清晰明确!
参数格式说明的补充很有帮助,使API更易于使用。
25-25
: 建议验证示例IP地址的使用
请确认文档中使用的示例IP地址(129.211.138.170)是否适合公开展示。建议考虑使用示例IP(如:192.0.2.0/24 范围内的地址)来避免暴露实际服务器地址。
doc/conf.py (1)
51-51
: 版本号更新正确!
版本号从 3.7.4 更新至 3.7.5 的修改符合预期。
运行以下脚本以验证版本号在所有相关文件中的一致性:
Also applies to: 53-53
✅ Verification successful
版本号已在所有相关文件中保持一致
经验证,版本号 3.7.5 在以下文件中均保持一致:
- setup.py
- PKG-INFO
- tqsdk/version.py
- doc/conf.py
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 描述:验证版本号在各个文件中是否一致
echo "检查各文件中的版本号:"
echo "1. setup.py 中的版本号:"
rg -A 1 "version\s*=" setup.py
echo "2. PKG-INFO 中的版本号:"
rg "^Version:" PKG-INFO
echo "3. tqsdk/__version__.py 中的版本号:"
cat tqsdk/__version__.py
echo "4. doc/conf.py 中的版本号:"
rg "version\s*=\s*u'[\d.]+'" doc/conf.py
Length of output: 615
doc/version.rst (1)
5-9
: 版本更新内容清晰明确
版本 3.7.5 的更新内容记录完整,包含了:
- 修复了与 websockets 14.0 版本的兼容性问题
- 补充了多个类的 front_url 示例文档
tqsdk/connect.py (5)
20-21
: 模块导入正确,确保版本兼容性
引入了websockets.exceptions
和version
模块,为后续的版本判断和异常处理奠定了基础。
47-48
: 使用packaging
模块解析版本号,准确判断websockets
版本
通过version.parse
解析websockets
库的版本号,确保了版本比较的准确性,有利于兼容不同版本的库。
62-72
: 根据websockets
版本定义异常类,保障异常处理的兼容性
针对websockets
14.0以上和以下的版本,分别定义了websocket_expect_exc
异常元组,确保在不同版本下都能正确捕获相关异常。
100-107
: 根据websockets
版本调整连接参数,确保连接建立的正确性
在websockets
14.0及以上版本中,使用了additional_headers
和process_exception
等新参数,并适当处理user_agent_header
,以适应新版本的API变化,保证了WebSocket连接的正确建立。
190-190
: 异常处理逻辑更新,兼容不同版本的websockets
异常类型
在异常捕获中使用了websocket_expect_exc
动态元组,结合其他常见异常类型,确保在连接过程中出现异常时能够被正确捕获并处理。
f171c16
to
a12c241
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
tqsdk/connect.py (2)
100-107
: 连接参数更新合理,建议添加注释说明版本差异!代码正确处理了 websockets 14.0 版本的参数变化,但建议添加注释说明不同版本参数的具体差异,以便后续维护。
建议添加如下注释:
if websocket_version_ge_14: + # websockets >= 14.0 使用 additional_headers 替代 extra_headers + # user_agent_header 设为 None 以避免重复,因为 base_headers 已包含 self._keywords["additional_headers"] = self._api._base_headers self._keywords["user_agent_header"] = None self._keywords["process_exception"] = lambda exc: exc else: + # websockets < 14.0 使用 extra_headers self._keywords["extra_headers"] = self._api._base_headers
190-190
: 异常处理完善,建议增强日志记录!异常处理逻辑完善,包含了维护时间窗口的检查。建议在捕获异常时添加更详细的日志记录,以便问题排查。
建议在异常处理中添加更详细的日志:
-except websocket_expect_exc + (asyncio.TimeoutError, OSError, EOFError, TqBacktestPermissionError) as e: +except websocket_expect_exc + (asyncio.TimeoutError, OSError, EOFError, TqBacktestPermissionError) as e: + self._logger.error("websocket connection error", + error_type=type(e).__name__, + error_msg=str(e), + url=url, + in_ops_time=in_ops_time)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (12)
PKG-INFO
(1 hunks)doc/conf.py
(1 hunks)doc/profession.rst
(0 hunks)doc/version.rst
(1 hunks)setup.py
(2 hunks)tqsdk/__version__.py
(1 hunks)tqsdk/api.py
(0 hunks)tqsdk/connect.py
(5 hunks)tqsdk/tradeable/otg/tqctp.py
(1 hunks)tqsdk/tradeable/otg/tqjees.py
(1 hunks)tqsdk/tradeable/otg/tqrohon.py
(1 hunks)tqsdk/tradeable/otg/tqyida.py
(1 hunks)
💤 Files with no reviewable changes (2)
- doc/profession.rst
- tqsdk/api.py
🚧 Files skipped from review as they are similar to previous changes (9)
- PKG-INFO
- doc/conf.py
- doc/version.rst
- setup.py
- tqsdk/version.py
- tqsdk/tradeable/otg/tqctp.py
- tqsdk/tradeable/otg/tqjees.py
- tqsdk/tradeable/otg/tqrohon.py
- tqsdk/tradeable/otg/tqyida.py
🔇 Additional comments (1)
tqsdk/connect.py (1)
20-21
: 版本兼容性处理得当!
代码通过 packaging
库优雅地处理了 websockets 14.0 版本的兼容性问题,并根据不同版本正确定义了异常处理元组。
Also applies to: 47-48, 62-72
Automated changes by create-pull-request GitHub action
Summary by CodeRabbit
新特性
query_symbol_settlement
、query_symbol_ranking
、query_options
和query_all_level_options
,增强了API的功能。文档
错误修复