LoslegenKostenlos loslegen

Monte Carlo VaR

Both the return values and the Monte-Carlo paths can be used for analysis of everything ranging from option pricing models and hedging to portfolio optimization and trading strategies.

Aggregate the returns data at each iteration, and use the resulting values to forecast parametric VaR(99).

The parameters mu, vol, T, and S0 are available from the previous exercise.

Diese Übung ist Teil des Kurses

Introduction to Portfolio Risk Management in Python

Kurs anzeigen

Anleitung zur Übung

  • Use the .append() method to append the rand_rets to sim_returns list in each iteration.
  • Calculate the parametric VaR(99) using the np.percentile() function on sim_returns.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Aggregate the returns
sim_returns = []

# Loop through 100 simulations
for i in range(100):

    # Generate the Random Walk
    rand_rets = np.random.normal(mu, vol, T)
    
    # Save the results
    sim_returns.____

# Calculate the VaR(99)
var_99 = ____
print("Parametric VaR(99): ", round(100*var_99, 2),"%")
Code bearbeiten und ausführen