Files
worldquant-alpha-system/backend/app/platform_checks.py
T

30 lines
1.3 KiB
Python

"""Classify platform evidence without discarding unknown checks or inferring eligibility."""
def check_result(check):
"""Normalize known upstream result casing without rewriting the raw evidence."""
value = check.get("result") if isinstance(check, dict) else None
return value.upper() if isinstance(value, str) else None
def is_submission_limit(check):
"""Recognize only the confirmed account-limit check; unknown names remain Alpha checks."""
return isinstance(check, dict) and check.get("name") == "REGULAR_SUBMISSION"
def split_checks(checks):
"""Return Alpha checks and submission limits, retaining malformed Alpha evidence."""
items = checks if isinstance(checks, list) else []
return ([c for c in items if not is_submission_limit(c)],
[c for c in items if is_submission_limit(c)])
def submission_limits(checks):
"""Summarize the observed limit, never the account's current allowance or reset time."""
_, limits = split_checks(checks)
status = "blocked" if any(check_result(c) == "FAIL" for c in limits) else (
"not_blocked" if limits and all(check_result(c) == "PASS" for c in limits) else "unknown"
)
return {"status": status, "checks": limits,
"meaning": "仅反映缓存观测时的提交限制,不代表当前额度或正式提交资格"}