loan_planner package¶
Submodules¶
loan_planner.heuristics module¶
-
loan_planner.heuristics.
first_loan_heuristic
(loans, daysSinceLastPayment)¶ Return the first loan in the list.
-
loan_planner.heuristics.
is_heuristic_function
(obj)¶ Return true if the given object represents a heuristic function.
-
loan_planner.heuristics.
max_balance_heuristic
(loans, daysSinceLastPayment)¶ Return the loan with the highest balance.
-
loan_planner.heuristics.
max_interest_accrual_heuristic
(loans, daysSinceLastPayment)¶ Return the loan which accrues the most interest in a year.
-
loan_planner.heuristics.
max_interest_rate_heuristic
(loans, daysSinceLastPayment)¶ Return the loan with the highest interest rate.
-
loan_planner.heuristics.
max_ipr_heuristic
(loans, daysSinceLastPayment)¶ Return the loan with the highest interest-to-monthly-payment ratio.
-
loan_planner.heuristics.
min_percent_payment_applied_heuristic
(loans, daysSinceLastPayment)¶ Return the loan with the lowest percentage of its monthly payment applied to the loan’s principal.
-
loan_planner.heuristics.
random_heuristic
(loans, daysSinceLastPayment)¶ Return a random loan.
loan_planner.loan_config module¶
loan_config
-
class
loan_planner.loan_config.
Loan
(name, balance, interestRate, monthlyPayment, paymentDay)¶ Bases:
object
Class to store data pertaining to a loan.
Methods
get_interest_accrued
(daysAccrued)Calculate the amount of interest accrued in the given number of days. get_interest_to_payment_ratio
(daysAccrued)Calcuate the ratio of the interest paid over a period of time to the monthly payment. get_payment_amount
()Return the monthly payment amount, or the loan balance if the balance is less than the monthly payment. -
get_interest_accrued
(daysAccrued)¶ Calculate the amount of interest accrued in the given number of days.
-
get_interest_to_payment_ratio
(daysAccrued)¶ Calcuate the ratio of the interest paid over a period of time to the monthly payment.
-
get_payment_amount
()¶ Return the monthly payment amount, or the loan balance if the balance is less than the monthly payment.
-
-
class
loan_planner.loan_config.
LoanConfig
(loanConfigFilePath)¶ Bases:
object
Configuration options for the loan planner.
Methods
any_changes
()Return true if there were any plan changes in the global options. parsed
()Return true if the INI file has been parsed successfully. -
BALANCE
= 'Balance'¶
-
DATE_FORMAT
= '%m/%d/%Y'¶
-
DATE_OF_BIRTH
= 'DateOfBirth'¶
-
DEFAULTS
= {'UpfrontPayment': '0', 'MonthlyIncrease': '0', 'MonthlyPayment': '0', 'PaymentDay': '1', 'DateOfBirth': '1/1/1900', 'InterestRate': '0', 'Balance': '0'}¶
-
INTEREST_RATE
= 'InterestRate'¶
-
MONTHLY_INCREASE
= 'MonthlyIncrease'¶
-
MONTHLY_PAYMENT
= 'MonthlyPayment'¶
-
OPTIONS
= 'Options'¶
-
PAYMENT_DAY
= 'PaymentDay'¶
-
UPFRONT_PAYMENT
= 'UpfrontPayment'¶
-
any_changes
()¶ Return true if there were any plan changes in the global options.
-
parsed
()¶ Return true if the INI file has been parsed successfully.
-
loan_planner.loan_planner module¶
Simulate the payment of a set of loans to suggest an improved payment plan.
Example¶
python loan_planner.py -c loans.ini
-
class
loan_planner.loan_planner.
LoanPlanner
(loanConfigFilePath)¶ Bases:
object
Class to evaluate loan payment plans using a variety of metrics, taking into consideration any user-specified payment changes.
Methods
find_best_plan
()Simulate the payment of all loans before and after changes to the payment plans, using all available metrics. -
find_best_plan
()¶ Simulate the payment of all loans before and after changes to the payment plans, using all available metrics. Decide which of all plans is the best.
-
-
loan_planner.loan_planner.
main
()¶
loan_planner.payment_device module¶
-
class
loan_planner.payment_device.
PaymentDevice
(dateOfBirth, loans, allocationDecider, bestDevice=None)¶ Bases:
object
Class to simulate paying loans over time.
Methods
pay_loans
()Make monthly loan payments until all loans are paid off. -
DAYS_PER_MONTH
= 30.436875¶
-
MAX_YEAR
= 3000¶
-
ONE_DAY_DELTA
= relativedelta(days=+1)¶
-
ONE_MONTH_DELTA
= relativedelta(months=+1)¶
-
pay_loans
()¶ Make monthly loan payments until all loans are paid off. When a loan is paid, reallocate that loan’s monthly payment to another loan. Return a boolean indicating if the simulation was successful.
-
-
class
loan_planner.payment_device.
PaymentStats
(dateOfBirth, isRelative=False)¶ Bases:
object
Class to store statistics about a payment device, or a comparison of two sets of statistics about payment devices.
Methods
compare
(other)Construct a PaymentStats instance to represent the comparison of these payment statistics to another set of statistics. -
compare
(other)¶ Construct a PaymentStats instance to represent the comparison of these payment statistics to another set of statistics.
-
-
loan_planner.payment_device.
get_age_on_date
(dateOfBirth, date)¶ Determine the age a person would be on the given date.
-
loan_planner.payment_device.
to_months
(timeDiff)¶ Convert a relativedelta instance to raw months.