feat(notify): 支持钉钉多群推送 & 添加轮动策略核心逻辑文档
- settings.py: 新增 get_all_dingtalk_configs() 自动扫描所有钉钉群配置 - notify.py: 新增 send_to_all_groups() 多群推送函数 - daily_scheduler.py: 报告和错误通知改用多群推送 - .env: 添加第二个钉钉群配置 (DINGTALK_WEBHOOK_2/SECRET_2) - 轮动策略核心逻辑.md: 策略核心逻辑总结文档
This commit is contained in:
@@ -32,7 +32,7 @@ load_dotenv(project_root / ".env")
|
||||
from loguru import logger
|
||||
import schedule
|
||||
import tushare as ts
|
||||
from core.common.notify import DingTalkBot
|
||||
from core.common.notify import DingTalkBot, send_to_all_groups
|
||||
from core.common.oss_utils import upload_image_to_oss
|
||||
|
||||
# 配置日志
|
||||
@@ -163,8 +163,9 @@ def send_report_to_dingtalk(chart_path: str, summary_text: str = "") -> bool:
|
||||
|
||||
today_str = datetime.now().strftime("%Y-%m-%d")
|
||||
|
||||
# 发送图文消息
|
||||
success = bot.send_image_via_oss(
|
||||
# 向所有群发送图文消息
|
||||
success = send_to_all_groups(
|
||||
"send_image_via_oss",
|
||||
image_path=chart_path,
|
||||
title=f"ETF轮动策略调仓日报 ({today_str})",
|
||||
text=summary_text,
|
||||
@@ -226,8 +227,8 @@ def daily_task(config_path: str = "config/strategies/rotation.yaml"):
|
||||
|
||||
if not result["success"]:
|
||||
# 发送错误通知
|
||||
bot = DingTalkBot()
|
||||
bot.send_text(f"策略执行失败: {result.get('error', '未知错误')}")
|
||||
# 发送错误通知到所有群
|
||||
send_to_all_groups("send_text", content=f"策略执行失败: {result.get('error', '未知错误')}")
|
||||
return
|
||||
|
||||
# 3. 发送报告
|
||||
|
||||
Reference in New Issue
Block a user