Last active
May 23, 2023 20:08
-
-
Save jimtalksdata/7382fe7ccd03da09b3d977f246f82307 to your computer and use it in GitHub Desktop.
gold_etf_question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def calculate_etf_value(discount_rate, gold_return, years_to_discard, future_year, simulations=10000): | |
# Initialize a list to store the present values from each simulation | |
present_values = [] | |
# For each simulation... | |
for _ in range(simulations): | |
# Randomly select a year for the gold to be discarded | |
discard_year = np.random.uniform(0, years_to_discard) | |
# If the future year is before the discard year, calculate the future value of the gold | |
# Otherwise, the future value is 0 | |
if future_year < discard_year: | |
future_value = 80 * (1 + gold_return) ** future_year | |
else: | |
future_value = 0 | |
# Calculate the present value of the future value of the gold | |
present_value = future_value / (1 + discount_rate) ** future_year | |
# Add the present value to the list | |
present_values.append(present_value) | |
# Calculate the average present value across all simulations | |
etf_value = np.mean(present_values) | |
return etf_value | |
# Customize your parameters | |
discount_rate = 0.08 # e.g., 5% | |
gold_return = 0.08 # e.g., 2% | |
years_to_discard = 50 | |
future_year = 25 # The year in the future for which to calculate the present value | |
etf_value = calculate_etf_value(discount_rate, gold_return, years_to_discard, future_year) | |
print(f"The estimated ETF value is ${etf_value:.2f}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment