def test_instance_constraint_slack_test_step_length(self): # add the count of weight value which is greater than 0 should be 5 or more constraints! constraint_param_list = [('general_count_lower_rc', { 'bound_value': 10.5 }, 1, 'ineq')] Ro = RunOpt(method=self.method, stockpool=stock_pool, sigma2=cov_price, lambda_r=2, portfolio_returns=return_matrix) result = Ro.run_opt(constraint_param_list, slack=True, step_length=0.1) self.assertEqual(result.success, True)
def test_main_entry_instance_test_constr_cls_instance(self): from QuantOPT.constraints.constraints import Constraints constraint_param_list = [] Ro = RunOpt(method=self.method, stockpool=stock_pool, sigma2=cov_price, lambda_r=2, portfolio_returns=return_matrix) result = Ro.run_opt(constraint_param_list, slack=False, constr_cls=Constraints) self.assertEqual(result.success, True)
def test_main_entry_instance_test_constr_cls_create_instance(self): from QuantOPT.conf.conf import setting_yaml_path from QuantOPT.constraints.constraints import create_constraints_holder constr_cls = create_constraints_holder(setting_yaml_path) constraint_param_list = [] Ro = RunOpt(method=self.method, stockpool=stock_pool, sigma2=cov_price, lambda_r=2, portfolio_returns=return_matrix, constr_cls=constr_cls) result = Ro.run_opt(constraint_param_list, slack=False) self.assertEqual(result.success, True)
def test_instance_constraint_slack_test_constr_cls_create_instance(self): from QuantOPT.conf.conf import setting_yaml_path from QuantOPT.constraints.constraints import create_constraints_holder constr_cls = create_constraints_holder(setting_yaml_path) constraint_param_list = [('general_count_lower_rc', { 'bound_value': 10.02 }, 1, 'ineq')] Ro = RunOpt(method=self.method, stockpool=stock_pool, sigma2=cov_price, constr_cls=constr_cls) result = Ro.run_opt(constraint_param_list, slack=True) self.assertEqual(result.success, True)
def test_instance_constraint_slack_test_constr_cls_instance(self): from QuantOPT.constraints.constraints import Constraints constraint_param_list = [('general_count_lower_rc', { 'bound_value': 10.02 }, 1, 'ineq')] kwargs_data = { 'stockpool': stock_pool, 'sigma2': cov_price, 'lambda_r': 2, 'portfolio_returns': return_matrix } Ro = RunOpt(method=self.method, constr_cls=Constraints, **kwargs_data) result = Ro.run_opt(constraint_param_list, slack=True) self.assertEqual(result.success, True)
def test_instance_constraint_slack(self): # add the count of weight value which is greater than 0 should be 5 or more constraints! constraint_param_list = [('general_count_lower_rc', { 'bound_value': 10.02 }, 1, 'ineq')] Ro = RunOpt( method=self.method, stockpool=stock_pool, sigma2=cov_price, ) result = Ro.run_opt( constraint_param_list, slack=True, ) self.assertEqual(result.success, True)
def test_instance_constraint_slack_test_constr_cls2_create_instance_test_step_length( self): from QuantOPT.conf.conf import setting_yaml_path from QuantOPT.constraints.constraints import create_constraints_holder constr_cls = create_constraints_holder(setting_yaml_path) # add the count of weight value which is greater than 0 should be 5 or more constraints! constraint_param_list = [('general_count_lower_rc', { 'bound_value': 10.5 }, 1, 'ineq')] Ro = RunOpt(method=self.method, stockpool=stock_pool, sigma2=cov_price) result = Ro.run_opt(constraint_param_list, slack=True, step_length=0.1, constr_cls=constr_cls) self.assertEqual(result.success, True)
def test_no_exists_model2(self): kwargs_data = {'stockpool': stock_pool, 'sigma2': cov_price} constraint_param_list = [] with self.assertRaises(AttributeError): Ro = RunOpt(method='test', **kwargs_data) result = Ro.run_opt(constraint_param_list, )
def test_main_entry_instance(self): constraint_param_list = [] Ro = RunOpt(method=self.method, stockpool=stock_pool, sigma2=cov_price) result = Ro.run_opt(constraint_param_list, slack=False) self.assertEqual(result.success, True)
def test_main_entry_instance(self): constraint_param_list = [] Ro = RunOpt(method=self.method, **self.kwargs_data) result = Ro.run_opt(constraint_param_list, slack=False) self.assertEqual(result.success, True)