Skip to content

fix: 补全 small_cap_strategy.py 缺失的 logger 定义#29

Open
DrIsDr wants to merge 1 commit into
quant-king299:mainfrom
DrIsDr:fix-small-cap-strategy-logger
Open

fix: 补全 small_cap_strategy.py 缺失的 logger 定义#29
DrIsDr wants to merge 1 commit into
quant-king299:mainfrom
DrIsDr:fix-small-cap-strategy-logger

Conversation

@DrIsDr

@DrIsDr DrIsDr commented Jul 11, 2026

Copy link
Copy Markdown

修复 SmallCapStrategy / SmallCapStrategyV2 实例化时因未定义 logger 而抛出的 NameError

问题复现:运行 学习实例/04_策略回测.py 时,在 lesson_3_practical_demo 中实例化 SmallCapStrategy 会触发:

NameError: name 'logger' is not defined

修复方式:在模块顶部参照 grid_strategy.pytechnical.py 的写法,补全:

import logging

logger = logging.getLogger(__name__)

已在本地验证:实例化 SmallCapStrategy() 不再报错。

SmallCapStrategy 和 SmallCapStrategyV2 中使用了 logger.info,
但模块未导入 logging 也未定义 logger,导致实例化时抛出 NameError。
Copilot AI review requested due to automatic review settings July 11, 2026 00:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants