"""continuous_front_adjust is the pure ratio-back-adjustment shared by the loader and the silver layer."""
from __future__ import annotations

import numpy as np

from fxhnt.adapters.data.dbn_local import continuous_front_adjust


def test_continuous_front_adjust_books_zero_return_on_roll() -> None:
    inst = np.array([10, 10, 20], dtype=np.int64)      # roll between day 1 and day 2
    close = np.array([100.0, 102.0, 50.0])             # day 2 is a different contract level
    high = np.array([101.0, 103.0, 51.0])
    low = np.array([99.0, 101.0, 49.0])
    syn_close, syn_high, syn_low = continuous_front_adjust(inst, close, high, low)
    assert syn_close[2] == syn_close[1]                # roll -> flat synthetic level (no gap)
    assert syn_high[2] / syn_close[2] == 51.0 / 50.0   # intraday range preserved proportionally
    assert syn_low[2] / syn_close[2] == 49.0 / 50.0
    assert syn_high[0] >= syn_close[0] >= syn_low[0]
