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
+7 -4
View File
@@ -316,19 +316,22 @@ async def fetch_probabilistic_scoring_enabled(pool: asyncpg.Pool) -> bool:
# ---------------------------------------------------------------------------
_V3_ENGINE_FLAG_QUERY = """
SELECT value FROM risk_configs WHERE key = 'v3_engine_enabled'
SELECT config->>'v3_engine_enabled' AS enabled
FROM risk_configs
WHERE name = 'default' AND active = TRUE
LIMIT 1
"""
async def _read_v3_flag(pool: asyncpg.Pool) -> bool:
"""Read v3_engine_enabled from risk_configs. Default False on error.
"""Read v3_engine_enabled from risk_configs JSONB. Default False on error.
Requirements: 19.3, 19.6
"""
try:
row = await pool.fetchrow(_V3_ENGINE_FLAG_QUERY)
if row:
return str(row["value"]).lower() in ("true", "1", "yes")
if row and row["enabled"] is not None:
return row["enabled"].lower() in ("true", "1", "yes")
return False
except Exception as e:
logger.warning("Failed to read v3_engine_enabled flag: %s", e)