# Reinitializing the required libraries and recalculating due to environment reset
import numpy as np
import pandas as pd
# Input parameters
initial_investment = 100000 # Initial investment in ILS
monthly_investment = 1000 # Monthly investment in ILS
conversion_fee = 0.02 # Conversion fee as percentage
years = 15 # Investment period in years
monthly_returns_sp500 = [((1 + rate/100)**(1/12) - 1) for rate in [
26.46, 15.06, 2.11, 16.00, 32.39, 13.69, 1.38, 11.96, 21.83, -4.38, 31.49, 18.40, 28.71, -18.11, 26.29
]]
# Exchange rates (assume yearly average)
exchange_rates = [
3.93, 3.73, 3.58, 3.85, 3.61, 3.58, 3.88, 3.84, 3.60, 3.60, 3.56, 3.44, 3.23, 3.36, 3.55
]
# Inflation adjustment factors
real_adjustment_factors = [1]
for inflation in [3.9, 2.7, 2.2, 1.6, 1.8, -0.2, -1.0, -0.2, 0.3, 0.8, 0.6, -0.7, 2.8, 5.3, 3.0]:
real_adjustment_factors.append(real_adjustment_factors[-1] * (1 + inflation / 100))
# Initialize investment tracker
investment_values = []
current_balance = 0
total_invested = 0
# Calculate investment with S&P500 returns
for year in range(years):
exchange_rate = exchange_rates[year]
monthly_return = monthly_returns_sp500[year]
# Initial investment for the first year
if year == 0:
usd_invested = (initial_investment * (1 - conversion_fee)) / exchange_rate
current_balance += usd_invested
# Monthly investments
for _ in range(12):
usd_invested = (monthly_investment * (1 - conversion_fee)) / exchange_rate
current_balance = (current_balance + usd_invested) * (1 + monthly_return)
total_invested += monthly_investment * 12
investment_values.append(current_balance)
# Final value in USD
final_value_usd = current_balance
# Convert back to ILS
final_exchange_rate = exchange_rates[-1]
final_value_ils = final_value_usd * final_exchange_rate
# Nominal gains
nominal_gains = final_value_ils - (initial_investment + total_invested)
# Real gains
real_adjustment_factor = real_adjustment_factors[-1]
real_gains = final_value_ils / real_adjustment_factor - (initial_investment + total_invested)
# Taxes
nominal_tax = nominal_gains * 0.25
real_tax = real_gains * 0.25
# Net values after tax
net_nominal = final_value_ils - nominal_tax
net_real = final_value_ils - real_tax
# Results summary
results = {
"Final Value (ILS)": final_value_ils,
"Nominal Gains (ILS)": nominal_gains,
"Real Gains (ILS)": real_gains,
"Nominal Tax (ILS)": nominal_tax,
"Real Tax (ILS)": real_tax,
"Net Value after Nominal Tax (ILS)": net_nominal,
"Net Value after Real Tax (ILS)": net_real,
}
# Display results
import ace_tools as tools; tools.display_dataframe_to_user(name="Investment Results for S&P500", dataframe=pd.DataFrame([results]))