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
+6 -4
View File
@@ -710,18 +710,20 @@ class TestCheckRateLimitEdgeCases:
async def test_exactly_at_per_type_limit_allowed(self):
"""Count exactly equal to the limit should be allowed (only > limit blocks)."""
rds = _mock_redis()
limit = DEFAULT_RATE_LIMITS["news_api"]
# Use filings_api (not in POLYGON_SOURCE_TYPES) to isolate the per-type check
limit = DEFAULT_RATE_LIMITS["filings_api"]
rds.incr = AsyncMock(return_value=limit)
result = await check_rate_limit(rds, "news_api", _now())
result = await check_rate_limit(rds, "filings_api", _now())
assert result is True
@pytest.mark.asyncio
async def test_one_over_per_type_limit_blocked(self):
"""Count one over the limit should be blocked."""
rds = _mock_redis()
limit = DEFAULT_RATE_LIMITS["news_api"]
# Use filings_api (not in POLYGON_SOURCE_TYPES) to isolate the per-type check
limit = DEFAULT_RATE_LIMITS["filings_api"]
rds.incr = AsyncMock(return_value=limit + 1)
result = await check_rate_limit(rds, "news_api", _now())
result = await check_rate_limit(rds, "filings_api", _now())
assert result is False
@pytest.mark.asyncio