• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# ISA Calculator

a guest Jan 23rd, 2018 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import matplotlib.pyplot as plt
2.
3. goal = 100000
4. in_years = True
5.
7. def htb(P=1200, r=0.04, c=200):
8.     m = 1
9.     balance = []
10.     months = []
11.     while P <= goal:
12.         if m % 12 == 0:
13.             gains = (P * r)
14.             P += gains
15.         if in_years:
16.             months.append(m / 12.)
17.         else:
18.             months.append(m)
19.         balance.append(P)
20.         m += 1
21.         P += c
22.     return months, balance
23.
25. def lft(P=1200, r=0.075, c=4000/12.):
26.     m = 1
27.     balance = []
28.     months = []
29.     while P <= goal:
30.         if m % 12 == 0:
31.             gains = (P * r)
32.             P += gains
33.             P += 1000
34.         if in_years:
35.             months.append(m / 12.)
36.         else:
37.             months.append(m)
38.         balance.append(P)
39.         m += 1
40.         P += c
41.     return months, balance
42.
43. # Calculate
44. htb_m, htb_b = htb()
45. lft_m, lft_b = lft()
46.
47. # Plot
48. plt.plot(htb_m, htb_b)
49. plt.plot(lft_m, lft_b)
50. plt.ylim(0, goal+1000)