Visualizing Portfolio Performance
Visualizing cumulative returns and portfolio growth is essential for investors who want to understand not just the final outcome of their investment decisions, but also the journey along the way. By plotting how the value of a portfolio and its individual assets change over time, you can quickly spot trends, periods of outperformance or underperformance, and the effects of diversification. These visualizations make it much easier to communicate investment results and to compare different strategies or assets.
1234567891011121314151617181920212223242526272829import matplotlib.pyplot as plt import pandas as pd import numpy as np # Simulate daily returns for three assets and a portfolio np.random.seed(42) dates = pd.date_range("2022-01-01", periods=252) assets = { "Stock A": np.random.normal(0.0005, 0.01, size=252), "Stock B": np.random.normal(0.0003, 0.012, size=252), "Stock C": np.random.normal(0.0004, 0.009, size=252) } returns = pd.DataFrame(assets, index=dates) weights = np.array([0.4, 0.4, 0.2]) returns["Portfolio"] = returns.dot(weights) # Calculate cumulative returns cumulative = (1 + returns).cumprod() - 1 # Plot cumulative returns plt.figure(figsize=(10, 6)) for col in cumulative.columns: plt.plot(cumulative.index, cumulative[col], label=col) plt.title("Cumulative Returns: Portfolio vs. Assets") plt.xlabel("Date") plt.ylabel("Cumulative Return") plt.legend() plt.tight_layout() plt.show()
When you look at a cumulative return chart like the one above, you are seeing how much each asset and the portfolio have grown, relative to their starting value, over time. The lines show the compounded effect of daily returns, so a steady upward slope indicates consistent growth, while dips reveal drawdowns or periods of loss. By comparing the portfolio's line to those of the individual assets, you can see whether diversification has reduced risk or boosted returns. If the portfolio line is smoother or higher than any single asset, it suggests effective risk management or smart asset selection.
123456789101112131415161718192021222324252627# Highlight and annotate key periods on the cumulative return chart plt.figure(figsize=(10, 6)) for col in cumulative.columns: plt.plot(cumulative.index, cumulative[col], label=col) # Highlight a period of strong growth plt.axvspan("2022-03-01", "2022-04-15", color="yellow", alpha=0.2, label="Growth Period") # Annotate the maximum point of the portfolio max_date = cumulative["Portfolio"].idxmax() max_value = cumulative["Portfolio"].max() plt.annotate( "Portfolio Peak", xy=(max_date, max_value), xytext=(max_date, max_value + 0.05), arrowprops=dict(arrowstyle="->", color="black"), fontsize=10, color="black" ) plt.title("Cumulative Returns with Highlights and Annotations") plt.xlabel("Date") plt.ylabel("Cumulative Return") plt.legend() plt.tight_layout() plt.show()
1. What does a cumulative return chart show?
2. Why might an investor compare portfolio growth to individual asset growth?
3. Which matplotlib function is used to add annotations to a plot?
Danke für Ihr Feedback!
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Großartig!
Completion Rate verbessert auf 4.76
Visualizing Portfolio Performance
Swipe um das Menü anzuzeigen
Visualizing cumulative returns and portfolio growth is essential for investors who want to understand not just the final outcome of their investment decisions, but also the journey along the way. By plotting how the value of a portfolio and its individual assets change over time, you can quickly spot trends, periods of outperformance or underperformance, and the effects of diversification. These visualizations make it much easier to communicate investment results and to compare different strategies or assets.
1234567891011121314151617181920212223242526272829import matplotlib.pyplot as plt import pandas as pd import numpy as np # Simulate daily returns for three assets and a portfolio np.random.seed(42) dates = pd.date_range("2022-01-01", periods=252) assets = { "Stock A": np.random.normal(0.0005, 0.01, size=252), "Stock B": np.random.normal(0.0003, 0.012, size=252), "Stock C": np.random.normal(0.0004, 0.009, size=252) } returns = pd.DataFrame(assets, index=dates) weights = np.array([0.4, 0.4, 0.2]) returns["Portfolio"] = returns.dot(weights) # Calculate cumulative returns cumulative = (1 + returns).cumprod() - 1 # Plot cumulative returns plt.figure(figsize=(10, 6)) for col in cumulative.columns: plt.plot(cumulative.index, cumulative[col], label=col) plt.title("Cumulative Returns: Portfolio vs. Assets") plt.xlabel("Date") plt.ylabel("Cumulative Return") plt.legend() plt.tight_layout() plt.show()
When you look at a cumulative return chart like the one above, you are seeing how much each asset and the portfolio have grown, relative to their starting value, over time. The lines show the compounded effect of daily returns, so a steady upward slope indicates consistent growth, while dips reveal drawdowns or periods of loss. By comparing the portfolio's line to those of the individual assets, you can see whether diversification has reduced risk or boosted returns. If the portfolio line is smoother or higher than any single asset, it suggests effective risk management or smart asset selection.
123456789101112131415161718192021222324252627# Highlight and annotate key periods on the cumulative return chart plt.figure(figsize=(10, 6)) for col in cumulative.columns: plt.plot(cumulative.index, cumulative[col], label=col) # Highlight a period of strong growth plt.axvspan("2022-03-01", "2022-04-15", color="yellow", alpha=0.2, label="Growth Period") # Annotate the maximum point of the portfolio max_date = cumulative["Portfolio"].idxmax() max_value = cumulative["Portfolio"].max() plt.annotate( "Portfolio Peak", xy=(max_date, max_value), xytext=(max_date, max_value + 0.05), arrowprops=dict(arrowstyle="->", color="black"), fontsize=10, color="black" ) plt.title("Cumulative Returns with Highlights and Annotations") plt.xlabel("Date") plt.ylabel("Cumulative Return") plt.legend() plt.tight_layout() plt.show()
1. What does a cumulative return chart show?
2. Why might an investor compare portfolio growth to individual asset growth?
3. Which matplotlib function is used to add annotations to a plot?
Danke für Ihr Feedback!