\( \newcommand{\bm}[1]{\boldsymbol{#1}} \newcommand{\textm}[1]{\textsf{#1}} \def\T{{\mkern-2mu\raise-1mu\mathsf{T}}} \newcommand{\R}{\mathbb{R}} % real numbers \newcommand{\E}{{\rm I\kern-.2em E}} \newcommand{\w}{\bm{w}} % bold w \newcommand{\bmu}{\bm{\mu}} % bold mu \newcommand{\bSigma}{\bm{\Sigma}} % bold mu \newcommand{\bigO}{O} %\mathcal{O} \renewcommand{\d}[1]{\operatorname{d}\!{#1}} \)

Exercises

Exercise 10.1 (Computing alternative measures of risk) Generate 10,000 samples following a normal distribution, plot the histogram, and compute the following measures:

  • mean
  • variance and standard deviation
  • semivariance and semi-deviation
  • tail measures (VaR, CVaR, and EVaR) based on raw data
  • tail measures (VaR, CVaR, and EVaR) based on a Gaussian approximation.

Exercise 10.2 (CVaR in variational convex form) Consider the expression for the CVaR: \[ \textm{CVaR}_{\alpha} = \E\left[\xi \mid \xi\geq\textm{VaR}_{\alpha}\right]. \]

Show that it can be rewritten in a convex variational form as: \[ \textm{CVaR}_{\alpha} = \underset{\tau}{\textm{inf}} \left\{\tau + \frac{1}{1-\alpha}\E\left[(\xi-\tau)^+\right]\right\}, \] where the optimal \(\tau\) precisely equals \(\textm{VaR}_{\alpha}\).

Exercise 10.3 (Sanity check for variational computation of CVaR) Generate 10,000 samples of the random variable \(\xi\) following a normal distribution and compute the CVaR as \[ \textm{CVaR}_{\alpha} = \E\left[\xi \mid \xi\geq\textm{VaR}_{\alpha}\right]. \]

Verify numerically that the variational expression for the CVaR gives the same result: \[ \textm{CVaR}_{\alpha} = \underset{\tau}{\textm{inf}} \left\{\tau + \frac{1}{1-\alpha}\E\left[(\xi-\tau)^+\right]\right\}. \]

Exercise 10.4 (CVaR vs downside risk) Consider the following two measures of risk in terms of the loss random variable \(\xi\):

  • downside risk in the form of lower partial moment (LPM) with \(\alpha=1\): \[ \textm{LPM}_1 = \E\left[(\xi - \xi_0)^+ \right]; \]
  • CVaR: \[ \textm{CVaR}_{\alpha} = \E\left[\xi \mid \xi\geq\textm{VaR}_{\alpha}\right]. \]

Rewrite the \(\textm{LPM}_1\) in the form of \(\textm{CVaR}_{\alpha}\) and the other way around. Hint: use \(\xi_0=\textm{VaR}_{\alpha}\).

Exercise 10.5 (Log-sum-exp function as exponential cone) Show that the following convex constraint involving the perspective operator on the log-sum-exp function \[ s \ge t\; \textm{log}\left( e^{x_1/t} + e^{x_2/t} \right), \] for \(t>0\), can be rewritten in terms of the exponential cone \(\mathcal{K}_{\textm{exp}}\) as \[ \begin{aligned} t & \ge u_1 + u_2\\ (u_i, t, x_i - s) & \in \mathcal{K}_{\textm{exp}}, \qquad i=1,2, \end{aligned} \] where \[ \mathcal{K}_{\textm{exp}} \triangleq \big\{(a,b,c) \mid c\geq b\,e^{a/b}, b>0\big\} \cup \big\{(a,b,c) \mid a\leq0, b=0, c\geq0\big\}. \]

Exercise 10.6 (Drawdown and path-dependency)

  1. Generate 10,000 samples of returns following a normal distribution.
  2. Compute and plot the cumulative returns, and plot the drawdown.
  3. Reorder randomly the original returns and plot again.
  4. Repeat a few times to observe the path-dependency property of the drawdown.

Exercise 10.7 (Semivariance portfolios)

  1. Download market data corresponding to \(N\) assets (e.g., stocks or cryptocurrencies) during a period with \(T\) observations, \(\bm{r}_1, \dots, \bm{r}_T \in \R^N\).
  2. Solve the minimization of the semivariance in a nonparametric way (reformulate it as a quadratic program): \[ \begin{array}{ll} \underset{\w}{\textm{minimize}} & \frac{1}{T}\sum_{t=1}^T \left((\tau - \w^\T\bm{r}_t)^+\right)^2\\ \textm{subject to} & \w \ge \bm{0}, \quad \bm{1}^\T\w = 1. \end{array} \]
  3. Solve the parametric approximation based on the quadratic program: \[ \begin{array}{ll} \underset{\w}{\textm{minimize}} & \w^\T\bm{M}\w\\ \textm{subject to} & \w \ge \bm{0}, \quad \bm{1}^\T\w = 1, \end{array} \] where \[ \bm{M} = \E\left[ (\tau\bm{1} - \bm{r})^+ \left((\tau\bm{1} - \bm{r})^+\right)^\T \right]. \]
  4. Comment on the goodness of the approximation.

Exercise 10.8 (CVaR portfolios)

  1. Download market data corresponding to \(N\) assets (e.g., stocks or cryptocurrencies) during a period with \(T\) observations, \(\bm{r}_1, \dots, \bm{r}_T \in \R^N\).
  2. Solve the minimum CVaR portfolio as the following linear program for different values of the parameter \(\alpha\): \[ \begin{array}{ll} \underset{\w, \tau, \bm{u}}{\textm{minimize}} & \tau + \frac{1}{1-\alpha} \frac{1}{T}\sum_{t=1}^T u_t\\ \textm{subject to} & 0 \le u_t \ge -\w^\T\bm{r}_t - \tau, \qquad t=1,\dots,T\\ & \w \ge \bm{0}, \quad \bm{1}^\T\w = 1. \end{array} \]
  3. Observe how many observations are actually used (\(u_t > 0\)) for the different values of \(\alpha\).
  4. Add some small perturbation or noise to the sequence of returns \(\bm{r}_1, \dots, \bm{r}_T\) and repeat the experiment to observe the sensitivity of the solutions to data perturbation.

Exercise 10.9 (Mean-Max-DD formulation as an LP) The mean–Max-DD formulation replaces the usual variance term \(\w^\T\bSigma\w\) by the Max-DD as a measure of risk, defined as \[\textm{Max-DD}(\w) = \underset{1\le t\le T}{\textm{max}} D_t(\w),\] where \(D_t(\w)\) is the drawdown at time \(t\). This leads to the problem formulation \[ \begin{array}{ll} \underset{\w}{\textm{maximize}} & \w^\T\bmu - \lambda \, \underset{1\le t\le T}{\textm{max}} \left\{\underset{1 \le \tau \le t}{\textm{max}} \; \w^\T\bm{r}_\tau^\textm{cum} - \w^\T\bm{r}_t^\textm{cum}\right\}\\ \textm{subject to} & \w \in \mathcal{W}. \end{array} \]

Show that it can be rewritten as the following problem (\(u_0\triangleq-\infty\)): \[ \begin{array}{ll} \underset{\w, \bm{u}, s}{\textm{maximize}} & \begin{array}{l} \w^\T\bmu - \lambda \, s \end{array}\\ \textm{subject to} & \begin{array}[t]{ll} \w^\T\bm{r}_\tau^\textm{cum} \le u_t \le s + \w^\T\bm{r}_t^\textm{cum}, & t=1,\dots,T\\ u_{t-1} \le u_t\\ \w \in \mathcal{W}, \end{array} \end{array} \] which is a linear program (assuming \(\mathcal{W}\) only contains linear constraints).

Exercise 10.10 (Mean-Ave-DD formulation as an LP) The mean–Ave-DD formulation replaces the usual variance term \(\w^\T\bSigma\w\) by the Ave-DD as a measure of risk, defined as \[\textm{Ave-DD} = \frac{1}{T}\sum_{1\le t\le T} D_t(\w),\] where \(D_t(\w)\) is the drawdown at time \(t\). This leads to the problem formulation \[ \begin{array}{ll} \underset{\w}{\textm{maximize}} & \begin{aligned} \w^\T\bmu - \lambda \, \frac{1}{T}\sum_{t=1}^T \left(\underset{1 \le \tau \le t}{\textm{max}} \; \w^\T\bm{r}_\tau^\textm{cum} - \w^\T\bm{r}_t^\textm{cum}\right)\end{aligned}\\ \textm{subject to} & \w \in \mathcal{W}. \end{array} \]

Show that it can be rewritten as the following problem (\(u_0\triangleq-\infty\)): \[ \begin{array}{ll} \underset{\w, \bm{u}, s}{\textm{maximize}} & \begin{array}{l} \w^\T\bmu - \lambda \, s \end{array}\\ \textm{subject to} & \frac{1}{T}\sum_{t=1}^T u_t \le \frac{1}{T}\sum_{t=1}^T\w^\T\bm{r}_t^\textm{cum} + s\\ & \w^\T\bm{r}_\tau^\textm{cum} \le u_t, \qquad t=1,\dots,T\\ & u_{t-1} \le u_t\\ & \w \in \mathcal{W}, \end{array} \] which is a linear program (assuming \(\mathcal{W}\) only contains linear constraints).

Exercise 10.11 (Mean-CVaR-DD formulation as an LP) The mean–CVaR-DD formulation replaces the usual variance term \(\w^\T\bSigma\w\) by the CVaR-DD as a measure of risk, expressed in a variational form as \[ \textm{CVaR-DD}(\w) = \underset{\tau}{\textm{inf}} \left\{\tau + \frac{1}{1-\alpha}\frac{1}{T}\sum_{t=1}^T(D_t(\w) - \tau)^+\right\}, \] where \(D_t(\w)\) is the drawdown at time \(t\). This leads to the problem formulation \[ \begin{array}{ll} \underset{\w, \tau}{\textm{maximize}} & \begin{aligned} \w^\T\bmu - \lambda \left(\tau + \frac{1}{1-\alpha}\frac{1}{T}\sum_{t=1}^T\left(\underset{1 \le \tau \le t}{\textm{max}} \; \w^\T\bm{r}_\tau^\textm{cum} - \w^\T\bm{r}_t^\textm{cum} - \tau\right)^+\right) \end{aligned}\\ \textm{subject to} & \w \in \mathcal{W}. \end{array} \]

Show that it can be rewritten as the following problem (\(u_0\triangleq-\infty\)): \[ \begin{array}{ll} \underset{\w, \tau, s, \bm{z}, \bm{u}}{\textm{maximize}} & \w^\T\bmu - \lambda \, s\\ \textm{subject to} & s \ge \tau + \frac{1}{1-\alpha}\frac{1}{T}\sum_{t=1}^T z_t\\ & 0 \le z_t \ge u_t - \w^\T\bm{r}_t^\textm{cum} - \tau, \qquad t=1,\dots,T\\ & \w^\T\bm{r}_\tau^\textm{cum} \le u_t\\ & u_{t-1} \le u_t\\ & \w \in \mathcal{W}, \end{array} \] which is a linear program (assuming \(\mathcal{W}\) only contains linear constraints).

Exercise 10.12 (Mean--EVaR-DD formulation as a convex problem) The mean–EVaR-DD formulation replaces the usual variance term \(\w^\T\bSigma\w\) by the EVaR-DD as a measure of risk, defined as \[ \textm{EVaR-DD}(\w) = \underset{z>0}{\textm{inf}}\left\{z^{-1}\;\textm{log}\left(\frac{1}{1-\alpha}\frac{1}{T}\sum_{t=1}^T\textm{exp}(z D_t(\w))\right)\right\}. \] where \(D_t(\w)\) is the drawdown at time \(t\) defined as \[D_t(\w) = \underset{1 \le \tau \le t}{\textm{max}} \; \w^\T\bm{r}_\tau^\textm{cum} - \w^\T\bm{r}_t^\textm{cum},\]

  1. Write down the mean–EVaR-DD portfolio formulation in convex form.
  2. Further rewrite the problem in terms of the exponential cone.