Optimize signal read paths and enforce score invariants
This commit is contained in:
@@ -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, "")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user