MAIDR Documentation - v3.73.0
    Preparing search index...
    • Rounds a delta to suppress binary floating-point noise (e.g. 0.30000000000000004) so exactly-on-the-line points compare equal to zero.

      Float noise scales with operand magnitude, so a fixed absolute grid is wrong at both extremes: a fixed raw * 1e9 round overflows Number.MAX_SAFE_INTEGER for large-priced instruments (e.g. crypto quoted above ~9e6, where the round loses all precision), and a 1e-9 absolute grid over-suppresses genuine tiny deltas on small-priced ones. Instead, snap to zero with a tolerance relative to the operand magnitude — values that agree to ~9 significant figures (typical financial display precision) are treated as "on the line" — then round survivors to 9 significant figures.

      Parameters

      • raw: number

        The raw difference between the OHLC value and the reference

      • magnitude: number = 0

        The larger operand magnitude, used to scale the tolerance (defaults to 0, which floors the tolerance at an absolute 1e-9)

      Returns number

      The cleaned delta