"""Silver: raw continuous-front futures arrays -> canonical BarRecords. Reuses the loader's
ratio-back-adjustment (continuous_front_adjust) so there is one implementation of the roll math."""
from __future__ import annotations

import numpy as np

from fxhnt.adapters.data.dbn_local import continuous_front_adjust
from fxhnt.domain.warehouse.bar import BarRecord


def normalize_futures(symbol: str, days: np.ndarray, inst: np.ndarray, close: np.ndarray,
                      high: np.ndarray, low: np.ndarray) -> list[BarRecord]:
    syn_close, syn_high, syn_low = continuous_front_adjust(inst, close, high, low)
    return [BarRecord(symbol=symbol, ts=int(d) * 86_400, close=float(c), high=float(h), low=float(lo))
            for d, c, h, lo in zip(days, syn_close, syn_high, syn_low, strict=True)]
