Spaces:
Sleeping
Sleeping
File size: 730 Bytes
49f1133 3a481ab 49f1133 3a481ab 49f1133 3a481ab 49f1133 3a481ab 49f1133 3a481ab | 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 | # economic_service.py
from typing import Dict
def harmonize(
commodity: str,
physical_anchor: float,
reporting_lag: int,
) -> Dict:
"""
Deterministic economic harmonization function.
"""
lag_factor = 1.0 + (reporting_lag * 0.005)
synthetic_index = physical_anchor / lag_factor
confidence = max(
0.0,
min(
1.0,
1.0 - abs(physical_anchor - synthetic_index)
/ (physical_anchor + 1e-9),
),
)
return {
"commodity": commodity,
"physical_anchor": physical_anchor,
"reporting_lag_days": reporting_lag,
"synthetic_index": round(synthetic_index, 4),
"confidence": round(confidence, 4),
} |