LoslegenKostenlos loslegen

Scaling risk estimates

The VaR(95) number calculated in previous exercises is simply the value at risk for a single day. To estimate the VaR for a longer time horizon, scale the value by the square root of time, similar to scaling volatility:

$$ \text{VaR(95)}_{\text{t days}} = \text{VaR(95)}_{\text{1 day}} * \sqrt{t} $$

StockReturns_perc and var_95 from the previous exercise is available in your workspace. Use this data to estimate the VaR for the USO oil ETF for 1 to 100 days from now. We've also defined a function plot_var_scale() that plots the VaR for 1 to 100 days from now.

Diese Übung ist Teil des Kurses

Introduction to Portfolio Risk Management in Python

Kurs anzeigen

Anleitung zur Übung

  • Loop from 0 to 100 (not including 100) using the range() function.
  • Set the second column of forecasted_values at each index equal to the forecasted VaR, multiplying var_95 by the square root of i + 1 using the np.sqrt() function.

Interaktive Übung

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

# Aggregate forecasted VaR
forecasted_values = np.empty([100, 2])

# Loop through each forecast period
for i in ____:
    # Save the time horizon i
    forecasted_values[i, 0] = i
    # Save the forecasted VaR 95
    forecasted_values[i, 1] = ____
    
# Plot the results
plot_var_scale()
Code bearbeiten und ausführen