mirror of
https://github.com/QuantEngines/fx_quant_engine.git
synced 2026-07-28 02:47:50 +00:00
24 lines
924 B
Python
24 lines
924 B
Python
import numpy as np
|
|
import pandas as pd
|
|
|
|
from fx_quant_engine.models.relative_value import RelativeValueModel
|
|
|
|
|
|
def test_relative_value_model_outputs_hedge_ratio_and_score() -> None:
|
|
idx = pd.date_range("2025-01-01", periods=120, freq="B")
|
|
base = np.linspace(100, 110, len(idx))
|
|
a = pd.Series(base + np.sin(np.arange(len(idx)) * 0.2), index=idx)
|
|
b = pd.Series(base * 0.8 + np.cos(np.arange(len(idx)) * 0.2), index=idx)
|
|
|
|
fa = pd.DataFrame({"momentum_multi_horizon": 0.2, "carry_proxy": 0.01}, index=idx)
|
|
fb = pd.DataFrame({"momentum_multi_horizon": -0.1, "carry_proxy": -0.02}, index=idx)
|
|
|
|
model = RelativeValueModel(lookback=60)
|
|
rv = model.generate("USDINR", "EURINR", a, b, fa, fb)
|
|
|
|
assert 0.0 <= rv.score <= 1.0
|
|
assert abs(rv.hedge_ratio) > 0.0
|
|
assert rv.long_asset in {"USDINR", "EURINR"}
|
|
assert rv.short_asset in {"USDINR", "EURINR"}
|
|
assert "hedge_ratio" in rv.drivers
|