Advertisement
Guest User

balance.py

a guest
Jan 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.53 KB | None | 0 0
  1. import sys
  2. import time
  3. from calendar import monthrange
  4. import numpy as np
  5. from matplotlib import pyplot as plt
  6.  
  7. bal = float(sys.argv[1])
  8. bal -= 1500
  9.  
  10. Sal = [26, 1762]
  11. Payback = [6, 300]
  12. HCC = [8, -float(sys.argv[2])]#730
  13. NCC = [28, -float(sys.argv[3])]#1200
  14.  
  15. today = time.gmtime().tm_mday
  16. month = time.gmtime().tm_mon
  17. year = time.gmtime().tm_year
  18. max_day = monthrange(year, month)[1]
  19. s_day = 60*60*24
  20.  
  21. if today < HCC[0]:
  22.     days = HCC[0] + max_day - today
  23. elif today < NCC[0]:
  24.     days =  NCC[0] + max_day - today
  25. else:
  26.     days = HCC[0] + monthrange(year, month +1)[1] + max_day + - today
  27. if days < Sal[0] - today + max_day + 1:
  28.     days = Sal[0] - today + max_day + 1
  29.  
  30. data = {}
  31. for i in range(32):
  32.     data[i] = 0
  33.  
  34. data[1] -= 6 ## H Charity
  35. data[1] -= 16 ## LL Charity
  36. data[1] -= 220 ## Joint Bills
  37. data[26] -= 365 ## Rent
  38. data[28] -= 38 ## Phone
  39. data[Sal[0]] += Sal[1]
  40. data[Payback[0]] += Payback[1]
  41. data[NCC[0]] += NCC[1]
  42. data[HCC[0]] += HCC[1]
  43.  
  44. forecast = np.zeros(days)
  45. forecast[0] = bal
  46. for day in range(1, days):
  47.     forecast[day] = forecast[day - 1]
  48.     forecast[day] += data[time.gmtime(time.mktime(time.gmtime()) + day * s_day).tm_mday]
  49.  
  50. plt.figure()
  51. plt.plot((0, days), (0, 0), 'k--')
  52. plt.plot((0, Sal[0] - today), (forecast[Sal[0] - today], forecast[Sal[0] - today]), 'g--')
  53. plt.plot((0, Sal[0] - today + max_day), (forecast[Sal[0] - today + max_day], forecast[Sal[0] - today + max_day]), 'g--')
  54. plt.plot((max_day - today + 1, max_day - today + 1), (forecast.min(), forecast.max()), 'r--')
  55. plt.plot(forecast)
  56. plt.xlim(xmin = 0)
  57. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement