feat: cycle
This commit is contained in:
@@ -175,3 +175,23 @@ def format_indicators_for_prompt(indicators: dict) -> str:
|
||||
if "error" in indicators:
|
||||
return ""
|
||||
return indicators.get("prompt_block", "")
|
||||
|
||||
|
||||
def compute_and_save_indicators(horizon_days: int = 45) -> dict:
|
||||
"""Cycle Actions — standalone "compute-indicators" action. compute_indicators()
|
||||
itself is pure (no persistence) — this loops the watchlist and persists each
|
||||
result into instrument_indicators (which nothing else reads from yet; this is
|
||||
an inspection snapshot, not a cache other steps depend on)."""
|
||||
from services.database import get_instruments_watchlist, save_instrument_indicators
|
||||
|
||||
tickers = [w["ticker"] for w in get_instruments_watchlist()]
|
||||
computed = 0
|
||||
failed = []
|
||||
for ticker in tickers:
|
||||
result = compute_indicators(ticker, horizon_days=horizon_days)
|
||||
if "error" in result:
|
||||
failed.append(ticker)
|
||||
continue
|
||||
save_instrument_indicators(ticker, horizon_days, result)
|
||||
computed += 1
|
||||
return {"tickers_computed": computed, "failed": failed, "horizon_days": horizon_days}
|
||||
|
||||
Reference in New Issue
Block a user