Spaces:
Sleeping
Sleeping
| import math | |
| from typing import Dict | |
| def harmonize_price(raw_price: float, physical_indicator: float, lag_factor: float) -> Dict[str, float]: | |
| """ | |
| Returns harmonized pricing with distortion and confidence. | |
| """ | |
| # Correction reduces false inflation from synthetic trading | |
| correction = (raw_price - physical_indicator) * min(1.0, lag_factor) | |
| harmonized = raw_price - correction | |
| confidence = 1.0 - abs(correction) / max(raw_price, 1) | |
| return { | |
| "raw_price": raw_price, | |
| "harmonized_price": round(harmonized, 4), | |
| "distortion": round(correction, 4), | |
| "confidence": round(max(0.0, min(confidence, 1.0)), 4) | |
| } |