refactor(notify): 将通知模块从归档移至正式位置

- 将 notify.py 和 oss_utils.py 从 archive/legacy_core 移至 core/common/
- 内联钉钉配置读取函数,移除对 config.settings 的依赖
- 删除 config/ 目录(settings.py 不再需要)
- daily_scheduler.py 移除归档路径的 sys.path hack
- 新增 --no-detail 和 --no-report 命令行参数控制导出
- 全标的排名表新增退场日期和退场价格列
This commit is contained in:
2026-06-08 22:34:03 +08:00
parent c32ce72579
commit 844e609ff7
6 changed files with 898 additions and 82 deletions

View File

@@ -30,10 +30,6 @@ from pathlib import Path
project_root = Path(__file__).parent.parent
sys.path.insert(0, str(project_root))
# 添加归档模块路径(使用原有的 notify 和 oss_utils
archive_path = project_root / 'archive' / 'legacy_core'
sys.path.insert(0, str(archive_path))
# 加载环境变量
from dotenv import load_dotenv
load_dotenv()
@@ -154,7 +150,7 @@ def run_strategy(config_path: str = "strategies/rotation/config.yaml") -> dict:
return {"success": False, "error": str(e)}
def run_simple_rotation(config_path: str = None) -> dict:
def run_simple_rotation(config_path: str = None, no_detail: bool = False, no_report: bool = False) -> dict:
"""
执行 simple_rotation.py 策略回测并生成报告
@@ -173,6 +169,10 @@ def run_simple_rotation(config_path: str = None) -> dict:
]
if config_path:
cmd.extend(["--config", config_path])
if no_detail:
cmd.append("--no-detail")
if no_report:
cmd.append("--no-report")
logger.info(f"执行命令: {' '.join(cmd)}")
@@ -284,7 +284,9 @@ def setup_schedule(target_time: str = "15:30",
def daily_task(config_path: str = "strategies/rotation/config.yaml",
strategy: str = "all",
simple_config: str = None):
simple_config: str = None,
no_detail: bool = False,
no_report: bool = False):
"""
每日任务主流程
@@ -305,7 +307,7 @@ def daily_task(config_path: str = "strategies/rotation/config.yaml",
# 2. 执行 Simple Rotation 策略
if strategy in ("simple", "all"):
result = run_simple_rotation(simple_config)
result = run_simple_rotation(simple_config, no_detail=no_detail, no_report=no_report)
if result["success"]:
if result.get("chart_path"):
send_report_to_dingtalk(
@@ -384,6 +386,16 @@ def main():
action='store_true',
help='非后台模式:执行一次后进入定时循环(测试用)'
)
parser.add_argument(
'--no-detail',
action='store_true',
help='跳过 detail JSON 导出(加速日常运行)'
)
parser.add_argument(
'--no-report',
action='store_true',
help='跳过 report PNG 生成'
)
args = parser.parse_args()
@@ -392,12 +404,12 @@ def main():
if args.now:
# 立即执行一次并退出
daily_task(args.config, args.strategy, args.simple_config)
daily_task(args.config, args.strategy, args.simple_config, args.no_detail, args.no_report)
elif args.no_daemon:
# 非后台模式:执行一次后进入定时循环
setup_schedule(args.time, args.config, args.strategy, args.simple_config)
logger.info("执行一次测试...")
daily_task(args.config, args.strategy, args.simple_config)
daily_task(args.config, args.strategy, args.simple_config, args.no_detail, args.no_report)
logger.info("测试完成启动定时任务循环Ctrl+C 停止)...")
run_scheduler_loop()
else: