File size: 665 Bytes
f2851cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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)
    }