Пример #1
0
    def get(self, request, *args, **kwargs):
        """
        Quotes request should have following parameters
        funding_amount,current_income,age,degree,industry(optional),
        profession(optional),method(optional),term_list(optional in years)
        """
        term_flag = 0
        paras = request.query_params
        funding_amount = float(paras['funding_amount'])
        current_income = float(paras['current_income'])
        age = int(paras['age'])
        degree = paras['degree']

        if 'industry' in paras.keys():
            industry = request.query_params['industry']

        if 'profession' in paras.keys():
            profession = request.query_params['profession']

        if 'method' in paras.keys():
            method = request.query_params['method']

        if 'term_list' in paras.keys():
            term_list = eval(request.query_params['term_list'])
            term_flag = 1
            print('here')

        prais = Prais()
        if term_flag == 1:
            quotes_result = prais.Quotes(funding_amount,
                                         current_income,
                                         age,
                                         degree,
                                         term_list=term_list)
        else:
            quotes_result = prais.Quotes(funding_amount, current_income, age,
                                         degree)

        quotes_json = quotes_result  #json.dumps(quotes_result)
        # except:
        #     return Response(status.HTTP_406_NOT_ACCEPTABLE)
        return Response(quotes_json)
Пример #2
0
    def test_GetQuote(self):
        """Test GetQuote function returns a right output"""

        isa_para = PraisParameterCap.objects.create(
                    isa_processing_fee=0.01 ,
                    isa_servicing_fee=0.05,
                    isa_sales_charge=0.02,
                    minimum_self_equity_perc=0.05,
                    max_minimum_self_equity=5000,
                    annual_lower_income=25000,
                    isa_processing_fee_cap=1500,
                    buyout_servicing_fee=0.05,
                    isp_age_factor=2.5)

        growth_rate = GrowthRateByAgeEducation.objects.create(
                                                    age=26,
                                                    dropout=0.03,
                                                    diploma=0.03,
                                                    some_college=0.03,
                                                    associates=0.03,
                                                    license=0.03,
                                                    bachelors=0.03,
                                                    masters=0.03,
                                                    mba=0.03,
                                                    attorney=0.03,
                                                    doctorate=0.03,
                                                    professional=0.03,
                                                )
        unemployment_duration_by_agegroup = UnemploymentByAgeGroup.objects.create(
                                                    age_group="25-34",
                                                    age_min=25,
                                                    age_max=34,
                                                    mean_duration=23.0,
                                                    median_duration=10.0
                                                )
        employment_duratiom_agegroup = EmploymentDurationByAgeGroup.objects.create(
                                                            age_group="25-34",
                                                            age_min=25,
                                                            age_max=34,
                                                            duration=2.8
                                                        )

        hike_by_education = HikesByEducation.objects.create(
            updated_date="2020-02-02",
            degree="masters",
            hike=0.03,
        )

        pricing = Pricing.objects.create(
            term=7,
            interest_rate=0.1,
            min_cagr=0.1,
            targeted_cagr=0.0325,
            max_cagr=0.1,
            payment_cap_factor=0.1,
            prepayment_fv=0.1,
            prepayment_growth=0.1
        )

        prais= Prais()

        Quote = prais.Quotes(funding_amount=31000,
                              current_income=44000,
                              age=26,
                              degree='masters',
                              industry="NA",
                              profession="NA",
                              method="Median",
                              term_list = [7])
        print(Quote)
        self.assertEqual(7,Quote[7]['term'])