def create_rate(self, row, data_date): """ Create a Rate object from a row of the CSV file. """ r = Rate() r.rate_id = int(row[0]) r.product_id = int(row[1]) r.lock = int(row[3]) r.base_rate = Decimal(row[4]) r.total_points = Decimal(row[5]) r.data_timestamp = data_date r.region_id = int(row[2]) return r
def setUp(self): self.url = '/oah-api/rates/rate-checker' REGIONS = [[1, 'DC'], [2, 'VA']] PRODUCTS = [ # plan_id, institution, loan_purpose, pmt_type, loan_type, loan_term, int_adj_term, _, io, _, _, _, _, _, _, # min_ltv, max_ltv, minfico, maxfico, min_loan_amt, max_loan_amt, single_family, condo, coop [ 11, 'Institution 1', 'PURCH', 'FIXED', 'CONF', 30, None, None, 0, None, None, None, None, None, None, 1, 95, 680, 700, 90000, 750000, 1, 0, 0 ], [ 22, 'Institution 2', 'PURCH', 'FIXED', 'CONF', 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0 ], [ 33, 'Institution 3', 'PURCH', 'ARM', 'CONF', 15, 5, None, 0, None, None, None, None, None, None, 1, 95, 680, 740, 90000, 550000, 1, 0, 0 ], [ 44, 'Institution 4', 'PURCH', 'FIXED', 'CONF', 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0 ], [ 55, 'Institution 5', 'PURCH', 'ARM', 'CONF', 30, 5, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0 ], [ 66, 'Institution 6', 'PURCH', 'FIXED', 'CONF', 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0 ], [ 77, 'Institution 7', 'PURCH', 'FIXED', 'FHA-HB', 15, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0 ], [ 88, 'Institution 8', 'PURCH', 'FIXED', 'FHA', 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0 ], ] RATES = [ # rate_id, product_id, region_id, lock, base_rate, total_points [111, 11, 1, 50, '3.150', '0.5'], [112, 11, 2, 60, '4.350', '-0.5'], [113, 11, 1, 60, '2.125', '0.125'], [221, 22, 1, 60, '3.555', '0.125'], [331, 33, 1, 60, '3.250', '0.125'], [332, 33, 2, 60, '4.650', '-0.5'], [441, 44, 1, 50, '3.125', '1.25'], [551, 55, 1, 50, '0.125', '0.125'], [661, 66, 1, 60, '3.705', '0.5'], [771, 77, 2, 60, '1.705', '0.25'], [772, 77, 2, 60, '2.705', '1.25'], [881, 88, 1, 60, '3.000', '0.5'], [882, 88, 1, 60, '2.005', '0.25'], [883, 88, 1, 60, '1.005', '-0.25'], ] ADJUSTMENTS = [ # rule_id, product_id, affect_rate_type, adj_value, min_loan_amt, max_loan_amt # prop_type, minfico, maxfico, minltv, maxltv, state [ 1, 11, 'P', '-0.35', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC' ], [ 2, 11, 'P', '0.25', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC' ], [ 3, 11, 'R', '0.15', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC' ], [ 4, 22, 'R', '0.25', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'VA' ], [ 5, 22, 'R', '0.15', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC' ], [ 6, 33, 'R', '0.25', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC' ], [ 7, 77, 'P', '0.125', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'VA' ], ] FEES = [ # plan_id, product_id, state_id, lender , single_family, condo, coop, # origination_dollar, origination_percent, third_party [11, 11111, 'DC', 'SMPL', 1, 1, 1, 1608.0000, .000, 587.2700], [11, 11111, 'DC', 'SMPL1', 1, 0, 1, 1610.0000, .000, 589.2700], [10, 11001, 'DC', 'SMPL1', 0, 1, 0, 1610.0000, .000, 589.2700], [11, 11111, 'VA', 'SMPL2', 1, 1, 1, 1610.0000, .000, 589.2700], ] NOW = timezone.now() for region in REGIONS: reg = Region(region_id=region[0], state_id=region[1], data_timestamp=NOW) reg.save() for p in PRODUCTS: product = Product(plan_id=p[0], institution=p[1], loan_purpose=p[2], pmt_type=p[3], loan_type=p[4], loan_term=p[5], int_adj_term=p[6], adj_period=p[7], io=p[8], arm_index=p[9], int_adj_cap=p[10], annual_cap=p[11], loan_cap=p[12], arm_margin=p[13], ai_value=p[14], min_ltv=p[15], max_ltv=p[16], min_fico=p[17], max_fico=p[18], min_loan_amt=p[19], max_loan_amt=p[20], single_family=p[21], condo=p[22], coop=p[23], data_timestamp=NOW) product.save() for r in RATES: rate = Rate(rate_id=r[0], product_id=r[1], region_id=r[2], lock=r[3], base_rate=r[4], total_points=r[5], data_timestamp=NOW) rate.save() for a in ADJUSTMENTS: adjustment = Adjustment(rule_id=a[0], product_id=a[1], affect_rate_type=a[2], adj_value=a[3], min_loan_amt=a[4], max_loan_amt=a[5], prop_type=a[6], min_fico=a[7], max_fico=a[8], min_ltv=a[9], max_ltv=a[10], state=a[11], data_timestamp=NOW) adjustment.save() for f in FEES: fee = Fee(plan_id=f[0], product_id=f[1], state_id=f[2], lender=f[3], single_family=f[4], condo=f[5], coop=f[6], origination_dollar=Decimal("%s" % f[7]), origination_percent=Decimal("%s" % f[8]), third_party=Decimal("%s" % f[9]), data_timestamp=NOW) fee.save()
def setUp(self): self.url = "/oah-api/rates/rate-checker" REGIONS = [[1, "DC"], [2, "VA"]] PRODUCTS = [ # plan_id, institution, loan_purpose, pmt_type, loan_type, loan_term, int_adj_term, _, io, _, _, _, _, _, _, # noqa # min_ltv, max_ltv, minfico, maxfico, min_loan_amt, max_loan_amt, single_family, condo, coop # noqa [ 11, "Institution 1", "PURCH", "FIXED", "CONF", 30, None, None, 0, None, None, None, None, None, None, 1, 95, 680, 700, 90000, 750000, 1, 0, 0, ], [ 22, "Institution 2", "PURCH", "FIXED", "CONF", 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0, ], [ 33, "Institution 3", "PURCH", "ARM", "CONF", 15, 5, None, 0, None, None, None, None, None, None, 1, 95, 680, 740, 90000, 550000, 1, 0, 0, ], [ 44, "Institution 4", "PURCH", "FIXED", "CONF", 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0, ], [ 55, "Institution 5", "PURCH", "ARM", "CONF", 30, 5, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0, ], [ 66, "Institution 6", "PURCH", "FIXED", "CONF", 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0, ], [ 77, "Institution 7", "PURCH", "FIXED", "FHA-HB", 15, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0, ], [ 88, "Institution 8", "PURCH", "FIXED", "FHA", 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0, ], ] RATES = [ # rate_id, product_id, region_id, lock, base_rate, total_points [111, 11, 1, 50, "3.150", "0.5"], [112, 11, 2, 60, "4.350", "-0.5"], [113, 11, 1, 60, "2.125", "0.125"], [221, 22, 1, 60, "3.555", "0.125"], [331, 33, 1, 60, "3.250", "0.125"], [332, 33, 2, 60, "4.650", "-0.5"], [441, 44, 1, 50, "3.125", "1.25"], [551, 55, 1, 50, "0.125", "0.125"], [661, 66, 1, 60, "3.705", "0.5"], [771, 77, 2, 60, "1.705", "0.25"], [772, 77, 2, 60, "2.705", "1.25"], [881, 88, 1, 60, "3.000", "0.5"], [882, 88, 1, 60, "2.005", "0.25"], [883, 88, 1, 60, "1.005", "-0.25"], ] ADJUSTMENTS = [ # rule_id, product_id, affect_rate_type, adj_value, min_loan_amt, # max_loan_amt, prop_type, minfico, maxfico, minltv, maxltv, state [ 1, 11, "P", "-0.35", 100000, 500000, "CONDO", 660, 780, 30, 95, "DC", ], [ 2, 11, "P", "0.25", 100000, 500000, "CONDO", 660, 780, 30, 95, "DC", ], [ 3, 11, "R", "0.15", 100000, 500000, "CONDO", 660, 780, 30, 95, "DC", ], [ 4, 22, "R", "0.25", 100000, 500000, "CONDO", 660, 780, 30, 95, "VA", ], [ 5, 22, "R", "0.15", 100000, 500000, "CONDO", 660, 780, 30, 95, "DC", ], [ 6, 33, "R", "0.25", 100000, 500000, "CONDO", 660, 780, 30, 95, "DC", ], [ 7, 77, "P", "0.125", 100000, 500000, "CONDO", 660, 780, 30, 95, "VA", ], ] NOW = timezone.now() for region in REGIONS: reg = Region(region_id=region[0], state_id=region[1], data_timestamp=NOW) reg.save() for p in PRODUCTS: product = Product( plan_id=p[0], institution=p[1], loan_purpose=p[2], pmt_type=p[3], loan_type=p[4], loan_term=p[5], int_adj_term=p[6], adj_period=p[7], io=p[8], arm_index=p[9], int_adj_cap=p[10], annual_cap=p[11], loan_cap=p[12], arm_margin=p[13], ai_value=p[14], min_ltv=p[15], max_ltv=p[16], min_fico=p[17], max_fico=p[18], min_loan_amt=p[19], max_loan_amt=p[20], single_family=p[21], condo=p[22], coop=p[23], data_timestamp=NOW, ) product.save() for r in RATES: rate = Rate( rate_id=r[0], product_id=r[1], region_id=r[2], lock=r[3], base_rate=r[4], total_points=r[5], data_timestamp=NOW, ) rate.save() for a in ADJUSTMENTS: adjustment = Adjustment( rule_id=a[0], product_id=a[1], affect_rate_type=a[2], adj_value=a[3], min_loan_amt=a[4], max_loan_amt=a[5], prop_type=a[6], min_fico=a[7], max_fico=a[8], min_ltv=a[9], max_ltv=a[10], state=a[11], data_timestamp=NOW, ) adjustment.save()
def setUp(self): self.url = '/oah-api/rates/rate-checker' REGIONS = [[1, 'DC'], [2, 'VA']] PRODUCTS = [ # plan_id, institution, loan_purpose, pmt_type, loan_type, loan_term, int_adj_term, _, io, _, _, _, _, _, _, # min_ltv, max_ltv, minfico, maxfico, min_loan_amt, max_loan_amt, single_family, condo, coop [11, 'Institution 1', 'PURCH', 'FIXED', 'CONF', 30, None, None, 0, None, None, None, None, None, None, 1, 95, 680, 700, 90000, 750000, 1, 0, 0], [22, 'Institution 2', 'PURCH', 'FIXED', 'CONF', 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0], [33, 'Institution 3', 'PURCH', 'ARM', 'CONF', 15, 5, None, 0, None, None, None, None, None, None, 1, 95, 680, 740, 90000, 550000, 1, 0, 0], [44, 'Institution 4', 'PURCH', 'FIXED', 'CONF', 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0], [55, 'Institution 5', 'PURCH', 'ARM', 'CONF', 30, 5, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0], [66, 'Institution 6', 'PURCH', 'FIXED', 'CONF', 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0], [77, 'Institution 7', 'PURCH', 'FIXED', 'FHA-HB', 15, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0], [88, 'Institution 8', 'PURCH', 'FIXED', 'FHA', 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0], ] RATES = [ # rate_id, product_id, region_id, lock, base_rate, total_points [111, 11, 1, 50, '3.150', '0.5'], [112, 11, 2, 60, '4.350', '-0.5'], [113, 11, 1, 60, '2.125', '0.125'], [221, 22, 1, 60, '3.555', '0.125'], [331, 33, 1, 60, '3.250', '0.125'], [332, 33, 2, 60, '4.650', '-0.5'], [441, 44, 1, 50, '3.125', '1.25'], [551, 55, 1, 50, '0.125', '0.125'], [661, 66, 1, 60, '3.705', '0.5'], [771, 77, 2, 60, '1.705', '0.25'], [772, 77, 2, 60, '2.705', '1.25'], [881, 88, 1, 60, '3.000', '0.5'], [882, 88, 1, 60, '2.005', '0.25'], [883, 88, 1, 60, '1.005', '-0.25'], ] ADJUSTMENTS = [ # rule_id, product_id, affect_rate_type, adj_value, min_loan_amt, max_loan_amt # prop_type, minfico, maxfico, minltv, maxltv, state [1, 11, 'P', '-0.35', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC'], [2, 11, 'P', '0.25', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC'], [3, 11, 'R', '0.15', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC'], [4, 22, 'R', '0.25', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'VA'], [5, 22, 'R', '0.15', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC'], [6, 33, 'R', '0.25', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC'], [7, 77, 'P', '0.125', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'VA'], ] NOW = timezone.now() for region in REGIONS: reg = Region(region_id=region[0], state_id=region[1], data_timestamp=NOW) reg.save() for p in PRODUCTS: product = Product( plan_id=p[0], institution=p[1], loan_purpose=p[2], pmt_type=p[3], loan_type=p[4], loan_term=p[5], int_adj_term=p[6], adj_period=p[7], io=p[8], arm_index=p[9], int_adj_cap=p[10], annual_cap=p[11], loan_cap=p[12], arm_margin=p[13], ai_value=p[14], min_ltv=p[15], max_ltv=p[16], min_fico=p[17], max_fico=p[18], min_loan_amt=p[19], max_loan_amt=p[20], single_family=p[21], condo=p[22], coop=p[23], data_timestamp=NOW ) product.save() for r in RATES: rate = Rate( rate_id=r[0], product_id=r[1], region_id=r[2], lock=r[3], base_rate=r[4], total_points=r[5], data_timestamp=NOW ) rate.save() for a in ADJUSTMENTS: adjustment = Adjustment( rule_id=a[0], product_id=a[1], affect_rate_type=a[2], adj_value=a[3], min_loan_amt=a[4], max_loan_amt=a[5], prop_type=a[6], min_fico=a[7], max_fico=a[8], min_ltv=a[9], max_ltv=a[10], state=a[11], data_timestamp=NOW ) adjustment.save()
def setUp(self): REGIONS = [[1, 'DC'], [2, 'VA'], [3, 'MD']] PRODUCTS = [ # plan_id, institution, loan_purpose, pmt_type, loan_type, loan_term, int_adj_term, _, io, _, _, _, _, _, _, # min_ltv, max_ltv, minfico, maxfico, min_loan_amt, max_loan_amt, single_family, condo, coop [11, 'Institution 1', 'PURCH', 'FIXED', 'CONF', 30, None, None, 0, None, None, None, None, None, None, 1, 95, 680, 700, 90000, 750000, 1, 0, 0], [22, 'Institution 2', 'PURCH', 'FIXED', 'CONF', 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0], [33, 'Institution 3', 'PURCH', 'ARM', 'CONF', 15, 5, None, 0, None, None, None, None, None, None, 1, 95, 680, 740, 90000, 550000, 1, 0, 0], [44, 'Institution 4', 'PURCH', 'FIXED', 'CONF', 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0], [55, 'Institution 5', 'PURCH', 'ARM', 'CONF', 30, 5, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0], [66, 'Institution 6', 'PURCH', 'FIXED', 'CONF', 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0], [77, 'Institution 7', 'PURCH', 'FIXED', 'FHA-HB', 15, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0], [88, 'Institution 8', 'PURCH', 'FIXED', 'FHA', 30, None, None, 0, None, None, None, None, None, None, 1, 87, 680, 740, 90000, 550000, 1, 0, 0], [98, 'Institution 8', 'PURCH', 'FIXED', 'CONF', 30, None, None, 0, None, None, None, None, None, None, 1, 95, 680, 740, 90000, 550000, 1, 1, 0], [99, 'Institution 8', 'PURCH', 'FIXED', 'CONF', 30, None, None, 0, None, None, None, None, None, None, 1, 90, 680, 740, 90000, 550000, 1, 1, 0], ] RATES = [ # rate_id, product_id, region_id, lock, base_rate, total_points [111, 11, 1, 50, '3.150', '0.5'], [112, 11, 2, 60, '4.350', '-0.5'], [113, 11, 1, 60, '2.125', '0.125'], [221, 22, 1, 60, '3.555', '0.125'], [331, 33, 1, 60, '3.250', '0.125'], [332, 33, 2, 60, '4.650', '-0.5'], [441, 44, 1, 50, '3.125', '1.25'], [551, 55, 1, 50, '0.125', '0.125'], [661, 66, 1, 60, '3.705', '0.5'], [771, 77, 2, 60, '1.705', '0.25'], [772, 77, 2, 60, '2.705', '1.25'], [881, 88, 1, 60, '3.000', '0.5'], [882, 88, 1, 60, '2.005', '0.25'], [883, 88, 1, 60, '1.005', '-0.25'], [884, 98, 3, 60, '3.000', '0.5'], [885, 98, 3, 60, '2.985', '0'], [886, 98, 3, 60, '1.985', '-0.25'], [887, 99, 3, 60, '3.000', '0.5'], [888, 99, 3, 60, '2.995', '0'], [889, 99, 3, 60, '1.995', '-0.25'], ] ADJUSTMENTS = [ # rule_id, product_id, affect_rate_type, adj_value, min_loan_amt, max_loan_amt # prop_type, minfico, maxfico, minltv, maxltv, state [1, 11, 'P', '-0.35', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC'], [2, 11, 'P', '0.25', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC'], [3, 11, 'R', '0.15', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC'], [4, 22, 'R', '0.25', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'VA'], [5, 22, 'R', '0.15', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC'], [6, 33, 'R', '0.25', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'DC'], [7, 77, 'P', '0.125', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'VA'], [8, 98, 'P', '0.125', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'MD'], [9, 99, 'P', '0.125', 100000, 500000, 'CONDO', 660, 780, 30, 95, 'MD'], ] FEES = [ # plan_id, product_id, state_id, lender , single_family, condo, coop, # origination_dollar, origination_percent, third_party [11, 88, 'DC', 'Institution 8', 1, 1, 1, 1608.0000, .000, 587.2700], [11, 88, 'DC', 'Institution 8', 1, 0, 1, 1612.0000, .000, 591.2700], [10, 88, 'DC', 'Institution 8', 0, 1, 0, 1610.0000, .000, 589.2700], [11, 87, 'VA', 'Institution 7', 1, 1, 1, 1610.0000, .000, 589.2700], ] self.NOW = timezone.now() NOW = self.NOW for region in REGIONS: reg = Region(region_id=region[0], state_id=region[1], data_timestamp=NOW) reg.save() for p in PRODUCTS: product = Product( plan_id=p[0], institution=p[1], loan_purpose=p[2], pmt_type=p[3], loan_type=p[4], loan_term=p[5], int_adj_term=p[6], adj_period=p[7], io=p[8], arm_index=p[9], int_adj_cap=p[10], annual_cap=p[11], loan_cap=p[12], arm_margin=p[13], ai_value=p[14], min_ltv=p[15], max_ltv=p[16], min_fico=p[17], max_fico=p[18], min_loan_amt=p[19], max_loan_amt=p[20], single_family=p[21], condo=p[22], coop=p[23], data_timestamp=NOW ) product.save() for r in RATES: rate = Rate( rate_id=r[0], product_id=r[1], region_id=r[2], lock=r[3], base_rate=r[4], total_points=r[5], data_timestamp=NOW ) rate.save() for a in ADJUSTMENTS: adjustment = Adjustment( rule_id=a[0], product_id=a[1], affect_rate_type=a[2], adj_value=a[3], min_loan_amt=a[4], max_loan_amt=a[5], prop_type=a[6], min_fico=a[7], max_fico=a[8], min_ltv=a[9], max_ltv=a[10], state=a[11], data_timestamp=NOW ) adjustment.save() for f in FEES: fee = Fee( plan_id=f[0], product_id=f[1], state_id=f[2], lender=f[3], single_family=f[4], condo=f[5], coop=f[6], origination_dollar=Decimal("%s" % f[7]), origination_percent=Decimal("%s" % f[8]), third_party=Decimal("%s" % f[9]), data_timestamp=NOW ) fee.save()