Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Assignment: Amortization and Rolling Window

Statistics

Python and Applications to Business Analytics

Python and Applications to Finannce

Exercise  1. Amortization

Amortization is a method of repaying a loan through regular payments of interest and prin- cipal.  The size of the loan (the original balance) is reduced by the principal part of the payment.   The interest part of the payment pays the interest incurred on the remaining principal balance.  As the principal gets paid down over the term of the loan, the interest part of the payment diminishes.

A new loan is typically issued with the following metrics:

❼ Principal: amount of the loan

❼ Interest Rate: annual interest rate

❼ Term: amount of time to pay back the loan with monthly payments

For instance, a given 15-year $250,000 at an 8.0% interest rate, the monthly payment of $2,389.13 is expected over the 180 (15 years * 12 payments per year) payments. An online calculator exists to verify this calculation.

Please note that borrowers have the option to make an extra payment which will be ap- plied to the principal. Extra payments will lower the principal and thus the loan can be paid in full earlier than expected. A typical payment schedule with no extra payment is seen in the following.

Month

Begin P

Payment

Interest

Extra Payment

P Applied

End P

1

250,000.00

2,389.13

1,666.66

0.00

722.46

249,277.53

2

249,277.53

2,389.13

1,661.85

0.00

727.27

248,550.25

3

248,550.25

2,389.13

1,657.00

0.00

732.12

247,818.12

178

7,072.94

2,389.13

47.15

0.00

2,341.97

4,730.97

179

4,730.97

2,389.13

31.53

0.00

2,357.59

2,373.38

180

2,373.38

2,389.13

15.82

0.00

2,373.30

0.00

Total

430,043.44

180,043.43

 

250,000.00

Write a Python computer program to do the following:

❼ Get user input of principal, minimum expected payment, interest, and extra payment,

and error check that all input is valid. If not valid, have the user re-enter. Note that one does not need to enter the term of the loan.

❼ Compute and print the schedule of payments, similar to the table shown above.

❼ Compute and print the total (sum of all) payments, interest paid, and principal applied.

❼ Compute and print the total time (in years) required to payoff the loan.

The computer program should leverage comments,  readability,  and above all,  efficiency. Please note that I have attached a spreadsheet that computes the payment schedule.  The spreadsheet will greatly enhance your ability to code the solution by understanding the nature of calculations.

Exercise  2. Rolling Window Statistics

Attached is a le containing named GOOG.csv which has daily market prices over one year. With the data, compute a rolling window statistics with the statistics being:

❼ Min, Max, and Mean

 Bollinger Bands: Mean +/- 2.0 * Standard Deviation

Write a Python computer program to do the following:

❼ From the user, input the rolling window size. For instance, inputting 5 would yield a

weekly window, 20 would be a monthly window, etc. Make sure that the input is valid. For instance, if a user inputs 400 but the time series only has 250 daily prices, this is not valid input.

❼ Over the rolling window size, compute the statistics mentioned above. Attached also is a le named read le.py for reading data from a le.