fork(1) download
  1.  
  2.  
  3. import pandas as pd
  4. import matplotlib.pyplot as plt
  5.  
  6. # Constants
  7. monthly_sip = 100000 # Monthly SIP amount in INR
  8. inflation_rate = 0.15 # 15% annual inflation
  9. tax_rate = 0.125 # LTCG Tax rate (12.5%)
  10. rate_of_return_annual = 0.135 # 13.5% annual return
  11.  
  12. # Calculating monthly rate of return
  13. rate_of_return_monthly = rate_of_return_annual / 12
  14.  
  15. # Function to calculate SIP corpus at the end of each year
  16. def calculate_sip_corpus(P, i, n):
  17. """Calculate Future Value of SIP"""
  18. return P * (((1 + i) ** n - 1) / i) * (1 + i)
  19.  
  20. # Function to calculate inflated price of the item
  21. def calculate_inflated_price(initial_price, inflation_rate, years):
  22. """Calculate the inflated price of the item"""
  23. return initial_price * ((1 + inflation_rate) ** years)
  24.  
  25. # Function to calculate taxable profits and LTCG tax
  26. def calculate_taxable_profits_and_tax(total_sip_contributions, corpus, tax_rate):
  27. """Calculate taxable profits and LTCG tax"""
  28. profits = corpus - total_sip_contributions
  29. tax = profits * tax_rate
  30. post_tax_profits = profits - tax
  31. return profits, tax, post_tax_profits
  32.  
  33. # Initial values
  34. initial_item_price = 15000000 # Initial item price in INR (1.5 crore)
  35. total_sip_contributions = 0 # Total SIP contributions, initialized to zero
  36. corpus = 0 # SIP corpus, initialized to zero
  37.  
  38. # Store results for each 5-year interval
  39. output_data = []
  40.  
  41. # Simulating the SIP for 30 years
  42. for year in range(5, 31, 5):
  43. # Number of months till the current 5-year period
  44. n_months = 12 * year
  45.  
  46. # Calculate SIP corpus for this period
  47. corpus = calculate_sip_corpus(monthly_sip, rate_of_return_monthly, n_months)
  48.  
  49. # Total SIP contributions are simply the SIP amount multiplied by the number of months
  50. total_sip_contributions = monthly_sip * n_months
  51.  
  52. # Calculate the inflated price of the item after 'year' years
  53. inflated_price = calculate_inflated_price(initial_item_price, inflation_rate, year)
  54.  
  55. # Calculate taxable profits, tax, and post-tax profits
  56. profits, tax, post_tax_profits = calculate_taxable_profits_and_tax(total_sip_contributions, corpus, tax_rate)
  57.  
  58. # Prepare the output string in the desired format
  59. output_data.append({
  60. "Period": f"Year {year - 4} to {year}",
  61. "Contributed Amount Till Now": f"{total_sip_contributions / 1e7:.2f} Cr",
  62. "Profits Made Till Now": f"{profits / 1e7:.2f} Cr",
  63. "Total Taxes Till Now": f"{tax / 1e5:.2f} L",
  64. "Total Amount Available for Withdrawal": f"{post_tax_profits / 1e7:.2f} Cr",
  65. "Inflated Value of Asset": f"{inflated_price / 1e7:.2f} Cr"
  66. })
  67.  
  68. # Create a DataFrame to display the results
  69. df_output = pd.DataFrame(output_data)
  70.  
  71. # Display the output for each 5-year period
  72. print("SIP Investment Overview (Every 5 Years):")
  73. for row in df_output.itertuples(index=False, name=None):
  74. print(f"\n{row[0]} --")
  75. print(f" - Contributed amount till now: {row[1]}")
  76. print(f" - Profits made from SIP till now: {row[2]}")
  77. print(f" - Total taxes paid (12.5% of profits): {row[3]}")
  78. print(f" - Total amount available for withdrawal: {row[4]}")
  79. print(f" - Inflated value of the asset at this time: {row[5]}")
  80.  
  81. # Plotting the data (optional)
  82. plt.figure(figsize=(12, 8))
  83.  
  84. # Plot SIP Corpus vs Year
  85. plt.plot(df_output['Period'], df_output['Total Amount Available for Withdrawal'], label='Total Amount Available for Withdrawal', marker='o', color='b')
  86.  
  87. # Adding title and labels
  88. plt.title('Comparison of Total Amount Available for Withdrawal Over 30 Years')
  89. plt.xlabel('Year Period')
  90. plt.ylabel('Amount in INR')
  91.  
  92. # Show the plot
  93. plt.grid(True)
  94. plt.xticks(rotation=45)
  95. plt.tight_layout()
  96. plt.show()
  97.  
Success #stdin #stdout 3.08s 85648KB
stdin
Standard input is empty
stdout
SIP Investment Overview (Every 5 Years):

Year 1 to 5 --
 - Contributed amount till now: 0.60 Cr
 - Profits made from SIP till now: 0.26 Cr
 - Total taxes paid (12.5% of profits): 3.25 L
 - Total amount available for withdrawal: 0.23 Cr
 - Inflated value of the asset at this time: 3.02 Cr

Year 6 to 10 --
 - Contributed amount till now: 1.20 Cr
 - Profits made from SIP till now: 1.34 Cr
 - Total taxes paid (12.5% of profits): 16.78 L
 - Total amount available for withdrawal: 1.17 Cr
 - Inflated value of the asset at this time: 6.07 Cr

Year 11 to 15 --
 - Contributed amount till now: 1.80 Cr
 - Profits made from SIP till now: 4.03 Cr
 - Total taxes paid (12.5% of profits): 50.43 L
 - Total amount available for withdrawal: 3.53 Cr
 - Inflated value of the asset at this time: 12.21 Cr

Year 16 to 20 --
 - Contributed amount till now: 2.40 Cr
 - Profits made from SIP till now: 9.88 Cr
 - Total taxes paid (12.5% of profits): 123.45 L
 - Total amount available for withdrawal: 8.64 Cr
 - Inflated value of the asset at this time: 24.55 Cr

Year 21 to 25 --
 - Contributed amount till now: 3.00 Cr
 - Profits made from SIP till now: 21.88 Cr
 - Total taxes paid (12.5% of profits): 273.50 L
 - Total amount available for withdrawal: 19.15 Cr
 - Inflated value of the asset at this time: 49.38 Cr

Year 26 to 30 --
 - Contributed amount till now: 3.60 Cr
 - Profits made from SIP till now: 45.94 Cr
 - Total taxes paid (12.5% of profits): 574.27 L
 - Total amount available for withdrawal: 40.20 Cr
 - Inflated value of the asset at this time: 99.32 Cr