一個簡單的投資模型
假設: * f₁(x):初始投資金額 * f₂(x):第一年的預期收益率 * f₃(x):第二年的預期收益率 * ... * f₉(x):第九年的預期收益率 則 F(x) = f₉(f₈(...f₁(x))) 表示經過九年的投資後,初始投資 x 的最終金額。
集合 D 在函數複合的投資應用中扮演著重要的角色。它代表了所有可能的投資結果,是我們進行風險評估、目標設定和策略制定的基礎。通過對集合 D 的分析,我們可以更好地理解投資的複雜性,做出更明智的投資決策。 下圖加入股市暴跌等因素
Python
import numpy as np
import matplotlib.pyplot as plt
# Simulate random investment returns
def investment_return(num_years, volatility):
returns = np.random.normal(loc=0.1, scale=volatility, size=num_years)
return np.cumprod(1 + returns)
# Scenario 1: Normal market conditions
normal_returns = investment_return(10, 0.15)
# Scenario 2: Stock market crash with a sharp decline
crash_year = 5 # Simulate crash in year 5
crash_factor = 0.3 # 70% drop in asset value (more severe crash)
pre_crash_returns = investment_return(crash_year, 0.15) # Returns before crash
crash_returns = investment_return(10 - crash_year, 0.15) * crash_factor # Returns after crash (adjusted for crash)
crash_returns = np.concatenate((pre_crash_returns, crash_returns))
# Scenario 3: Possible economic recovery (optimistic scenario)
recovery_year = 7 # Simulate recovery starting in year 7
recovery_factor = 1.15 # 15% annual growth after recovery
pre_recovery_returns = investment_return(recovery_year, 0.15) # Returns before recovery
recovery_returns = investment_return(10 - recovery_year, 0.2) * recovery_factor # Returns after recovery (with higher volatility)
recovery_returns = np.concatenate((pre_recovery_returns, recovery_returns))
# Plot all scenarios
plt.plot(normal_returns, label="Normal Market")
plt.plot(crash_returns, label="Stock Market Crash", color='red') # Highlight crash in red
plt.plot(recovery_returns, label="Possible Recovery", color='green') # Highlight recovery in green
# Customize plot for better readability
plt.xlabel("Year")
plt.ylabel("Investment Value")
plt.title("Possible Investment Outcomes (Including Stock Market Crash and Recovery)")
plt.legend()
plt.grid(True)
# Adjust x and y axis limits to better fit the data
plt.xlim(0, 10) # Set x-axis limits to show all 10 years
plt.ylim(min(normal_returns.min(), crash_returns.min(), recovery_returns.min()) * 0.9, max(normal_returns.max(), crash_returns.max(), recovery_returns.max()) * 1.1) # Adjust y-axis limits to show all data with a 10% buffer
plt.tight_layout() # Reduce whitespace around the plot
plt.show()
# This code simulates three investment scenarios and plots the possible investment outcomes,
# including inflation, deflation, stock market crash, global financial crisis, and economic recovery,
# without the average return line. The set D (represented by the different plots) reflects the range of
# potential investment results under various market conditions. The plot is optimized for better readability.
留言
張貼留言