77from okama .common .helpers import rebalancing as rb
88
99
10- @mark .rebalance
1110def test_validate_period_failing ():
1211 with pytest .raises (ValueError ):
1312 ok .Rebalance (period = "not existing" )
1413
1514
16- @mark .rebalance
1715def test_validate_abs_deviation_big_failing ():
1816 with pytest .raises (ValueError , match = r"Absolute deviation must be less or equal to 1." ):
1917 ok .Rebalance (abs_deviation = 1.5 )
2018
2119
22- @mark .rebalance
2320def test_validate_abs_deviation_small_failing ():
2421 with pytest .raises (ValueError , match = r"Absolute deviation must be positive." ):
2522 ok .Rebalance (abs_deviation = - 100 )
2623
2724
28- @mark .rebalance
2925def test_validate_rel_deviation_failing ():
3026 with pytest .raises (ValueError , match = r"Relative deviation must be positive." ):
3127 ok .Rebalance (rel_deviation = - 100 )
@@ -56,7 +52,6 @@ def test_rebalance_by_condition_events_with_mock(mocker):
5652 assert (res .events == "abs" ).any ()
5753
5854
59- @mark .rebalance
6055def test_check_if_rebalancing_required_series_abs ():
6156 # Series: trigger by absolute deviation
6257 r = ok .Rebalance (period = "none" , abs_deviation = 0.05 )
@@ -69,7 +64,6 @@ def test_check_if_rebalancing_required_series_abs():
6964 assert cond_abs is True
7065
7166
72- @mark .rebalance
7367def test_check_if_rebalancing_required_series_rel ():
7468 # Series: trigger only by relative deviation
7569 r = ok .Rebalance (period = "none" , rel_deviation = 0.08 )
@@ -82,7 +76,6 @@ def test_check_if_rebalancing_required_series_rel():
8276 assert cond_abs is False
8377
8478
85- @mark .rebalance
8679def test_check_if_rebalancing_required_series_no_trigger ():
8780 # Series: no trigger for both thresholds
8881 r = ok .Rebalance (period = "none" , abs_deviation = 0.2 , rel_deviation = 0.5 )
@@ -95,7 +88,6 @@ def test_check_if_rebalancing_required_series_no_trigger():
9588 assert cond_abs is False
9689
9790
98- @mark .rebalance
9991def test_check_if_rebalancing_required_dataframe_last_row_rel ():
10092 # DataFrame + Series: only the last row is considered (iloc[-1])
10193 r = ok .Rebalance (period = "none" , rel_deviation = 0.05 )
@@ -110,7 +102,6 @@ def test_check_if_rebalancing_required_dataframe_last_row_rel():
110102 assert cond_abs is False
111103
112104
113- @mark .rebalance
114105def test_assets_weights_ts_no_rebalancing_manual ():
115106 # No rebalancing at all: assets weights should be equal to manual calculation
116107 idx = pd .period_range ("2020-01" , "2020-03" , freq = "M" )
@@ -146,7 +137,6 @@ def test_assets_weights_ts_no_rebalancing_manual():
146137 pdt .assert_frame_equal (weights_ts , weights_manual , atol = 1e-12 , rtol = 1e-12 )
147138
148139
149- @mark .rebalance
150140def test_return_ror_ts_no_rebalancing_manual ():
151141 # Verify portfolio return series equals manual pct_change of wealth index in no-rebalancing case
152142 idx = pd .period_range ("2020-01" , "2020-03" , freq = "M" )
0 commit comments