# -*- coding: utf-8 -*- """Unit tests: baseline forecasters.""" import numpy as np from src.baselines import NaiveBaseline, NaiveConfig, DriftBaseline, DriftConfig from src.forecasting.target import ForecastContext from src.forecasting.interface import Series def _ctx(): return ForecastContext(symbol="XAUUSD", timeframe="H1", horizon=10, atr_period=20) def test_naive_random_walk_neutral(): close = np.arange(1, 101, dtype=float) s = Series(symbol="XAUUSD", timeframe="H1", timestamp=[f"t{i}" for i in range(100)], open=list(close), high=list(close + 0.5), low=list(close - 0.5), close=list(close)) rec = NaiveBaseline(NaiveConfig()).forecast(s, 50, _ctx()) assert rec.normalized_expected_return == 0.0 assert rec.forecast_direction == "NEUTRAL" def test_drift_directional_on_up_trend(): close = np.cumsum(np.full(120, 0.1)) + 100.0 s = Series(symbol="XAUUSD", timeframe="H1", timestamp=[f"t{i}" for i in range(120)], open=list(close), high=list(close + 0.5), low=list(close - 0.5), close=list(close)) rec = DriftBaseline(DriftConfig(lookback=40)).forecast(s, 90, _ctx()) assert rec.normalized_expected_return is not None assert rec.normalized_expected_return > 0 assert rec.forecast_direction == "LONG"