예제 #1
0
    def test_no_exists_model_init_no_check(self):
        kwargs_data = {'stockpool': stock_pool, 'sigma2': cov_price}
        constraint_param_list = []

        Ro = RunOpt(method='test', check=False, **kwargs_data)
        with self.assertRaises(AttributeError):
            result = Ro.run_opt(constraint_param_list, )
예제 #2
0
 def test_main_entry_instance_test_constr_cls_instance(self):
     from QuantOPT.constraints.constraints import Constraints
     constraint_param_list = []
     Ro = RunOpt(method=self.method, **self.kwargs_data)
     result = Ro.run_opt(constraint_param_list,
                         slack=False,
                         constr_cls=Constraints)
     self.assertEqual(result.success, True)
예제 #3
0
 def test_instance_constraint(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': 5
     }, 1, 'ineq')]
     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)
예제 #4
0
 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)
예제 #5
0
 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,
                 constr_cls=Constraints)
     result = Ro.run_opt(constraint_param_list, slack=False)
     self.assertEqual(result.success, True)
예제 #6
0
 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,
                 constr_cls=constr_cls,
                 **self.kwargs_data)
     result = Ro.run_opt(constraint_param_list, slack=False)
     self.assertEqual(result.success, True)
예제 #7
0
 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')]
     Ro = RunOpt(method=self.method,
                 stockpool=stock_pool,
                 sigma2=cov_price,
                 constr_cls=Constraints)
     result = Ro.run_opt(constraint_param_list, slack=True)
     self.assertEqual(result.success, True)
예제 #8
0
 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)
예제 #9
0
 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)
예제 #10
0
 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)
예제 #11
0
 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)
예제 #12
0
 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,
                 lambda_r=2,
                 portfolio_returns=return_matrix)
     result = Ro.run_opt(constraint_param_list, slack=True)
     self.assertEqual(result.success, True)
예제 #13
0
 def test_main_entry_no_instance_test_constr_cls_instance(self):
     from QuantOPT.constraints.constraints import Constraints
     # constr_cls = create_constraints_holder(setting_yaml_path)
     result = RunOpt.run_opt_single(self.kwargs_data, [],
                                    self.method,
                                    constr_cls=Constraints)
     self.assertEqual(result.success, True)
예제 #14
0
 def test_main_entry_no_instance_test_constr_cls(self):
     constraint_param_list = []
     from QuantOPT.conf.conf import setting_yaml_path
     result = RunOpt.run_opt_single(self.kwargs_data,
                                    constraint_param_list,
                                    self.method,
                                    constr_cls=setting_yaml_path)
     self.assertEqual(result.success, True)
예제 #15
0
 def test_no_exists_constraints(self):
     kwargs_data = {'stockpool': stock_pool, 'sigma2': cov_price}
     constraint_param_list = [('not_exists', {'bound_value': 5}, 1, 'ineq')]
     from QuantOPT.conf.conf import setting_yaml_path
     with self.assertRaises(AttributeError):
         result = RunOpt.run_opt_single(kwargs_data,
                                        constraint_param_list,
                                        'MinVar',
                                        constr_cls=setting_yaml_path)
예제 #16
0
 def test_main_entry_no_instance_test_constr_cls(self):
     kwargs_data = {'stockpool': stock_pool, 'sigma2': cov_price}
     constraint_param_list = []
     from QuantOPT.conf.conf import setting_yaml_path
     result = RunOpt.run_opt_single(kwargs_data,
                                    constraint_param_list,
                                    self.method,
                                    constr_cls=setting_yaml_path)
     self.assertEqual(result.success, True)
예제 #17
0
 def test_main_entry_no_instance(self):
     kwargs_data = {
         'stockpool': stock_pool,
         'sigma2': cov_price,
     }
     constraint_param_list = []
     result = RunOpt.run_opt_single(kwargs_data, constraint_param_list,
                                    self.method)
     self.assertEqual(result.success, True)
예제 #18
0
 def test_no_exists_constraints_priority_wrong(self):
     kwargs_data = {'stockpool': stock_pool, 'sigma2': cov_price}
     constraint_param_list = [('general_count_lower_rc', {
         'bound_value': 5
     }, 'f', 'ineq')]
     from QuantOPT.conf.conf import setting_yaml_path
     with self.assertRaises(TypeError):
         result = RunOpt.run_opt_single(kwargs_data,
                                        constraint_param_list,
                                        'MinVar',
                                        constr_cls=setting_yaml_path)
예제 #19
0
 def test_main_entry_no_instance_test_constr_cls_instance(self):
     kwargs_data = {
         'stockpool': stock_pool,
         'sigma2': cov_price,
     }
     constraint_param_list = []
     from QuantOPT.constraints.constraints import Constraints
     # constr_cls = create_constraints_holder(setting_yaml_path)
     result = RunOpt.run_opt_single(kwargs_data,
                                    constraint_param_list,
                                    self.method,
                                    constr_cls=Constraints)
     self.assertEqual(result.success, True)
예제 #20
0
 def test_main_entry_no_instance_test_constr_cls_create_instance(self):
     kwargs_data = {
         'stockpool': stock_pool,
         'sigma2': cov_price,
         'lambda_r': 2,
         'portfolio_returns': return_matrix
     }
     constraint_param_list = []
     from QuantOPT.conf.conf import setting_yaml_path
     from QuantOPT.constraints.constraints import create_constraints_holder
     constr_cls = create_constraints_holder(setting_yaml_path)
     result = RunOpt.run_opt_single(kwargs_data,
                                    constraint_param_list,
                                    self.method,
                                    constr_cls=constr_cls)
     self.assertEqual(result.success, True)
예제 #21
0
 def test_no_exists_model_init_check(self):
     kwargs_data = {'stockpool': stock_pool, 'sigma2': cov_price}
     # constraint_param_list = []
     with self.assertRaises(AttributeError):
         Ro = RunOpt(method='test', check=True, **kwargs_data)
예제 #22
0
 def test_no_exists_model(self):
     kwargs_data = {'stockpool': stock_pool, 'sigma2': cov_price}
     constraint_param_list = []
     with self.assertRaises(AttributeError):
         result = RunOpt.run_opt_single(kwargs_data, constraint_param_list,
                                        'test')
예제 #23
0
 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)
예제 #24
0
 def test_main_entry_no_instance(self):
     constraint_param_list = []
     result = RunOpt.run_opt_single(self.kwargs_data, constraint_param_list,
                                    self.method)
     self.assertEqual(result.success, True)