The Ultimate Guide to Smart Investment Planning and Wealth Withdrawal Using Python
Investing can be one of the most powerful ways to secure your financial future, but it comes with a maze of decisions: how much to invest, where to invest, and how to manage withdrawals when the time comes. Wouldn’t it be great to have a tool that helps you model your financial future, factoring in growth rates, inflation, and taxes? While we can't predict the market, we can use Python to build an investment simulator that brings clarity to your planning.
In this blog, we’ll explore how a simple yet powerful Python script can simulate your investments over time, handle tax implications, and help you understand how long your savings will last. By the end of this post, you'll have the tools to make informed financial decisions and visualize your investment outcomes.
We're exploring a strategic approach to building lasting wealth: invest consistently for a few years with annual increments, let your investments grow, and then strategically sell them when you’re ready to stop working. While selling incurs taxes, this marks the transition to a new phase—retirement—where you live off your withdrawals. At this point, you can reinvest your gains into safer assets, like debt or large-cap funds, which offer reduced but stable earnings. With a target monthly income in mind, the plan is to withdraw an inflation-adjusted amount each month, continually adjusting to ensure your lifestyle is sustained as long as possible, until the funds eventually run out or you die.
Why Investment Planning Is Essential
Before diving into the code, let’s talk about why investment planning is crucial. You may think simply putting your money into a savings account or investing without a strategy is good enough, but this approach can have consequences:
The Power of Compound Growth: Small, consistent investments can snowball into a significant sum over time, thanks to compounding. However, to fully realize this power, you need to invest strategically.
Combating Inflation: Inflation erodes the purchasing power of money, meaning what you can buy today with a given amount will likely cost more in the future. Planning for inflation ensures your investments outpace these rising costs.
Tax Efficiency: Taxes can significantly impact your investment returns. Proper planning minimizes tax liabilities, allowing you to retain more of your hard-earned gains.
Sustainable Withdrawals: For retirees or those planning to live off their investments, knowing how much you can withdraw each year without depleting your funds is critical.
This Python investment simulator addresses all these factors, giving you a comprehensive view of your financial future.
The Core Components of the Python Script
Our investment simulator models your financial journey from the accumulation phase (where you’re building wealth) to the decumulation phase (where you’re withdrawing funds). Here’s an in-depth look at how the script works:
Constants and Setup
The script starts by defining important constants, such as the number of months in a year and the formulas for monthly growth and inflation rates:
months_per_year = 12
max_csv_months = 100 * months_per_year # Limit CSV output to 100 years
annual_return_rate = annual_return_percent / 100
monthly_growth_rate = (1 + annual_return_rate) ** (1 / months_per_year) - 1
annual_inflation_rate = annual_inflation_percent / 100
These constants ensure our calculations are precise and reflect real-world financial dynamics.
Customizing Your Investment Strategy
One of the most exciting aspects of this Python code is that you can tailor it to match your financial situation and goals. Here are the key parameters you can adjust:
Initial Monthly Investment
initial_monthly_investment = 130000 # in currency units
- This is the amount you invest every month. Adjust it based on your income and how much you’re willing to allocate for long-term growth.
Yearly Increment Percentage
yearly_increment_percent = 2 # Annual increase in your monthly investment
- As your income grows, you might increase your monthly investment. This parameter models that growth. For example, if you expect a 5% annual salary raise, you might increase your contributions accordingly.
Annual Return Percentage
annual_return_percent = 17 # Expected annual return on your investment
- This rate varies depending on your investment strategy. Stocks typically offer higher returns (but with more risk), while bonds are safer but yield less.
Number of Years to Invest
years = 12 # Duration of the accumulation phase
- Set this to the number of years you plan to invest before making withdrawals. Longer investment horizons generally yield better returns due to compounding.
Annual Inflation Percentage
annual_inflation_percent = 5 # Expected inflation rate
- Inflation reduces the purchasing power of your money. This parameter helps simulate how much you’ll need to withdraw in the future to maintain your current lifestyle.
Desired Monthly Amount in Hand
desired_monthly_in_hand = 100000 # Amount needed each month in today's money
- This is the amount you’ll need each month during retirement or the withdrawal phase. The code adjusts this amount for inflation, ensuring your purchasing power remains consistent.
Withdrawal Fund Growth Percentage
withdrawal_fund_growth_percent = 8 # Annual return during the withdrawal phase
- Even when you start withdrawing funds, your remaining investments will likely continue to grow. This parameter models the expected return during the withdrawal phase.
LTCG and STCG Tax Percentages
ltcg_tax_percent = 12.5 # Tax on long-term gains stcg_tax_percent = 20 # Tax on short-term gains
- Different types of gains are taxed differently. Adjust these values to match your local tax regulations.
The Investment Phase: Building Your Wealth
The code simulates monthly investments over several years, adjusting for annual increments. Each investment is treated as a separate “lot” to simplify tax calculations later.
for year in range(1, years + 1):
for month in range(months_per_year):
lot_name = f"{calendar.month_name[current_month]} {current_year}"
total_invested_amount += monthly_investment
investment_lots.append([lot_name, monthly_investment, monthly_investment, 0])
# Compounding growth
for lot in investment_lots:
lot[2] *= (1 + monthly_growth_rate)
lot[3] += 1
Each lot grows at the monthly rate, simulating the compounding effect that makes investing so powerful. The result is a growing investment balance that can fund your future withdrawals.
Handling Taxes: LTCG and STCG
When it’s time to start withdrawing, the script first sells all investments and calculates taxes. Investments held for over 12 months incur LTCG taxes, while those held for less incur STCG taxes.
while investment_lots:
lot_name, principal_component, current_value, age = investment_lots.popleft()
profit = current_value - principal_component
if age >= 12:
initial_ltcg_tax += profit * ltcg_tax_rate if profit > 0 else 0
else:
initial_stcg_tax += profit * stcg_tax_rate if profit > 0 else 0
This step ensures that your net proceeds after taxes are as accurate as possible, helping you understand your actual available funds.
The Withdrawal Phase: Sustaining Your Wealth
The most critical part of any financial plan is ensuring your money lasts. Our code simulates monthly withdrawals adjusted for inflation, ensuring your lifestyle remains consistent.
monthly_withdrawal = gross_monthly_withdrawal
withdrawal_months = 0
# Adjust withdrawals for inflation and grow the remaining fund
while withdrawal_months < max_csv_months:
if fund_balance < monthly_withdrawal:
# If funds are insufficient, sell everything and calculate taxes
...
else:
# Withdraw the target amount, prioritizing older lots for tax efficiency
...
monthly_withdrawal *= (1 + annual_inflation_rate / 12)
The withdrawal strategy prioritizes selling older lots to minimize taxes and adjusts the withdrawal amount for inflation each month.
A Comprehensive Financial Report
The script generates a detailed summary and a CSV report that captures your financial journey month by month. Here’s what you’ll see in the output:
Investment Summary: How much you invested, the annual return, and the total value when you started withdrawing.
Tax Summary: A breakdown of LTCG and STCG taxes, both at the start of withdrawals and over time.
Duration of Funds: How many years and months your money will last, even with inflation-adjusted withdrawals.
Example Output
You invested 1.30 lacs INR per month for 12 years, which grew at 17% per year.
Your investments increased at 2% per year.
The value of the fund when you stopped investing and started withdrawing
was 5.53 crore INR and 3.08 crore INR adjusted for inflation.
You sold all the funds and incurred 48.92 lacs INR in LTCG and
29.37 thousand INR in STCG, totaling 49.22 lacs INR.
We reinvested the remaining 5.53 crore INR into 100 different lots,
which will grow at 8% per year, and started withdrawing.
You need 1.00 lacs INR per month in today's money.
The starting withdrawal will be 1.80 lacs INR adjusted for
12 years of inflation at 5% per year.
The withdrawals will increase every month to adjust for inflation.
The fund lasted for 34 years and 5 months in the withdrawal phase.
Summary of Taxes:
Initial LTCG Tax at the start of withdrawal: 48.92 lacs INR
Initial STCG Tax at the start of withdrawal: 29.37 thousand INR
LTCG Tax during systematic withdrawals: 2.13 crore INR
STCG Tax during systematic withdrawals: 14.58 thousand INR
Total LTCG Tax (bulk sale + withdrawals): 2.62 crore INR
Total STCG Tax (bulk sale + withdrawals): 43.95 thousand INR
Imagine investing consistently from the age of 30 to 42, dedicating just 12 years to building your financial foundation. With the power of compounding and strategic planning, that relatively short investment period can set you up for a life of financial freedom, allowing you to comfortably retire and sustain yourself until the age of 75. By the time you reach 42, your carefully managed investments could have grown into a massive fund that not only supports your desired lifestyle but also adjusts for inflation, ensuring your wealth retains its purchasing power over the decades.
This means you can enjoy the fruits of your labor, experience peace of mind, and make the most of your golden years without financial stress—all because you committed to investing smartly for just 12 impactful years. The path to early retirement and a worry-free future may be simpler and more attainable than you think!
The CSV File: A Comprehensive Record of Your Financial Journey
One of the most valuable outputs of this Python script is a detailed CSV report. The file contains all the data you need to analyze your investment and withdrawal plan in depth, making it perfect for tracking, planning, or even sharing with your financial advisor.
What’s Inside the CSV File?
The CSV file includes the following columns:
Month: The total number of months since you started investing. This helps you keep track of the timeline and correlate it with your life plans.
Fund Balance: The total value of your investments at the end of each month. It includes the compounded growth from your monthly contributions during the investment phase and the reduced balance during the withdrawal phase.
Investment That Month: The amount you invested in that particular month. During the investment phase, this value is your monthly contribution. Once the investment phase ends, this becomes zero.
Inflation-Adjusted Value: The real value of your fund balance after adjusting for inflation. This column helps you understand the purchasing power of your investments over time, which is crucial for long-term planning.
Gross Withdrawal: The amount you withdrew before accounting for taxes. During the investment phase, this is zero. In the withdrawal phase, it starts with the inflation-adjusted amount you need and increases each month to keep up with inflation.
Taxes to Pay: The taxes incurred on the withdrawn amount. This includes both LTCG and STCG taxes, and it is calculated based on the age of the lots you’re withdrawing from.
Net Withdrawal: The amount you receive after taxes are deducted. This is the money you have in hand to spend, making it an essential metric for planning your lifestyle.
Total Invested Amount: A running total of all the money you have invested over time. This helps you track how much of your wealth is the result of your contributions versus the returns on your investments.
Lots Sold: Detailed information about the investment lots you sold in that month. Each lot includes:
Lot Name: The month and year when the lot was created.
Value Sold: How much of the lot was sold.
Left: The remaining value of the lot after the sale.
Profit: The profit made from the sale.
Tax: The tax paid on that profit, either as LTCG or STCG, depending on how long the lot was held.
How to Use the CSV File
The CSV report provides a granular look at your financial journey and can be incredibly helpful in various ways:
Analyze Investment Growth: By reviewing the “Fund Balance” and “Inflation-Adjusted Value” columns, you can see how your investments grow over time and understand the real purchasing power of your wealth.
Track Contributions: The “Investment That Month” and “Total Invested Amount” columns help you keep an eye on your total contributions, making it easy to compare them with the returns you’ve earned.
Plan Withdrawals: The “Gross Withdrawal” and “Net Withdrawal” columns show how much money you’ll have in hand each month, helping you budget for future expenses.
Understand Tax Implications: Taxes can have a significant impact on your withdrawals. The “Taxes to Pay” and “Lots Sold” columns give you a clear picture of how taxes affect your income, allowing you to plan for tax-efficient withdrawals.
Evaluate Financial Milestones: You can pinpoint specific months where major changes occur, such as the start of withdrawals or significant tax events. This is useful for aligning your financial plan with life milestones like retirement, buying a house, or funding education.
Experimenting with Different Scenarios
The flexibility of this simulator allows you to model various financial situations:
Early Retirement: Adjust the number of years to invest to see how long your funds will last if you retire early.
Higher or Lower Inflation: Experiment with different inflation rates to understand how rising costs affect your future withdrawals.
Aggressive vs. Conservative Returns: Simulate both high-risk, high-reward strategies and safer, lower-return investments to see how each impacts your wealth.
Take Control of Your Financial Future
Investing and planning for the future can be daunting, but with tools like this Python simulator, you can make data-driven decisions. By tweaking the parameters, you can explore various scenarios and understand the long-term impact of your investment choices.
So, why wait? Run the simulation, explore different strategies, and set yourself on the path to financial security. Remember, the best time to start investing was yesterday; the second-best time is today. Happy investing, and may your financial future be as bright as you’ve always dreamed!
Full Code
import csv
from collections import deque
import calendar
def calculate_investment_with_withdrawal(
initial_monthly_investment, yearly_increment_percent, annual_return_percent,
years, annual_inflation_percent, desired_monthly_in_hand, withdrawal_fund_growth_percent, ltcg_tax_percent, stcg_tax_percent):
# Constants
months_per_year = 12
max_csv_months = 100 * months_per_year # Limit CSV output to 100 years (1200 months)
annual_return_rate = annual_return_percent / 100 # Convert percent to decimal
monthly_growth_rate = (1 + annual_return_rate) ** (1 / months_per_year) - 1 # Correct monthly growth rate
annual_inflation_rate = annual_inflation_percent / 100 # Convert percent to decimal
ltcg_tax_rate = ltcg_tax_percent / 100 # Convert LTCG tax percent to decimal
stcg_tax_rate = stcg_tax_percent / 100 # Convert STCG tax percent to decimal
# Queue to track each investment as a separate lot
investment_lots = deque() # Stores (lot_name, principal_component, current_value, age_in_months)
# Prepare to collect data for CSV
csv_data = [["Month", "Fund Balance", "Investment That Month", "Inflation-Adjusted Value",
"Gross Withdrawal", "Taxes to Pay", "Net Withdrawal", "Total Invested Amount", "Lots Sold"]]
# Investment phase: growing the investment balance
monthly_investment = initial_monthly_investment
total_months = 0
total_invested_amount = 0 # Track total invested amount
# Start date for naming lots
current_year = 2024
current_month = 11 # Starting month: November
for year in range(1, years + 1):
for month in range(months_per_year):
total_months += 1
lot_name = f"{calendar.month_name[current_month]} {current_year}"
total_invested_amount += monthly_investment # Track total invested amount
# Add the new lot with its name, principal component, current value, and age in months
investment_lots.append([lot_name, monthly_investment, monthly_investment, 0])
# Apply monthly growth to all existing lots using the correct monthly growth rate
for lot in investment_lots:
lot[2] *= (1 + monthly_growth_rate) # Grow the lot's current value
lot[3] += 1 # Increase age by one month
# Update total fund balance as the sum of all current lot values
fund_balance = sum(lot[2] for lot in investment_lots)
# Inflation-adjusted value for this phase
inflation_adjusted_balance = fund_balance / ((1 + annual_inflation_rate) ** (total_months / months_per_year))
# Collect data for CSV: No withdrawals during investment phase
csv_data.append([total_months, f"{fund_balance:.2f}", f"{monthly_investment:.2f}",
f"{inflation_adjusted_balance:.2f}", "0.00", "0.00", "0.00",
f"{total_invested_amount:.2f}", ""])
# Update the month and year
current_month += 1
if current_month > 12:
current_month = 1
current_year += 1
# Increase monthly investment for the next year
monthly_investment *= (1 + yearly_increment_percent / 100)
# Initial Sale and Tax Calculation on All Lots Before Starting Withdrawals
total_sale_value = 0
initial_ltcg_tax = 0
initial_stcg_tax = 0
while investment_lots:
lot_name, principal_component, current_value, age = investment_lots.popleft()
total_sale_value += current_value
profit = current_value - principal_component
if age >= 12: # Apply LTCG for lots older than 12 months
initial_ltcg_tax += profit * ltcg_tax_rate if profit > 0 else 0
else: # Apply STCG for lots younger than 12 months
initial_stcg_tax += profit * stcg_tax_rate if profit > 0 else 0
initial_total_tax = initial_ltcg_tax + initial_stcg_tax
post_tax_proceeds = total_sale_value - initial_total_tax
# Reinvest into 100 Fresh Lots
new_lot_value = post_tax_proceeds / 100
investment_lots = deque([[str(i + 1), new_lot_value, new_lot_value, 0] for i in range(100)])
# Value of the fund before withdrawals
initial_fund_value = post_tax_proceeds
inflation_adjusted_fund_value = post_tax_proceeds / ((1 + annual_inflation_rate) ** years)
# Adjust desired monthly in-hand amount for inflation
adjusted_desired_monthly_in_hand = desired_monthly_in_hand * ((1 + annual_inflation_rate) ** years)
# Calculate gross monthly withdrawal to achieve desired in-hand amount after LTCG tax
gross_monthly_withdrawal = adjusted_desired_monthly_in_hand / (1 - ltcg_tax_rate)
# Withdrawal phase: monthly withdrawals that account for inflation and taxes
monthly_withdrawal = gross_monthly_withdrawal
withdrawal_months = 0 # Track the duration of the withdrawal phase
fund_balance = sum(lot[2] for lot in investment_lots)
withdrawal_monthly_growth_rate = (1 + (withdrawal_fund_growth_percent / 100)) ** (1 / months_per_year) - 1
# Track overall taxes during withdrawal phase
total_ltcg_tax_withdrawal = 0
total_stcg_tax_withdrawal = 0
while withdrawal_months < max_csv_months:
if fund_balance < monthly_withdrawal:
# If the combined fund balance is less than the withdrawal amount, sell everything
total_withdrawn = fund_balance
monthly_tax = 0
lots_sold_details = []
while investment_lots:
lot_name, principal_component, current_value, age = investment_lots.popleft()
profit = current_value - principal_component
if age >= 12:
tax = profit * ltcg_tax_rate if profit > 0 else 0
total_ltcg_tax_withdrawal += tax
lots_sold_details.append(
f"{lot_name}: value={current_value:.2f}, sold={current_value:.2f}, left=0.00, "
f"profit={profit:.2f}, tax=LTCG:{tax:.2f} INR"
)
else:
tax = profit * stcg_tax_rate if profit > 0 else 0
total_stcg_tax_withdrawal += tax
lots_sold_details.append(
f"{lot_name}: value={current_value:.2f}, sold={current_value:.2f}, left=0.00, "
f"profit={profit:.2f}, tax=STCG:{tax:.2f} INR"
)
monthly_tax += tax
fund_balance = 0 # Set fund balance to zero
net_withdrawal = total_withdrawn - monthly_tax
csv_data.append([total_months + withdrawal_months + 1, "0.00", "0.00", "0.00",
f"{total_withdrawn:.2f}", f"{monthly_tax:.2f}", f"{net_withdrawal:.2f}",
f"{total_invested_amount:.2f}", "; ".join(lots_sold_details)])
break
# Track how much needs to be withdrawn this month
amount_to_withdraw = monthly_withdrawal
monthly_tax = 0
lots_sold_details = []
# Continue aging the lots
for lot in investment_lots:
lot[3] += 1 # Increase age by one month
# Withdraw from eligible lots
total_withdrawn = 0
while amount_to_withdraw > 0 and investment_lots:
lot_name, principal_component, current_value, age = investment_lots.popleft()
if age >= 12: # Apply LTCG for lots older than 12 months
applicable_tax_rate = ltcg_tax_rate
tax_label = "LTCG"
else: # Apply STCG for lots younger than 12 months
applicable_tax_rate = stcg_tax_rate
tax_label = "STCG"
if current_value <= amount_to_withdraw:
# Fully withdraw this lot
profit = current_value - principal_component
tax = profit * applicable_tax_rate if profit > 0 else 0
monthly_tax += tax
if tax_label == "LTCG":
total_ltcg_tax_withdrawal += tax
else:
total_stcg_tax_withdrawal += tax
lots_sold_details.append(
f"{lot_name}: value={current_value:.2f}, sold={current_value:.2f}, left=0.00, "
f"profit={profit:.2f}, tax={tax_label}:{tax:.2f} INR")
amount_to_withdraw -= current_value
total_withdrawn += current_value
else:
# Partially withdraw from this lot
proportion = amount_to_withdraw / current_value
profit = proportion * (current_value - principal_component)
tax = profit * applicable_tax_rate if profit > 0 else 0
monthly_tax += tax
if tax_label == "LTCG":
total_ltcg_tax_withdrawal += tax
else:
total_stcg_tax_withdrawal += tax
withdraw_amount = amount_to_withdraw
total_withdrawn += withdraw_amount
remaining_amount = current_value - withdraw_amount
lots_sold_details.append(
f"{lot_name}: value={current_value:.2f}, sold={withdraw_amount:.2f}, left={remaining_amount:.2f}, "
f"profit={profit:.2f}, tax={tax_label}:{tax:.2f} INR")
# Reinsert the partial lot back with updated current value
investment_lots.appendleft([lot_name, principal_component * (1 - proportion), remaining_amount, age])
amount_to_withdraw = 0
# Deduct taxes and calculate net withdrawal
net_withdrawal = total_withdrawn - monthly_tax
# Grow remaining lots at the new fund's withdrawal growth rate
for lot in investment_lots:
lot[2] *= (1 + withdrawal_monthly_growth_rate) # Grow current value
# Update total fund balance as the sum of all current lot values
fund_balance = sum(lot[2] for lot in investment_lots)
monthly_withdrawal *= (1 + annual_inflation_rate / 12) # Increase withdrawal by monthly inflation rate
withdrawal_months += 1
# Inflation-adjusted value for this phase
inflation_adjusted_balance = fund_balance / ((1 + annual_inflation_rate) ** (withdrawal_months / months_per_year))
# Collect data for CSV
csv_data.append([total_months + withdrawal_months, f"{fund_balance:.2f}", "0.00",
f"{inflation_adjusted_balance:.2f}", f"{total_withdrawn:.2f}",
f"{monthly_tax:.2f}", f"{net_withdrawal:.2f}",
f"{total_invested_amount:.2f}", "; ".join(lots_sold_details)])
# Calculate total years and months of withdrawals
withdrawal_years = withdrawal_months // 12
withdrawal_remaining_months = withdrawal_months % 12
# Write data to CSV
with open("investment_withdrawal_report.csv", "w", newline="") as csvfile:
writer = csv.writer(csvfile)
writer.writerows(csv_data)
# Print the formatted story and tax summary
print(f"\nYou invested {format_in_lacs_and_crores(initial_monthly_investment)} per month for {years} years, "
f"which grew at {annual_return_percent}% per year.\n"
f"Your investments increased at {yearly_increment_percent}% per year.\n"
f"The value of the fund when you stopped investing and started withdrawing\n"
f"was {format_in_lacs_and_crores(initial_fund_value)} and "
f"{format_in_lacs_and_crores(inflation_adjusted_fund_value)} adjusted for inflation.\n"
f"You sold all the funds and incurred {format_in_lacs_and_crores(initial_ltcg_tax)} in LTCG and\n"
f"{format_in_lacs_and_crores(initial_stcg_tax)} in STCG, totaling {format_in_lacs_and_crores(initial_total_tax)}.\n"
f"We reinvested the remaining {format_in_lacs_and_crores(post_tax_proceeds)} into 100 different lots,\n"
f"which will grow at {withdrawal_fund_growth_percent}% per year, and started withdrawing.\n"
f"You need {format_in_lacs_and_crores(desired_monthly_in_hand)} per month in today's money.\n"
f"The starting withdrawal will be {format_in_lacs_and_crores(adjusted_desired_monthly_in_hand)} adjusted for\n"
f"{years} years of inflation at {annual_inflation_percent}% per year.\n"
f"The withdrawals will increase every month to adjust for inflation.\n")
print(f"The fund lasted for {withdrawal_years} years and {withdrawal_remaining_months} months in the withdrawal phase.\n")
# Print the detailed tax summary
print("Summary of Taxes:")
print(f"Initial LTCG Tax at the start of withdrawal: {format_in_lacs_and_crores(initial_ltcg_tax)}")
print(f"Initial STCG Tax at the start of withdrawal: {format_in_lacs_and_crores(initial_stcg_tax)}")
print(f"LTCG Tax during systematic withdrawals: {format_in_lacs_and_crores(total_ltcg_tax_withdrawal)}")
print(f"STCG Tax during systematic withdrawals: {format_in_lacs_and_crores(total_stcg_tax_withdrawal)}")
print(f"Total LTCG Tax (bulk sale + withdrawals): {format_in_lacs_and_crores(initial_ltcg_tax + total_ltcg_tax_withdrawal)}")
print(f"Total STCG Tax (bulk sale + withdrawals): {format_in_lacs_and_crores(initial_stcg_tax + total_stcg_tax_withdrawal)}")
return (withdrawal_years, withdrawal_remaining_months, initial_fund_value, inflation_adjusted_fund_value,
adjusted_desired_monthly_in_hand, gross_monthly_withdrawal, ltcg_tax_rate * 100, stcg_tax_rate * 100)
def format_in_lacs_and_crores(amount):
if amount >= 1e7: # Greater than or equal to 1 crore
return f"{amount / 1e7:.2f} crore INR"
elif amount >= 1e5: # Greater than or equal to 1 lac
return f"{amount / 1e5:.2f} lacs INR"
elif amount >= 1e3: # Greater than or equal to 1 thousand
return f"{amount / 1e3:.2f} thousand INR"
else:
return f"{amount:.2f} INR"
# Easily adjustable values
initial_monthly_investment = 130000 # Initial monthly investment in currency units
yearly_increment_percent = 2 # Yearly increment percentage
annual_return_percent = 17 # Annual return rate in percent
years = 12 # Number of years to invest
annual_inflation_percent = 5 # Annual inflation rate in percent
desired_monthly_in_hand = 100000 # Desired monthly amount in hand in today's money
withdrawal_fund_growth_percent = 8 # Growth rate of the new fund after switching
ltcg_tax_percent = 12.5 # LTCG tax percentage on profits
stcg_tax_percent = 20 # STCG tax percentage on profits
# Perform the calculations
(withdrawal_years, withdrawal_remaining_months, initial_fund_value, inflation_adjusted_fund_value,
adjusted_desired_monthly_in_hand, gross_monthly_withdrawal, ltcg_tax_rate_percent, stcg_tax_rate_percent) = \
calculate_investment_with_withdrawal(
initial_monthly_investment, yearly_increment_percent, annual_return_percent,
years, annual_inflation_percent, desired_monthly_in_hand, withdrawal_fund_growth_percent, ltcg_tax_percent, stcg_tax_percent)
# Display the results
print("")
print("_________________________________________________________________________")
print("The detailed report has been saved to 'investment_withdrawal_report.csv'.")
Subscribe to my newsletter
Read articles from Jyotiprakash Mishra directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Jyotiprakash Mishra
Jyotiprakash Mishra
I am Jyotiprakash, a deeply driven computer systems engineer, software developer, teacher, and philosopher. With a decade of professional experience, I have contributed to various cutting-edge software products in network security, mobile apps, and healthcare software at renowned companies like Oracle, Yahoo, and Epic. My academic journey has taken me to prestigious institutions such as the University of Wisconsin-Madison and BITS Pilani in India, where I consistently ranked among the top of my class. At my core, I am a computer enthusiast with a profound interest in understanding the intricacies of computer programming. My skills are not limited to application programming in Java; I have also delved deeply into computer hardware, learning about various architectures, low-level assembly programming, Linux kernel implementation, and writing device drivers. The contributions of Linus Torvalds, Ken Thompson, and Dennis Ritchie—who revolutionized the computer industry—inspire me. I believe that real contributions to computer science are made by mastering all levels of abstraction and understanding systems inside out. In addition to my professional pursuits, I am passionate about teaching and sharing knowledge. I have spent two years as a teaching assistant at UW Madison, where I taught complex concepts in operating systems, computer graphics, and data structures to both graduate and undergraduate students. Currently, I am an assistant professor at KIIT, Bhubaneswar, where I continue to teach computer science to undergraduate and graduate students. I am also working on writing a few free books on systems programming, as I believe in freely sharing knowledge to empower others.