def compute_impacts(self): # setup a loan portfolio # loan_portfolio = LoanPortfolio() # loan with all contributions (mi)_all # loan_all = Loan(principal=self.principal, rate=self.rate, payment=self.payment, extra_payment=self.extra_payment + sum(self.contributions)) loan_all.check_loan_parameters() loan_all.compute_schedule() # loan with no contributions (mi)_0 # loan_none = Loan(principal=self.principal, rate=self.rate, payment=self.payment, extra_payment=self.extra_payment) loan_none.check_loan_parameters() loan_none.compute_schedule() micro_impact_interest_paid_all = \ (loan_none.total_interest_paid - loan_all.total_interest_paid) / loan_all.total_interest_paid micro_impact_duration_all = -\ (loan_none.time_to_loan_termination - loan_all.time_to_loan_termination) / loan_all.time_to_loan_termination # micro_impact_interest_paid_all = loan_none.total_interest_paid / loan_all.total_interest_paid # micro_impact_duration_all = loan_none.time_to_loan_termination / loan_all.time_to_loan_termination print(f'\nIndex\tInterestPaid\tDuration\tMIInterest\tMIDuration') print(f'ALL \t\t', round(loan_all.total_interest_paid, 2), f'\t\t', loan_all.time_to_loan_termination) print(f'0\t\t\t', round(loan_none.total_interest_paid, 2), f'\t\t', loan_none.time_to_loan_termination, f'\t\t', round(micro_impact_interest_paid_all, 4), f'\t', round(micro_impact_duration_all, 4)) # iterate over each contribution (mi)_index # #res = ['Index', 'InterestPaid', 'Duration', 'MIInterest', 'MIDuration'] res = [[0, round(loan_none.total_interest_paid, 2), loan_none.time_to_loan_termination, round(micro_impact_interest_paid_all, 4), round(micro_impact_duration_all, 4)]] for index, contribution in enumerate(self.contributions): loan_index = Loan(principal=self.principal, rate=self.rate, payment=self.payment, extra_payment=self.extra_payment + sum(self.contributions) - contribution) loan_index.check_loan_parameters() loan_index.compute_schedule() micro_impact_interest_paid = \ (loan_index.total_interest_paid - loan_all.total_interest_paid) / loan_all.total_interest_paid micro_impact_duration = \ (loan_index.time_to_loan_termination - loan_all.time_to_loan_termination) / loan_all.time_to_loan_termination # micro_impact_interest_paid = loan.total_interest_paid / loan_all.total_interest_paid # micro_impact_duration = loan.time_to_loan_termination / loan_all.time_to_loan_termination print(index+1, f'\t\t\t', round(loan_index.total_interest_paid, 2), f'\t\t', loan_index.time_to_loan_termination, f'\t\t', round(micro_impact_interest_paid, 4), f'\t', round(micro_impact_duration, 4)) res.append([index+1, round(loan_index.total_interest_paid, 2), loan_index.time_to_loan_termination, round(micro_impact_interest_paid, 4), round(micro_impact_duration, 4)]) return res
def work_application(self): print(f"\nWorking an Application") if not self.fake_db["applications_list"]: print(f"No Applications exist. Please create an Application...") self.menu_handler("Loan Menu") else: app_id = input(f"Enter application id... ") print(f"\n1 Approve") print(f"2 Deny") decision = int(input(f"Enter choice... ")) if decision == 1: owner = self.fake_db["people_list"][input( f"Enter owner id... ")] interest = input(f"Input interest rate... ") temp_ln = Loan( *self.fake_db["application_list"][app_id]. approve_application(self, app_id, owner, interest)) self.fake_db["loan_list"].append(temp_ln) self.write_db() elif decision == 2: self.fake_db["application_list"].deny_application() self.write_db() else: self.menu_handler("Loan Menu") self.menu_handler("Loan Menu")
def main(): # Enter yearly interest rate. annualInterestRate = float(input ("Enter yearly interest rate, for example, 7.25: ")) # Enter number of years. numberOfYears = int(input( "Enter number of years as an integer: ")) # Enter loan amount. loanAmount = float(input( "Enter loan amount, for example, 120000.95: ")) # Enter a borrower. borrower = input("Enter a borrower's name: ") # Enter reason. reason = input("Enter a reason for the loan: ") # Create a Loan object. loan = Loan(annualInterestRate, numberOfYears, loanAmount, borrower, reason) # Display loan date, monthly payment, and total payment. print("The borrower is", loan.getBorrower(), "for", loan.getReason()) print("The monthly payment is", format( loan.getMonthlyPayment(), '.2f')) print("The total payment is", format( loan.getTotalPayment(), '.2f'))
def buyProperty(self, property_obj): current_month = self.calendar.month # buy property property_value = property_obj.value_history[current_month] down_payment = self.down_payment_percentage * property_value / 100.0 # TODO: function for calcing down payment self.savings_history[current_month] -= down_payment self.properties.append(property_obj) # take on loan new_loan = Loan(property_value - down_payment, current_month) self.loans.append(new_loan)
def _populate_db(self): """Add mocked data to database""" user_1 = User(name='FirstName', surname="FirstSurname") user_2 = User(name='SecondName', surname="SecondName") loan_1 = Loan(balance=56, currency='GBP') report_1 = Report( body='body1', loan=loan_1, title='TitleReport1', user=user_1, ) report_2 = Report(user=user_2, title='TitleReport2') db.session.add(report_1) db.session.add(report_2) db.session.commit()
def main(): annualInterestRate = eval( input("Enter yearly interest rate, for example, 7.25: ")) numberOfYears = eval(input("Enter number of years as integer: ")) loanAmount = eval(input("Enter loan amount, ex 120000.95: ")) borrower = input("Enter a borrowers name: ") # Create a loan object loan = Loan(annualInterestRate, numberOfYears, loanAmount, borrower) print("the loan is for", loan.getBorrower()) print("the monthly payment is", format(loan.getMonthlyPayment(), ".2f")) print("the total payment is", format(loan.getTotalPayment(), ".2f"))
def test(store): from Book import Book from Author import Author from Loan import Loan from Wrote import Wrote from Shelf import Shelf classics = Shelf() classics.setName('Classics') store.addObject(classics) store.saveChanges() ed = Author() ed.setName('Edmund Wells') david = Book() wrote = Wrote() ed.addToWrote(wrote) david.addToAuthors(wrote) david.setTitle('David Coperfield') david.setPublisher('Monty Python') loan = Loan() loan.setBorrower('A. Git') david.addToLoans(loan) david.setShelf(classics) store.addObject(david) store.saveChanges() # create a clone of the book and associated objects grate = david.clone() grate.setTitle('Grate Expections') store.addObject(grate) store.saveChanges() assert david is not grate assert len(grate.authors()) == 1 assert david.authors()[0] is not grate.authors()[0] assert grate.authors()[0].author() is ed assert len(grate.loans()) == 0 assert grate.shelf() is david.shelf() assert grate.publisher() == 'Monty Python'
def main(): # Enter yearly interest rate annualInterestRate = eval(input("请输入年利率,例如 7.25 :")) # Enter number of years numberOfYears = eval(input("请输入贷款年限,整数:")) # Enter loan amount loanAmount = eval(input("请输入贷款总数,例如 120000.95 :")) # Enter a borrower borrower = input("请输入贷款人姓名:") # Create a Loan object loan = Loan(annualInterestRate, numberOfYears, loanAmount, borrower) # Display loan date, monthly payment, and total payment print("The loan is for", loan.getBorrower()) print("The monthly payment is", format(loan.getMonthlyPayment(), ".2f")) print("The total payment is", format(loan.getTotalPayment(), ".2f"))
def main(): # Enter yearly interest rate annualInterestRate = eval(input("Enter yearly interest rate, for example, 7.25: ")) # Enter number of years numberOfYears = eval(input("Enter number of years as an integer: ")) # Enter loan amount loanAmount = eval(input("Enter loan amount, for example, 120000.95: ")) # Enter a borrower borrower = input("Enter a borrower's name: ") # Create a Loan object loan = Loan(annualInterestRate, numberOfYears, loanAmount, borrower) # Display loan date, monthly payment, and total payment print("The loan is for", loan.getBorrower()) print("The monthly payment is", format(loan.getMonthlyPayment(), ".2f")) print("The total payment is", format(loan.getTotalPayment(), ".2f"))
def compute_impacts(self): # setup a loan portfolio # loan_portfolio = LoanPortfolio() # loan with all contributions (mi)_all # loan_all = Loan(principal=self.principal, rate=self.rate, payment=self.payment, extra_payment=self.extra_payment + sum(self.contributions)) loan_all.check_loan_parameters() loan_all.compute_schedule() # loan with no contributions (mi)_0 # loan_none = Loan(principal=self.principal, rate=self.rate, payment=self.payment, extra_payment=self.extra_payment) loan_none.check_loan_parameters() loan_none.compute_schedule() micro_impact_interest_paid_all = \ (loan_none.total_interest_paid - loan_all.total_interest_paid) / loan_all.total_interest_paid micro_impact_duration_all = -\ (loan_none.time_to_loan_termination - loan_all.time_to_loan_termination) / loan_all.time_to_loan_termination # micro_impact_interest_paid_all = loan_none.total_interest_paid / loan_all.total_interest_paid # micro_impact_duration_all = loan_none.time_to_loan_termination / loan_all.time_to_loan_termination # print(f'\nIndex\tInterestPaid\tDuration\tMIInterest\tMIDuration') # print(f'ALL\t', # round(loan_all.total_interest_paid, 2), f'\t\t', loan_all.time_to_loan_termination) # print(f'0\t', # round(loan_none.total_interest_paid, 2), f'\t\t', loan_none.time_to_loan_termination, f'\t\t', # round(micro_impact_interest_paid_all, 4), f'\t\t', round(micro_impact_duration_all, 4)) df = pd.DataFrame(columns=[ 'Index', 'InterestPaid', 'Duration', 'MIInterest', 'MIDuration' ]) list = [ 'ALL', round(loan_all.total_interest_paid, 2), loan_all.time_to_loan_termination, None, None ] df.loc[len(df)] = list list = [ 0, round(loan_none.total_interest_paid, 2), loan_none.time_to_loan_termination, round(micro_impact_interest_paid_all, 4), round(micro_impact_duration_all, 4) ] df.loc[len(df)] = list i = 2 # iterate over each contribution (mi)_index # for index, contribution in enumerate(self.contributions): loan_index = Loan(principal=self.principal, rate=self.rate, payment=self.payment, extra_payment=self.extra_payment + sum(self.contributions) - contribution) loan_index.check_loan_parameters() loan_index.compute_schedule() micro_impact_interest_paid = \ (loan_index.total_interest_paid - loan_all.total_interest_paid) / loan_all.total_interest_paid micro_impact_duration = \ (loan_index.time_to_loan_termination - loan_all.time_to_loan_termination) / loan_all.time_to_loan_termination # micro_impact_interest_paid = loan.total_interest_paid / loan_all.total_interest_paid # micro_impact_duration = loan.time_to_loan_termination / loan_all.time_to_loan_termination # print(index+1, f'\t', # round(loan_index.total_interest_paid, 2), f'\t\t', loan_index.time_to_loan_termination, f'\t\t', # round(micro_impact_interest_paid, 4), f'\t\t', round(micro_impact_duration, 4)) list = [ i - 1, round(loan_index.total_interest_paid, 2), loan_index.time_to_loan_termination, round(micro_impact_interest_paid, 4), round(micro_impact_duration, 4) ] df.loc[len(df)] = list i += 1 df = df.reset_index(drop=True) return df
def compute_impacts(self): # setup a loan portfolio # loan_portfolio = LoanPortfolio() # loan with all contributions (mi)_all # loan_all = Loan(principal=self.principal, rate=self.rate, payment=self.payment, extra_payment=self.extra_payment + sum(self.contributions)) loan_all.check_loan_parameters() loan_all.compute_schedule() # loan with no contributions (mi)_0 # loan_none = Loan(principal=self.principal, rate=self.rate, payment=self.payment, extra_payment=self.extra_payment) loan_none.check_loan_parameters() loan_none.compute_schedule() micro_impact_interest_paid_all = \ (loan_none.total_interest_paid - loan_all.total_interest_paid) / loan_all.total_interest_paid micro_impact_duration_all = -\ (loan_none.time_to_loan_termination - loan_all.time_to_loan_termination) / loan_all.time_to_loan_termination # micro_impact_interest_paid_all = loan_none.total_interest_paid / loan_all.total_interest_paid # micro_impact_duration_all = loan_none.time_to_loan_termination / loan_all.time_to_loan_termination self.results.append(['Index','InterestPaid','Duration','MIInterest','MIDuration']) self.results.append(['All', round(loan_all.total_interest_paid, 2), loan_all.time_to_loan_termination, None, None ]) self.results.append(['0', round(loan_none.total_interest_paid, 2), loan_none.time_to_loan_termination, round(micro_impact_interest_paid_all, 4), round(micro_impact_duration_all, 4) ]) # iterate over each contribution (mi)_index # for index, contribution in enumerate(self.contributions): loan_index = Loan(principal=self.principal, rate=self.rate, payment=self.payment, extra_payment=self.extra_payment + sum(self.contributions) - contribution) loan_index.check_loan_parameters() loan_index.compute_schedule() micro_impact_interest_paid = \ (loan_index.total_interest_paid - loan_all.total_interest_paid) / loan_all.total_interest_paid micro_impact_duration = \ (loan_index.time_to_loan_termination - loan_all.time_to_loan_termination) / loan_all.time_to_loan_termination # micro_impact_interest_paid = loan.total_interest_paid / loan_all.total_interest_paid # micro_impact_duration = loan.time_to_loan_termination / loan_all.time_to_loan_termination self.results.append([str(index+1), round(loan_index.total_interest_paid, 2), loan_index.time_to_loan_termination, round(micro_impact_interest_paid, 4), round(micro_impact_duration, 4) ])
from Loan import Loan from PaymentSchedules import Standard_Repayment from PaymentSchedules import Extended_Repayment from PaymentSchedules import Graduated_Repayment from PaymentSchedules import ICR l = Loan() p = ICR(l, income=60000) total_payment_count = l.loan_length * p.payment_frequency stepsize = 1 medschool = 12 * 4 #months of forebearance l.CalculateInterest(period=12 * 4) l.Capitalization() #residency starts p.ChangeIncomeLevel(60000) while l.debt_timestep < total_payment_count: if l.debt_timestep == 12.0 * 6: p.ChangeIncomeLevel(200000) l.CalculateInterest(period=stepsize) payment = p.CurrentPayment(l) l.MakePayment(payment=payment)
def compute_impacts(self): table = "" dict = {} # setup a loan portfolio # loan_portfolio = LoanPortfolio() # loan with all contributions (mi)_all # loan_all = Loan(principal=self.principal, rate=self.rate, payment=self.payment, extra_payment=self.extra_payment + sum(self.contributions)) loan_all.check_loan_parameters() loan_all.compute_schedule() # loan with no contributions (mi)_0 # loan_none = Loan(principal=self.principal, rate=self.rate, payment=self.payment, extra_payment=self.extra_payment) loan_none.check_loan_parameters() loan_none.compute_schedule() micro_impact_interest_paid_all = \ (loan_none.total_interest_paid - loan_all.total_interest_paid) / loan_all.total_interest_paid micro_impact_duration_all = -\ (loan_none.time_to_loan_termination - loan_all.time_to_loan_termination) / loan_all.time_to_loan_termination # micro_impact_interest_paid_all = loan_none.total_interest_paid / loan_all.total_interest_paid # micro_impact_duration_all = loan_none.time_to_loan_termination / loan_all.time_to_loan_termination table += '\nIndex\tInterestPaid\tDuration\tMIInterest\tMIDuration' table += '\nALL \t\t' + str(round( loan_all.total_interest_paid, 2)) + '\t\t' + str( loan_all.time_to_loan_termination) table += '\n0\t\t\t' + str(round( loan_none.total_interest_paid, 2)) + '\t\t' + str( loan_none.time_to_loan_termination) table += '\t\t' + str(round(micro_impact_interest_paid_all, 4)) + '\t' + str( round(micro_impact_duration_all, 4)) dict["All"] = ("All", round(loan_all.total_interest_paid, 2), loan_all.time_to_loan_termination, "", "") dict[0] = (0, round(loan_all.total_interest_paid, 2), loan_all.time_to_loan_termination, round(micro_impact_interest_paid_all, 4), round(micro_impact_duration_all, 4)) # iterate over each contribution (mi)_index # for index, contribution in enumerate(self.contributions): loan_index = Loan(principal=self.principal, rate=self.rate, payment=self.payment, extra_payment=self.extra_payment + sum(self.contributions) - contribution) loan_index.check_loan_parameters() loan_index.compute_schedule() micro_impact_interest_paid = \ (loan_index.total_interest_paid - loan_all.total_interest_paid) / loan_all.total_interest_paid micro_impact_duration = \ (loan_index.time_to_loan_termination - loan_all.time_to_loan_termination) / loan_all.time_to_loan_termination # micro_impact_interest_paid = loan.total_interest_paid / loan_all.total_interest_paid # micro_impact_duration = loan.time_to_loan_termination / loan_all.time_to_loan_termination table += '\n' + str(index + 1) + '\t\t\t' + str( round(loan_index.total_interest_paid, 2)) + '\t\t' + str( loan_index.time_to_loan_termination) table += '\t\t' + str(round(micro_impact_interest_paid, 4)) + '\t' + str( round(micro_impact_duration, 4)) dict[index + 1] = (index + 1, round(loan_index.total_interest_paid, 2), loan_index.time_to_loan_termination, round(micro_impact_interest_paid, 4), round(micro_impact_duration, 4)) print(table) print("111") return (dict)
def main(): l = Loan() l.setBorrower("스니") print("borrower is ", l.getBorrower())
def test008_loan(self): L = Loan(self.D, '18252023049', 'cjs123456') L.loan(u'善楼贷', u'等额本息', '6', '20000', u'扩大经营')