@@ -63,107 +63,50 @@ def test_ef_points_reb(init_efficient_frontier_reb):
6363
6464@mark .rebalance
6565@mark .frontier
66- def convex_right_frontier ():
67-
68- ls_m = ["SPY.US" , "GLD.US" , "PGJ.US" , "RGBITR.INDX" , "MCFTR.INDX" ]
69- curr_rub = "RUB"
70-
71- x = ok .EfficientFrontierReb (
72- assets = ls_m ,
73- first_date = "2005-01" ,
74- last_date = "2020-11" ,
75- ccy = curr_rub ,
76- rebalancing_period = "year" ,
77- n_points = 5 ,
78- verbose = True ,
79- )
80-
81- result = x ._max_cagr_asset_right_to_max_cagr
66+ def test_convex_right_frontier (init_convex_frontier ):
67+ x = init_convex_frontier
68+ result = x ._max_ratio_asset_right_to_max_cagr
8269
8370 expected_result = {
84- "max_asset_cagr" : 0.17520700138002665 ,
85- "ticker_with_largest_cagr" : "PGJ.US" ,
86- "list_position" : 2
71+ "max_asset_cagr" : approx ( 0.17520700138002665 , abs = 1e-2 ) ,
72+ "ticker_with_largest_cagr" : "PGJ.US" ,
73+ "list_position" : 2
8774 }
8875
8976 assert result == expected_result
9077
91-
9278@mark .rebalance
9379@mark .frontier
94- def nonconvex_right_frontier ():
95-
96- ls_m = ["SPY.US" , "GLD.US" , "VB.US" , "RGBITR.INDX" , "MCFTR.INDX" ]
97- curr_rub = "RUB"
98-
99- x = ok .EfficientFrontierReb (
100- assets = ls_m ,
101- first_date = "2004-12" ,
102- last_date = "2020-12" ,
103- ccy = curr_rub ,
104- rebalancing_period = "year" ,
105- n_points = 5 ,
106- verbose = True ,
107- )
108-
109- result = x ._max_cagr_asset_right_to_max_cagr
80+ def test_nonconvex_right_frontier (init_nonconvex_frontier ):
81+ x = init_nonconvex_frontier
82+ result = x ._max_ratio_asset_right_to_max_cagr
11083
11184 expected_result = {
112- "max_asset_cagr" : 0.15691138904751512 ,
113- "ticker_with_largest_cagr" : "MCFTR.INDX" ,
85+ "max_asset_cagr" : approx ( 0.15691138904751512 , abs = 1e-2 ) ,
86+ "ticker_with_largest_cagr" : "MCFTR.INDX" ,
11487 "list_position" : 4
11588 }
11689
11790 assert result == expected_result
118-
119-
91+
12092@mark .rebalance
12193@mark .frontier
122- def test_maximize_risk_with_convex_right_frontier ():
123-
124- ls_m = ["SPY.US" , "GLD.US" , "PGJ.US" , "RGBITR.INDX" , "MCFTR.INDX" ]
125- curr_rub = "RUB"
126-
127- x = ok .EfficientFrontierReb (
128- assets = ls_m ,
129- first_date = "2005-01" ,
130- last_date = "2020-11" ,
131- ccy = curr_rub ,
132- rebalancing_period = "year" ,
133- n_points = 5 ,
134- verbose = True ,
135- )
136-
94+ def test_maximize_risk_with_convex_right_frontier (init_convex_frontier ):
95+ x = init_convex_frontier
13796 result = x ._maximize_risk (0.17520700138002665 )
13897
13998 result_risk = result ['Risk' ]
140-
141- expected_risk = 0.30419612104254684
99+ expected_risk = approx (0.30419612104254684 , abs = 1e-2 )
142100
143101 assert result_risk == expected_risk
144102
145-
146103@mark .rebalance
147104@mark .frontier
148- def test_maximize_risk_with_nonconvex_right_frontier ():
149-
150- ls_m = ["SPY.US" , "GLD.US" , "VB.US" , "RGBITR.INDX" , "MCFTR.INDX" ]
151- curr_rub = "RUB"
152-
153- x = ok .EfficientFrontierReb (
154- assets = ls_m ,
155- first_date = "2004-12" ,
156- last_date = "2020-12" ,
157- ccy = curr_rub ,
158- rebalancing_period = "year" ,
159- n_points = 5 ,
160- verbose = True ,
161- )
162-
105+ def test_maximize_risk_with_nonconvex_right_frontier (init_nonconvex_frontier ):
106+ x = init_nonconvex_frontier
163107 result = x ._maximize_risk (0.15691138904751512 )
164108
165109 result_risk = result ['Risk' ]
166-
167- expected_risk = 0.28761107914313766
110+ expected_risk = approx (0.28761107914313766 , abs = 1e-2 )
168111
169112 assert result_risk == expected_risk
0 commit comments