def find_qualifying_loans(bank_data, credit_score, debt, income, loan, home_value): """Determine which loans the user qualifies for. Loan qualification criteria is based on: - Credit Score - Loan Size - Debit to Income ratio (calculated) - Loan to Value ratio (calculated) Args: bank_data (list): A list of bank data. credit_score (int): The applicant's current credit score. debt (float): The applicant's total monthly debt payments. income (float): The applicant's total monthly income. loan (float): The total loan amount applied for. home_value (float): The estimated home value. Returns: A list of the banks willing to underwrite the loan. """ # Calculate the monthly debt ratio monthly_debt_ratio = calculate_monthly_debt_ratio(debt, income) print(f"The monthly debt to income ratio is {monthly_debt_ratio:.02f}") # Calculate loan to value ratio loan_to_value_ratio = calculate_loan_to_value_ratio(loan, home_value) print(f"The loan to value ratio is {loan_to_value_ratio:.02f}.") # Run qualification filters bank_data_filtered = filter_max_loan_size(loan, bank_data) bank_data_filtered = filter_credit_score(credit_score, bank_data_filtered) bank_data_filtered = filter_debt_to_income(monthly_debt_ratio, bank_data_filtered) bank_data_filtered = filter_loan_to_value(loan_to_value_ratio, bank_data_filtered) print(f"Found {len(bank_data_filtered)} qualifying loans") #Printing the bank_data_filtered to verify CSV file output after running save_csv #print(bank_data_filtered) return bank_data_filtered
def test_calculate_monthly_debt_ratio(): assert calculators.calculate_monthly_debt_ratio(1500, 4000) == 0.375