fix: 全面系统修复 — delivery目标修正 + 脚本同步 + refresh_mtf_cache import修复 + clean_watchlist硬编码修复
修复清单: - cron delivery修正:10个job从deliver=origin/all改为local,消除推送错误 - refresh_mtf_cache.py:替换strategy_lifecycle.PORTFOLIO_PATH导入为mofin_db直接读DB - clean_watchlist.py:修复mo_data导入名错误和JSON硬编码路径 - MoFin/scripts/与profile scripts互相补全,双向sync到一致 - price_monitor.py:现金源从portfolio_summary表改为cash_log(Dad确认的现金权威) - 更新watchlist.json加入000850华茂股份
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python3
|
||||
"""inject_xiaoguo_insight.py — 将小果情感分析结果注入 market.json
|
||||
|
||||
时序:market_watch(15:30) → market_insight(15:35) → xiaoguo_analyst(16:00) → 本脚本(16:05)
|
||||
|
||||
读取 xiaoguo_insights.json 的情感分析结果,注入到 market.json 的 insights 字段
|
||||
"""
|
||||
|
||||
import json
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
DATA_DIR = Path(__file__).parent / "data"
|
||||
|
||||
|
||||
def inject():
|
||||
market_path = DATA_DIR / "market.json"
|
||||
xiaoguo_path = DATA_DIR / "xiaoguo_insights.json"
|
||||
|
||||
if not xiaoguo_path.exists():
|
||||
print("xiaoguo_insights.json 不存在,跳过")
|
||||
return
|
||||
|
||||
with open(xiaoguo_path, "r", encoding="utf-8") as f:
|
||||
xiaoguo = json.load(f)
|
||||
|
||||
analyses = xiaoguo.get("analyses", [])
|
||||
if not analyses:
|
||||
print("小果分析为空,跳过")
|
||||
return
|
||||
|
||||
with open(market_path, "r", encoding="utf-8") as f:
|
||||
market = json.load(f)
|
||||
|
||||
insights = market.get("insights", [])
|
||||
|
||||
# 注入情感分析结果
|
||||
for a in analyses:
|
||||
name = a.get("name", "")
|
||||
sentiment = a.get("sentiment", "neutral")
|
||||
confidence = a.get("confidence", 0)
|
||||
brief = a.get("brief", "")
|
||||
sentiment_emoji = {"positive": "", "negative": "", "neutral": ""}.get(
|
||||
sentiment, ""
|
||||
)
|
||||
label = {"positive": "利好", "negative": "利空", "neutral": "中性"}.get(
|
||||
sentiment, "中性"
|
||||
)
|
||||
|
||||
if brief:
|
||||
insights.append(
|
||||
f"[小果]{name}: {label}(置信度{confidence:.0%}) — {brief}"
|
||||
)
|
||||
|
||||
market["insights"] = insights
|
||||
market["xiaoguo_timestamp"] = xiaoguo.get("timestamp", "")
|
||||
|
||||
with open(market_path, "w", encoding="utf-8") as f:
|
||||
json.dump(market, f, ensure_ascii=False, indent=2)
|
||||
|
||||
print(f"注入{len(analyses)}条小果分析到 market.json")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
inject()
|
||||
Reference in New Issue
Block a user