fix: ops pipeline — rate limit, validation cycle, snapshots, config query, rejection reason

- Polygon rate limit env-configurable, default 5 (free tier)
- v3_engine_enabled reads from JSONB config column correctly
- Validation cycle (outcome eval + metrics) wired into scheduler hourly
- Daily portfolio/risk snapshots after 16:30 ET with idempotency
- Prediction snapshot price fallback from positions table
- Order rejection_reason + rejected_at persisted on insert
- Lake-publisher scaled to 0 replicas (redundant)
- Test fix: isolate per-type rate limit tests from Polygon global
This commit is contained in:
Celes Renata
2026-07-03 08:29:24 +00:00
parent b70304ad6c
commit 14a9b4fcc1
6 changed files with 145 additions and 13 deletions
+13 -1
View File
@@ -311,7 +311,19 @@ async def create_prediction_snapshot(
# 1. Fetch prices — handle NULL gracefully (Requirement 1.5)
ticker_price = await fetch_latest_close_price(pool, ticker)
if ticker_price is None:
logger.warning("No market price available for %s at snapshot time", ticker)
# Fallback: try positions table for tickers we actively hold (Bug 1.8)
pos_row = await pool.fetchrow(
"SELECT current_price FROM positions "
"WHERE ticker = $1 AND current_price IS NOT NULL LIMIT 1",
ticker,
)
if pos_row:
ticker_price = float(pos_row["current_price"])
logger.info(
"Used positions fallback price for %s: %s", ticker, ticker_price
)
else:
logger.warning("No market price available for %s at snapshot time", ticker)
spy_price = await fetch_latest_close_price(pool, "SPY")
if spy_price is None: