Optimize signal read paths and enforce score invariants
Deploy / lint (push) Successful in 7s
Deploy / test (push) Successful in 1m11s
Deploy / deploy (push) Successful in 37s

This commit is contained in:
2026-07-11 13:36:59 +02:00
parent fdc49d0e28
commit 25364f8e99
12 changed files with 357 additions and 35 deletions
+8 -1
View File
@@ -556,6 +556,9 @@ async def scan_all_tickers(
result = await db.execute(select(Ticker).order_by(Ticker.symbol))
tickers = list(result.scalars().all())
total = len(tickers)
# Ranking, score refresh, and setup detection repeatedly read the same
# immutable OHLCV series during one scan. Scope the cache to this run only.
db.info["ohlcv_cache"] = {}
# Rank the universe up front so each new setup carries both the residual
# activation gate percentile and the promoted production ordering score.
@@ -582,7 +585,6 @@ async def scan_all_tickers(
await scoring_service.compute_all_dimensions(db, ticker.symbol)
await scoring_service.compute_composite_score(db, ticker.symbol)
await db.commit()
except Exception:
logger.exception("Error refreshing scores for %s", ticker.symbol)
@@ -596,6 +598,11 @@ async def scan_all_tickers(
except Exception:
logger.exception("Error scanning ticker %s", ticker.symbol)
# scan_ticker commits successful setup writes. This final commit persists
# refreshed scores for tickers that produced no setup or hit a scan error.
await db.commit()
db.info.pop("ohlcv_cache", None)
if progress_callback is not None and total:
progress_callback(total, total, "")