Files
xxm c68f987653 chore(cleansweep): 代码大扫除——归档hermes 111个死工具+4个废弃scanner,收敛MoFin/scripts重复副本,删除根旧版mo_models
- archive/hermes-dead-tools-20260820/: hermes独有不在cron不被import的111个一次性排查/测试工具
- archive/hermes-dead-tools-20260820/: 4个废弃scanner(btd1_v3/market_scanner/market_thermometer已废弃/s2v2)
- archive/legacy-cleanup-20260820/: MoFin根2旧版(mo_models/technical_analysis)+/home/hmo/scripts无引用旧项目+MoFin/scripts重复prepare_report_data
- 删除MoFin根mo_models.py(根旧版,deploy/profile-scripts权威保留)
- 保留: mofin_db.py/mo_data.py硬链接(server.py多层sys.path需各目录访问同一inode,非冗余)
- fix_gateway.py保留(Gateway看门狗fix_gateway_port.py的活跃依赖,勿误删)
- 验证: cron所有脚本引用无缺失, key模块import正常
- hermes独有从116收敛到5核心(alert_logger/market_screener/prepare_report_data/self_todo_executor_v2/xmpp_zhiwei_bot)
2026-08-20 10:36:25 +08:00

94 lines
2.7 KiB
Python

#!/usr/bin/env python3
import json
import subprocess
import sys
import os
from datetime import datetime
# 读取持仓数据
with open('data/portfolio.json', 'r') as f:
portfolio = json.load(f)
# 读取决策数据
with open('data/decisions.json', 'r') as f:
decisions_data = json.load(f)
# 获取所有持仓股票
holdings = portfolio['holdings']
active_holdings = [h for h in holdings if h.get('shares', 0) > 0]
print(f"持仓股票数量: {len(active_holdings)}")
# 获取实时价格 - 使用curl调用API
# 注意:这里需要根据实际情况调整API调用
realtime_prices = {}
for holding in active_holdings:
code = holding['code']
name = holding['name']
# 判断市场类型
# 港股代码5位数字(如01211),优先判断
if len(code) == 5: # 港股
market = 'hk'
price = holding['price']
change_pct = holding.get('change_pct', 0)
realtime_prices[code] = {
'name': name,
'price': price,
'change_pct': change_pct,
'market': 'HK'
}
elif code.startswith('6'): # 沪市
market = 'sh'
price = holding['price']
change_pct = holding.get('change_pct', 0)
realtime_prices[code] = {
'name': name,
'price': price,
'change_pct': change_pct,
'market': 'A'
}
elif code.startswith('0') or code.startswith('3'): # 深市
market = 'sz'
price = holding['price']
change_pct = holding.get('change_pct', 0)
realtime_prices[code] = {
'name': name,
'price': price,
'change_pct': change_pct,
'market': 'A'
}
else:
# 其他类型
price = holding['price']
change_pct = holding.get('change_pct', 0)
realtime_prices[code] = {
'name': name,
'price': price,
'change_pct': change_pct,
'market': 'OTHER'
}
# 获取活跃决策
active_decisions = [d for d in decisions_data['decisions'] if d.get('status') == 'active']
print(f"活跃决策数量: {len(active_decisions)}")
# 输出结果
print("\n=== 实时价格数据 ===")
for code, data in realtime_prices.items():
print(f"{code} {data['name']}: {data['price']} ({data['change_pct']:+.2f}%)")
# 保存到临时文件供后续使用
output_data = {
'timestamp': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
'prices': realtime_prices,
'holdings': active_holdings,
'active_decisions': active_decisions
}
with open('data/temp_realtime.json', 'w') as f:
json.dump(output_data, f, indent=2, ensure_ascii=False)
print(f"\n数据已保存到 data/temp_realtime.json")