feat: cycle

This commit is contained in:
OpenSquared
2026-07-15 14:59:11 +02:00
parent 2d474c9194
commit 16ccc7c2c7
6 changed files with 466 additions and 45 deletions

View File

@@ -495,14 +495,15 @@ def _to_event_dict(ev: Dict[str, Any]) -> Dict[str, Any]:
}
async def bootstrap_ma_events() -> Dict[str, Any]:
async def bootstrap_ma_events(force: bool = False) -> Dict[str, Any]:
"""
Main entrypoint. Detects MA ruptures, enriches with GPT, saves to DB.
Idempotent: skips if DB already has > 100 events.
Idempotent by default: skips if DB already has > 100 events. Pass force=True
to bypass this guard (same convention as bootstrap_macro_events/bootstrap_eco_events).
Returns {"detected": N, "saved": N, "skipped": N}.
"""
existing = count_market_events()
if existing > 100:
if existing > 100 and not force:
logger.info(f"[MA] DB already has {existing} events — skipping bootstrap")
return {"detected": 0, "saved": 0, "skipped": existing}