Permalink
Browse files

Initial distribution of v2.5 Beta

  • Loading branch information...
Dr Paul Brewer Dr Paul Brewer
Dr Paul Brewer authored and Dr Paul Brewer committed Oct 16, 2012
1 parent dadcabe commit 482a3ed26ad19db01c5da8b8367d61acd6065bd9
Showing with 1,822 additions and 423 deletions.
  1. +32 −17 README
  2. +104 −0 TVM.js
  3. +0 −361 UnofficialHampLib2.js
  4. +806 −0 UnofficialHampLib3.js
  5. +339 −0 gpl-2.0.txt
  6. +259 −0 jquery.jqplot.css
  7. +57 −0 jquery.jqplot.min.js
  8. +1 −1 license.html
  9. +180 −44 skin.html
  10. +12 −0 style.css
  11. +32 −0 underscore-min.js
View
49 README
@@ -1,7 +1,18 @@
Unofficial HAMP Calculator
-(c) Dr Paul Brewer 2010
-License: Free Software Foundation's General Public License (GPL) version 3
+(c) Dr Paul Brewer 2010, 2012-
+License: Free Software Foundation's General Public License (GPL) version 2
+or any later version of the FSF General Public License
+Please note that the License to use the software contains a warranty disclaimer
+so that THERE IS NO WARRANTY FOR THIS SOFTWARE and ALL USE IS AT YOUR OWN RISK.
+
+Such a disclaimer is common industry practice with respect to free software.
+
+Note: Dr Paul Brewer is an independent economist and did not work
+for the United States Government or any bank during the creation of this
+software. Also, no government or bank officials were involved in the creation
+or testing of the software. The algorithms involved are worthy of independent
+study, and the Unofficial HAMP Calculator represents such an independent study.
GENERAL BACKGROUND
During the recent credit crisis and recession in the United States, many
@@ -24,14 +35,8 @@ an existing mortgage.
The full details of this algorithm are beyond the scope of this version
of the README file.
-The algorithm is interesting and worthy of independent study
-The UnofficialHAMPCalculator represents such an independent study.
-
-I, Dr Paul Brewer, am a private economist with no ties to the US Government
-or the decision makers who created and implemented the HAMP program. Let's
-make that part clear.
-HAMP ALGORITHM
+AN INTRODUCTION TO THE HAMP ALGORITHM
Keep in mind that this is only one version of the procedure, and not
the whole procedure. The policy must be considered as subject to change.
@@ -59,16 +64,26 @@ to forgive some of this principal, but is not required to.
UNOFFICIAL CALCULATOR IMPLEMENTATION AND USAGE
-The calculator is implemented primarily in two files and uses the
-prototype.js Javascript extension library -- a copy of which is included.
+The calculator uses the folowing javascript extension libraries
+written by others:
+
+JQuery (no copy needed, html includes the Google public CDN copy)
+Underscore.js (copy provided, distrubuted under the MIT License)
+JQPlot (copies provided, distributed under the GNU GPL v2 License)
+
+The skin.html file contains the "skin" of the calculator. If you want
+to test your download of the calculator, open "skin.html" in firefox
+or google chrome.
-The skin.html file contains the "skin" of the calculator.
+The UnofficialHampLib3.js file contains the Javascript program code to implement
+the calculator.
-The UnofficialHampLib2.js file contains the Javascript program code to implement
-the calculator.
+The TVM.js file contains a library of mathematical Time Value of Money and
+Loan functions.
-I am making these files are made available under the Free Software Foundation's
-GNU General Public License version 3.0. However, that does not mean anyone
+I am making these files available under the Free Software Foundation's
+GNU General Public License version 2.0 (or any subsequent version of the license
+as released by the Free Software Foundation). However, that does not mean anyone
can do anything with the files. Please read the license to understand
what is permitted. For example, you may NOT modify this calculator and turn
the result into proprietary software where you control who can further
@@ -84,7 +99,7 @@ prototype.
I believe people have a right to get independent information about
how their mortgages may be modified and I have a website, ArmDisarm.com,
-that I am interested in devoting to benevolent entrepreneurship in this area.
+devoted to benevolent entrepreneurship in this area.
View
104 TVM.js
@@ -0,0 +1,104 @@
+// (c) 2012 Paul Brewer
+// Part of Unofficial HAMP Loan Modification Calculator
+// This File Licensed to the Public under the GNU GPL v2.0 License
+// or any later version
+// see license file: gpl-2.0.txt
+//
+// These six functions are textbook time-value-of-money factors.
+// Go read wikipeia "Time Value of Money" for a crash course on this subject.
+// The original software author, Dr Brewer, taught this subject as part of
+// "Engineering Economics" in Hong Kong for about 4 years.
+//
+// These function convert between
+// present values P, future values F, flow values A
+// rates are 8 for 8%/year, but n is in months so r is scaled at the
+// beginning of each function by 1/1200 so that we can correctly
+// apply the classic formulas.
+//
+
+TVM = {
+ 'PoverA': function PoverA(r, n) {
+ r = r / 1200.0;
+ return (r<0.000001)? n: ( (1.0 - Math.pow(1.0 + r, -n)) / r);
+ },
+
+ 'AoverP': function AoverP(r, n) {
+ r = r / 1200.0;
+ return (r<0.000001)? (1/n) : (r / (1.0 - Math.pow(1.0 + r, -n)));
+ },
+
+ 'FoverP': function FoverP(r, n) {
+ r = r / 1200.0;
+ return Math.pow(1.0 + r, n);
+ },
+
+ 'PoverF': function PoverF(r, n) {
+ r = r / 1200.0;
+ return Math.pow(1.0 + r, -n);
+ },
+
+ 'FoverA': function FoverA(r, n) {
+ r = r / 1200.0;
+ return (r<0.000001)? n : ( (Math.pow(1.0 + r, n) - 1) / r);
+ },
+
+ 'AoverF': function AoverF(r, n) {
+ r = r / 1200.0;
+ return (r<0.000001)? (1/n) : ( r / (Math.pow(1.0 + r, n) - 1) );
+ }
+};
+// end standard time-value-of-money functions
+
+
+TVM.StandardLoanPayment = function StandardLoanPayment(Rate, LoanAmt, TermInMonths) {
+ return TVM.AoverP(Rate, TermInMonths) * LoanAmt;
+};
+
+
+TVM.StandardLoanFutureBalance = function StandardLoanFutureBalance(Rate, LoanAmt, Month, MonthlyPayment) {
+ return TVM.FoverP(Rate, Month) * LoanAmt - TVM.FoverA(Rate, Month) * MonthlyPayment;
+};
+
+TVM.VariableRateLoanPaymentArray=function VariableRateLoanPaymentArray(LoanAmt, TermInMonths, startRate, MonthArray, RateArray) {
+ // This calculates a payment array for a single complex loan.
+ // The payment array is a sparse array and shows the changes in payments.
+ //
+ // Payments at other months match the previous step, the entire payment
+ // profile can be determined as a stairstep function with steps months
+ // given in the MonthArray rates in the RateArray and payments
+ // in the output of this function which we call a PaymentArray
+ //
+ // the loan is for an amortizing, interest-bearing amount LoanAmt
+ // the term is TermInMonths
+ // the initial interest rate is startRate
+ // the MonthArray lists the months when the rates change
+ // this array should be strictly increasing
+ // the RateArray lists what the rates will be
+ // rates may go up or down but the length of the array should match
+ // the length of MonthArray
+ // the output will be an array of identical length giving monthly payments
+ // (to get the start rate monthly payment use "StandardLoanPayment()")
+
+ var changes = MonthArray.length;
+ var payments = new Array(changes);
+
+ // initial state for the for loop; will be updated each iteration
+ var RemainingBalance = LoanAmt;
+ var prevMonth = 0;
+ var prevRate = startRate;
+ var prevPayment = TVM.StandardLoanPayment(prevRate, LoanAmt, TermInMonths);
+ var j=0,newMonth=0,newRate=0;
+
+ for(j = 0; j < changes; ++j) {
+ newMonth = MonthArray[j];
+ newRate = RateArray[j];
+ RemainingBalance = TVM.StandardLoanFutureBalance(prevRate, RemainingBalance, newMonth - prevMonth, prevPayment);
+ payments[j] = TVM.StandardLoanPayment(newRate, RemainingBalance, TermInMonths - newMonth);
+ prevMonth = newMonth;
+ prevRate = newRate;
+ prevPayment = payments[j];
+ }
+
+ return payments;
+
+};
Oops, something went wrong.

0 comments on commit 482a3ed

Please sign in to comment.