fix: 补全 small_cap_strategy.py 缺失的 logger 定义#29
Open
DrIsDr wants to merge 1 commit into
Open
Conversation
SmallCapStrategy 和 SmallCapStrategyV2 中使用了 logger.info, 但模块未导入 logging 也未定义 logger,导致实例化时抛出 NameError。
There was a problem hiding this comment.
Pull request overview
修复 easyxt_backtest/strategies/small_cap_strategy.py 中模块级 logger 未定义导致的 NameError,使 SmallCapStrategy / SmallCapStrategyV2 在实例化与运行时可正常记录日志并避免回测示例脚本报错。
Changes:
- 在
small_cap_strategy.py顶部补充import logging。 - 定义模块级
logger = logging.getLogger(__name__)供策略内部日志调用使用。
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复
SmallCapStrategy/SmallCapStrategyV2实例化时因未定义logger而抛出的NameError。问题复现:运行
学习实例/04_策略回测.py时,在lesson_3_practical_demo中实例化SmallCapStrategy会触发:修复方式:在模块顶部参照
grid_strategy.py和technical.py的写法,补全:已在本地验证:实例化
SmallCapStrategy()不再报错。