#!/usr/bin/env python3 """Свод источников исследования 5м-стратегий: объединение 5 направлений + выборка «что брать в бэктест».""" import glob import json import os D = "/opt/data/work/5m_research/directions" OUT = "/opt/data/work/5m_research/sources/ALL_SOURCES.json" all_src = [] for path in sorted(glob.glob(os.path.join(D, "*.json"))): direction = os.path.basename(path).replace(".json", "") try: items = json.load(open(path, encoding="utf-8")) except Exception as e: print(f"{direction}: НЕ ЧИТАЕТСЯ ({e})") continue for it in items: if isinstance(it, dict): it["direction"] = direction all_src.append(it) print(f"{direction}: {len(items)} источников") os.makedirs(os.path.dirname(OUT), exist_ok=True) json.dump(all_src, open(OUT, "w", encoding="utf-8"), ensure_ascii=False, indent=1) print(f"\nВСЕГО: {len(all_src)} источников → {OUT}") impl = [s for s in all_src if str(s.get("implementable")).lower() not in ("false", "none", "", "no")] print(f"\n=== потенциально применимые ({len(impl)}) ===") for s in impl: print(f"- [{s.get('direction')}] {str(s.get('title'))[:80]} ({s.get('year')}) | " f"горизонт: {str(s.get('horizon'))[:30]} | издержки: {str(s.get('costs_assumed'))[:40]} | " f"вердикт: {str(s.get('verdict'))[:90]}")