Spaces:
Running
Running
File size: 1,087 Bytes
2eec8c3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | from __future__ import annotations
from typing import Any, Dict, Optional
def resolve_analysis_higher_timeframe(interval: str) -> Optional[str]:
if interval in {"1h", "4h"}:
return "1d"
if interval in {"5m", "15m"}:
return "1h"
return None
def build_analysis_endpoint_response(
*,
symbol: str,
interval: str,
timestamp: int,
analysis: Dict[str, Any],
verdict: str,
ai_rule_version: str,
ai_rule_count: int,
refresh_requested: bool,
indicators_snapshot: Optional[Dict[str, Any]],
) -> Dict[str, Any]:
response: Dict[str, Any] = {
"symbol": symbol,
"interval": interval,
"timestamp": timestamp,
"analysis": analysis,
"verdict": verdict,
"verdict_source": "local_rules",
"ai_rules": {
"version": ai_rule_version,
"loaded_count": ai_rule_count,
},
"cache": {"refresh_requested": refresh_requested},
"indicators_snapshot": indicators_snapshot,
}
response["generated_at"] = timestamp
return response
|