From a1130ea43bf9df7718fdec5e27fa4f6bd33cf151 Mon Sep 17 00:00:00 2001 From: ao gong <41768719+ageorge156@users.noreply.github.com> Date: Fri, 21 Aug 2026 21:24:03 +0800 Subject: [PATCH] test: reject ambiguous duplicate rebalance dates --- tests/test_portfolio_construction.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_portfolio_construction.py b/tests/test_portfolio_construction.py index 43cd606..32756d2 100644 --- a/tests/test_portfolio_construction.py +++ b/tests/test_portfolio_construction.py @@ -130,6 +130,17 @@ def test_portfolio_construction_rejects_duplicate_assets() -> None: scores_to_target_weights(duplicate_scores, top_k=1) +def test_weight_table_rejects_duplicate_rebalance_dates() -> None: + duplicate_date = pd.Timestamp("2026-01-05") + scores = pd.DataFrame( + {"A": [1.0, 2.0]}, + index=[duplicate_date, duplicate_date], + ) + + with pytest.raises(ValueError, match="unique rebalance dates"): + scores_to_weight_table(scores, top_k=1) + + def test_weight_table_rejects_non_numeric_scores() -> None: scores = pd.DataFrame({"A": ["high"], "B": ["low"]})