Files
MoFin/mofin_collector.py
T

49 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""mofin_collector.py — 数据采集链:采集+检测+情报
在一个脚本内顺序跑完三件事:
1. market_watch — 拉90个板块实时数据
2. trend_detector — 检测17种信号
3. xiaoguo_news_processor — 搜新闻+LLM分析
"""
import os
import subprocess
import sys
from datetime import datetime
from pathlib import Path
BASE = Path(__file__).parent
def run_script(name):
path = BASE / name
print(f"[{datetime.now().strftime('%H:%M:%S')}] 开始: {name}", flush=True)
result = subprocess.run(
[sys.executable, str(path)],
capture_output=True, text=True, timeout=120
)
if result.returncode == 0:
for line in result.stdout.strip().split('\n'):
if line:
print(f" {line}", flush=True)
print(f"{name} 完成", flush=True)
else:
print(f"{name} 失败: {result.stderr[:200]}", flush=True)
return result.returncode
def main():
# 跳过午休
now = datetime.now()
hour = now.hour
minute = now.minute
if hour == 12 or (hour == 11 and minute > 30):
print("午休时间,跳过", flush=True)
return
run_script("market_watch.py")
run_script("trend_detector.py")
run_script("xiaoguo_news_processor.py")
if __name__ == "__main__":
main()