{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"# Assignment 3: Portfolio Management \n",
"\n",
"Data on average monthly returns for nine different hedge fund styles (e.g., long-short equity, market-neutral, global macro) are available at `https://github.com/mariuszoican/mgt443/blob/main/Data/A3_HedgeFunds.xlsx?raw=true`.\n",
"\n",
"The goal of this assignment is to implement a risk management strategy of **drawdown control**.\n",
"\n",
"1. Assume that at the end of December 1993, each hedge fund index (i.e., corresponding to a particular style) had a price equal to one. Given the monthly returns in the data, compute the price for each hedge fund style index at the end of each month. In this example, the price is equal to the cumulative return on the index.\n",
"\n",
"2. Compute the high-water mark for each fund style. The high-water mark for a fund at time $t$ is the highest price the fund has achieved before or at time $t$. Formally,\n",
"\n",
"$$\\text{HWM}_t=\\max_{0\\leq s \\leq t} p_s$$\n",
"\n",
"3. Compute the drawdown for each fund style. The drawdown at time $t$ is the distance from the current price to the high-water mark (in percentage style). In other words, the drawdown measures how far the hedge fund is at any given moment from its best historical performance:\n",
"\n",
"$$\\text{DD}_t=\\frac{\\text{HWM}_t-p_t}{\\text{HWM}_t}$$\n",
"\n",
"4. The goal of the assignment is to implement a drawdown control strategy by scaling down the position when the value-at-risk becomes \"too close\" to the **maximum acceptable drawdown** ($MADD$). We assume that $MADD=30\\%$ and that the value at risk is a 3-sigma event (three times the stock historical volatility, or 3$\\sigma_t$). Specifically, you need to choose each month and for each style an investment scale (return scalar) $x$ such that:\n",
"\n",
"$$x \\times 3\\sigma_t \\leq \\text{MADD}-\\text{DD}_t \\leftrightarrow x=\\frac{\\text{MADD}-\\text{DD}_t}{3\\sigma_t}.$$\n",
"\n",
"If $3\\sigma_t \\leq \\text{MADD}-\\text{DD}_t$ then you are not in “drawdown control mode” and you continue with investment of $x=1$ (full investment). Otherwise, you enter “drawdown control mode” and set the investment scale to $x=\\frac{\\text{MADD}-\\text{DD}_t}{3\\sigma_t}$. You never go short: if the current drawdown is higher than the $MADD$, you simply set $x=0$.\n",
"\n",
"To compute the historical volatility $\\sigma_t$, use the annualized volatility as the realized standard deviation over the past 12 months. For the first year, 1994, use the value from January 1995. For February 1995, use returns from February 1994 to January 1995. For March 1995, use returns from March 1994 to February 1995, and so on.\n",
"\n",
"5. Compute the total drawdown-adjusted return for each fund and month using the drawdown control scale x from the previous month as\n",
"\n",
"$$R_t^\\text{DD-adjusted}=x_t×R_t$$\n",
"\n",
"6. Plot the cumulative total raw return and the cumulative drawdown-adjusted return for two styles: dedicated short bias and long/short equity funds. What do you conclude?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Install required packages"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: pandas in /home/risav/.local/lib/python3.8/site-packages (1.3.4)\n",
"Requirement already satisfied: openpyxl in /home/risav/.local/lib/python3.8/site-packages (3.0.9)\n",
"Collecting matplotlib\n",
" Downloading matplotlib-3.4.3-cp38-cp38-manylinux1_x86_64.whl (10.3 MB)\n",
"\u001b[K |████████████████████████████████| 10.3 MB 4.9 MB/s eta 0:00:01 |████████ | 2.6 MB 4.9 MB/s eta 0:00:02\n",
"\u001b[?25hRequirement already satisfied: numpy>=1.17.3; platform_machine != \"aarch64\" and platform_machine != \"arm64\" and python_version < \"3.10\" in /home/risav/.local/lib/python3.8/site-packages (from pandas) (1.21.3)\n",
"Requirement already satisfied: pytz>=2017.3 in /usr/lib/python3/dist-packages (from pandas) (2019.3)\n",
"Requirement already satisfied: python-dateutil>=2.7.3 in /usr/lib/python3/dist-packages (from pandas) (2.7.3)\n",
"Requirement already satisfied: et-xmlfile in /home/risav/.local/lib/python3.8/site-packages (from openpyxl) (1.1.0)\n",
"Requirement already satisfied: pyparsing>=2.2.1 in /home/risav/.local/lib/python3.8/site-packages (from matplotlib) (3.0.3)\n",
"Requirement already satisfied: pillow>=6.2.0 in /usr/lib/python3/dist-packages (from matplotlib) (7.0.0)\n",
"Collecting kiwisolver>=1.0.1\n",
" Downloading kiwisolver-1.3.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.2 MB)\n",
"\u001b[K |████████████████████████████████| 1.2 MB 9.8 MB/s eta 0:00:01\n",
"\u001b[?25hCollecting cycler>=0.10\n",
" Downloading cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)\n",
"Requirement already satisfied: six in /usr/lib/python3/dist-packages (from cycler>=0.10->matplotlib) (1.14.0)\n",
"Installing collected packages: kiwisolver, cycler, matplotlib\n",
"Successfully installed cycler-0.10.0 kiwisolver-1.3.2 matplotlib-3.4.3\n"
]
}
],
"source": [
"# Installs required packages\n",
"!pip3 install pandas openpyxl matplotlib --user"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Imports"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Reading excel file using pandas"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
"\n",
"\n",
" | \n",
"Date | \n",
"Ln/Sh Eq Hedge Fund USD | \n",
"Eq Mkt Ntr Hedge Fund USD | \n",
"Ded Sh Bs Hedge Fund USD | \n",
"Global Mac Hedge Fund USD | \n",
"Mngd Fut Hedge Fund USD | \n",
"Emg Mkts Hedge Fund USD | \n",
"Evnt Drvn Hedge Fund USD | \n",
"Cnvrt Arb Hedge Fund USD | \n",
"Fx Inc Arb Hedge Fund USD | \n",
"
\n",
"\n",
"\n",
"\n",
"0 | \n",
"1994-01-31 | \n",
"0.011733 | \n",
"-0.005467 | \n",
"-0.016267 | \n",
"0.001433 | \n",
"0.001933 | \n",
"0.105133 | \n",
"0.036533 | \n",
"0.003333 | \n",
"0.012733 | \n",
"
\n",
"\n",
"1 | \n",
"1994-02-28 | \n",
"-0.025011 | \n",
"0.002106 | \n",
"0.019713 | \n",
"-0.056811 | \n",
"0.011667 | \n",
"-0.011705 | \n",
"-0.001850 | \n",
"0.001188 | \n",
"-0.020346 | \n",
"
\n",
"\n",
"2 | \n",
"1994-03-31 | \n",
"-0.039114 | \n",
"-0.002514 | \n",
"0.071827 | \n",
"-0.042854 | \n",
"0.025923 | \n",
"-0.046227 | \n",
"-0.013051 | \n",
"-0.009758 | \n",
"-0.016930 | \n",
"
\n",
"\n",
"3 | \n",
"1994-04-29 | \n",
"-0.015720 | \n",
"0.002397 | \n",
"0.012710 | \n",
"-0.016033 | \n",
"0.008437 | \n",
"-0.083673 | \n",
"-0.006673 | \n",
"-0.025332 | \n",
"-0.002165 | \n",
"
\n",
"\n",
"4 | \n",
"1994-05-31 | \n",
"0.005550 | \n",
"-0.001229 | \n",
"0.022357 | \n",
"0.037839 | \n",
"0.007497 | \n",
"-0.007453 | \n",
"-0.001604 | \n",
"-0.010329 | \n",
"0.007780 | \n",
"
\n",
"\n",
"
\n",
"
"
],
"text/plain": [
" Date Ln/Sh Eq Hedge Fund USD Eq Mkt Ntr Hedge Fund USD \\\n",
"0 1994-01-31 0.011733 -0.005467 \n",
"1 1994-02-28 -0.025011 0.002106 \n",
"2 1994-03-31 -0.039114 -0.002514 \n",
"3 1994-04-29 -0.015720 0.002397 \n",
"4 1994-05-31 0.005550 -0.001229 \n",
"\n",
" Ded Sh Bs Hedge Fund USD Global Mac Hedge Fund USD \\\n",
"0 -0.016267 0.001433 \n",
"1 0.019713 -0.056811 \n",
"2 0.071827 -0.042854 \n",
"3 0.012710 -0.016033 \n",
"4 0.022357 0.037839 \n",
"\n",
" Mngd Fut Hedge Fund USD Emg Mkts Hedge Fund USD Evnt Drvn Hedge Fund USD \\\n",
"0 0.001933 0.105133 0.036533 \n",
"1 0.011667 -0.011705 -0.001850 \n",
"2 0.025923 -0.046227 -0.013051 \n",
"3 0.008437 -0.083673 -0.006673 \n",
"4 0.007497 -0.007453 -0.001604 \n",
"\n",
" Cnvrt Arb Hedge Fund USD Fx Inc Arb Hedge Fund USD \n",
"0 0.003333 0.012733 \n",
"1 0.001188 -0.020346 \n",
"2 -0.009758 -0.016930 \n",
"3 -0.025332 -0.002165 \n",
"4 -0.010329 0.007780 "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"excel_file = \"A3_HedgeFunds.xlsx\"\n",
"df = pd.read_excel(excel_file, header=0)\n",
"display(df.head(5))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Computing Price for each hedge fund style index at the end of each month"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
"\n",
"\n",
" | \n",
"Date | \n",
"Ln/Sh Eq Hedge Fund USD | \n",
"Eq Mkt Ntr Hedge Fund USD | \n",
"Ded Sh Bs Hedge Fund USD | \n",
"Global Mac Hedge Fund USD | \n",
"Mngd Fut Hedge Fund USD | \n",
"Emg Mkts Hedge Fund USD | \n",
"Evnt Drvn Hedge Fund USD | \n",
"Cnvrt Arb Hedge Fund USD | \n",
"Fx Inc Arb Hedge Fund USD | \n",
"Ln/Sh Eq Hedge Fund Price USD | \n",
"Eq Mkt Ntr Hedge Fund Price USD | \n",
"Ded Sh Bs Hedge Fund Price USD | \n",
"Global Mac Hedge Fund Price USD | \n",
"Mngd Fut Hedge Fund Price USD | \n",
"Emg Mkts Hedge Fund Price USD | \n",
"Evnt Drvn Hedge Fund Price USD | \n",
"Cnvrt Arb Hedge Fund Price USD | \n",
"Fx Inc Arb Hedge Fund Price USD | \n",
"
\n",
"\n",
"\n",
"\n",
"217 | \n",
"2012-02-29 | \n",
"0.026418 | \n",
"0.013335 | \n",
"-0.046567 | \n",
"0.007852 | \n",
"0.012039 | \n",
"0.029177 | \n",
"0.015809 | \n",
"0.018784 | \n",
"0.010017 | \n",
"5.048153 | \n",
"2.400721 | \n",
"0.460273 | \n",
"7.793135 | \n",
"2.843154 | \n",
"3.711433 | \n",
"4.953850 | \n",
"3.717730 | \n",
"2.488409 | \n",
"
\n",
"\n",
"218 | \n",
"2012-03-30 | \n",
"0.004998 | \n",
"-0.001553 | \n",
"-0.013541 | \n",
"-0.004271 | \n",
"-0.029648 | \n",
"-0.007012 | \n",
"0.007863 | \n",
"0.005535 | \n",
"0.007377 | \n",
"5.073386 | \n",
"2.396992 | \n",
"0.454041 | \n",
"7.759852 | \n",
"2.758860 | \n",
"3.685409 | \n",
"4.992804 | \n",
"3.738310 | \n",
"2.506766 | \n",
"
\n",
"\n",
"219 | \n",
"2012-04-30 | \n",
"-0.004680 | \n",
"-0.004139 | \n",
"-0.025323 | \n",
"-0.002522 | \n",
"0.004299 | \n",
"0.001492 | \n",
"-0.002299 | \n",
"-0.002381 | \n",
"0.006870 | \n",
"5.049642 | \n",
"2.387072 | \n",
"0.442543 | \n",
"7.740286 | \n",
"2.770720 | \n",
"3.690908 | \n",
"4.981324 | \n",
"3.729408 | \n",
"2.523987 | \n",
"
\n",
"\n",
"220 | \n",
"2012-05-31 | \n",
"-0.045274 | \n",
"-0.031806 | \n",
"0.090337 | \n",
"0.001936 | \n",
"0.023829 | \n",
"-0.037889 | \n",
"-0.013256 | \n",
"-0.008387 | \n",
"0.002377 | \n",
"4.821025 | \n",
"2.311150 | \n",
"0.482521 | \n",
"7.755267 | \n",
"2.836744 | \n",
"3.551065 | \n",
"4.915292 | \n",
"3.698128 | \n",
"2.529986 | \n",
"
\n",
"\n",
"221 | \n",
"2012-06-29 | \n",
"0.003438 | \n",
"0.009249 | \n",
"-0.027231 | \n",
"-0.013726 | \n",
"-0.035612 | \n",
"-0.001355 | \n",
"-0.001814 | \n",
"0.003276 | \n",
"0.007563 | \n",
"4.837601 | \n",
"2.332525 | \n",
"0.469382 | \n",
"7.648820 | \n",
"2.735722 | \n",
"3.546253 | \n",
"4.906375 | \n",
"3.710242 | \n",
"2.549120 | \n",
"
\n",
"\n",
"
\n",
"
"
],
"text/plain": [
" Date Ln/Sh Eq Hedge Fund USD Eq Mkt Ntr Hedge Fund USD \\\n",
"217 2012-02-29 0.026418 0.013335 \n",
"218 2012-03-30 0.004998 -0.001553 \n",
"219 2012-04-30 -0.004680 -0.004139 \n",
"220 2012-05-31 -0.045274 -0.031806 \n",
"221 2012-06-29 0.003438 0.009249 \n",
"\n",
" Ded Sh Bs Hedge Fund USD Global Mac Hedge Fund USD \\\n",
"217 -0.046567 0.007852 \n",
"218 -0.013541 -0.004271 \n",
"219 -0.025323 -0.002522 \n",
"220 0.090337 0.001936 \n",
"221 -0.027231 -0.013726 \n",
"\n",
" Mngd Fut Hedge Fund USD Emg Mkts Hedge Fund USD \\\n",
"217 0.012039 0.029177 \n",
"218 -0.029648 -0.007012 \n",
"219 0.004299 0.001492 \n",
"220 0.023829 -0.037889 \n",
"221 -0.035612 -0.001355 \n",
"\n",
" Evnt Drvn Hedge Fund USD Cnvrt Arb Hedge Fund USD \\\n",
"217 0.015809 0.018784 \n",
"218 0.007863 0.005535 \n",
"219 -0.002299 -0.002381 \n",
"220 -0.013256 -0.008387 \n",
"221 -0.001814 0.003276 \n",
"\n",
" Fx Inc Arb Hedge Fund USD Ln/Sh Eq Hedge Fund Price USD \\\n",
"217 0.010017 5.048153 \n",
"218 0.007377 5.073386 \n",
"219 0.006870 5.049642 \n",
"220 0.002377 4.821025 \n",
"221 0.007563 4.837601 \n",
"\n",
" Eq Mkt Ntr Hedge Fund Price USD Ded Sh Bs Hedge Fund Price USD \\\n",
"217 2.400721 0.460273 \n",
"218 2.396992 0.454041 \n",
"219 2.387072 0.442543 \n",
"220 2.311150 0.482521 \n",
"221 2.332525 0.469382 \n",
"\n",
" Global Mac Hedge Fund Price USD Mngd Fut Hedge Fund Price USD \\\n",
"217 7.793135 2.843154 \n",
"218 7.759852 2.758860 \n",
"219 7.740286 2.770720 \n",
"220 7.755267 2.836744 \n",
"221 7.648820 2.735722 \n",
"\n",
" Emg Mkts Hedge Fund Price USD Evnt Drvn Hedge Fund Price USD \\\n",
"217 3.711433 4.953850 \n",
"218 3.685409 4.992804 \n",
"219 3.690908 4.981324 \n",
"220 3.551065 4.915292 \n",
"221 3.546253 4.906375 \n",
"\n",
" Cnvrt Arb Hedge Fund Price USD Fx Inc Arb Hedge Fund Price USD \n",
"217 3.717730 2.488409 \n",
"218 3.738310 2.506766 \n",
"219 3.729408 2.523987 \n",
"220 3.698128 2.529986 \n",
"221 3.710242 2.549120 "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Computes price from percentage\n",
"def get_price(percent, value):\n",
" return (1 + percent) * value\n",
"\n",
"# Computes cumulative price at the end of each month\n",
"for fund in df.columns:\n",
" if fund != \"Date\" and \"Price\" not in fund:\n",
" fund_price = fund.replace(\"USD\", \"Price USD\")\n",
" fund_prices = []\n",
" value = 1\n",
" percent = 0\n",
" for i in df.index:\n",
" percent = df[fund][i]\n",
" value = get_price(percent=percent, value=value)\n",
" fund_prices.append(value)\n",
" df[fund_price] = fund_prices\n",
" \n",
"display(df.tail(5))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. Computing high-water mark for each fund style"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
"\n",
"\n",
" | \n",
"Date | \n",
"Ln/Sh Eq Hedge Fund USD | \n",
"Eq Mkt Ntr Hedge Fund USD | \n",
"Ded Sh Bs Hedge Fund USD | \n",
"Global Mac Hedge Fund USD | \n",
"Mngd Fut Hedge Fund USD | \n",
"Emg Mkts Hedge Fund USD | \n",
"Evnt Drvn Hedge Fund USD | \n",
"Cnvrt Arb Hedge Fund USD | \n",
"Fx Inc Arb Hedge Fund USD | \n",
"... | \n",
"Fx Inc Arb Hedge Fund Price USD | \n",
"Ln/Sh Eq Hedge Fund HWM USD | \n",
"Eq Mkt Ntr Hedge Fund HWM USD | \n",
"Ded Sh Bs Hedge Fund HWM USD | \n",
"Global Mac Hedge Fund HWM USD | \n",
"Mngd Fut Hedge Fund HWM USD | \n",
"Emg Mkts Hedge Fund HWM USD | \n",
"Evnt Drvn Hedge Fund HWM USD | \n",
"Cnvrt Arb Hedge Fund HWM USD | \n",
"Fx Inc Arb Hedge Fund HWM USD | \n",
"
\n",
"\n",
"\n",
"\n",
"217 | \n",
"2012-02-29 | \n",
"0.026418 | \n",
"0.013335 | \n",
"-0.046567 | \n",
"0.007852 | \n",
"0.012039 | \n",
"0.029177 | \n",
"0.015809 | \n",
"0.018784 | \n",
"0.010017 | \n",
"... | \n",
"2.488409 | \n",
"5.312362 | \n",
"3.819347 | \n",
"1.237623 | \n",
"7.793135 | \n",
"3.023856 | \n",
"3.875496 | \n",
"5.436719 | \n",
"3.71773 | \n",
"2.488409 | \n",
"
\n",
"\n",
"218 | \n",
"2012-03-30 | \n",
"0.004998 | \n",
"-0.001553 | \n",
"-0.013541 | \n",
"-0.004271 | \n",
"-0.029648 | \n",
"-0.007012 | \n",
"0.007863 | \n",
"0.005535 | \n",
"0.007377 | \n",
"... | \n",
"2.506766 | \n",
"5.312362 | \n",
"3.819347 | \n",
"1.237623 | \n",
"7.793135 | \n",
"3.023856 | \n",
"3.875496 | \n",
"5.436719 | \n",
"3.73831 | \n",
"2.506766 | \n",
"
\n",
"\n",
"219 | \n",
"2012-04-30 | \n",
"-0.004680 | \n",
"-0.004139 | \n",
"-0.025323 | \n",
"-0.002522 | \n",
"0.004299 | \n",
"0.001492 | \n",
"-0.002299 | \n",
"-0.002381 | \n",
"0.006870 | \n",
"... | \n",
"2.523987 | \n",
"5.312362 | \n",
"3.819347 | \n",
"1.237623 | \n",
"7.793135 | \n",
"3.023856 | \n",
"3.875496 | \n",
"5.436719 | \n",
"3.73831 | \n",
"2.523987 | \n",
"
\n",
"\n",
"220 | \n",
"2012-05-31 | \n",
"-0.045274 | \n",
"-0.031806 | \n",
"0.090337 | \n",
"0.001936 | \n",
"0.023829 | \n",
"-0.037889 | \n",
"-0.013256 | \n",
"-0.008387 | \n",
"0.002377 | \n",
"... | \n",
"2.529986 | \n",
"5.312362 | \n",
"3.819347 | \n",
"1.237623 | \n",
"7.793135 | \n",
"3.023856 | \n",
"3.875496 | \n",
"5.436719 | \n",
"3.73831 | \n",
"2.529986 | \n",
"
\n",
"\n",
"221 | \n",
"2012-06-29 | \n",
"0.003438 | \n",
"0.009249 | \n",
"-0.027231 | \n",
"-0.013726 | \n",
"-0.035612 | \n",
"-0.001355 | \n",
"-0.001814 | \n",
"0.003276 | \n",
"0.007563 | \n",
"... | \n",
"2.549120 | \n",
"5.312362 | \n",
"3.819347 | \n",
"1.237623 | \n",
"7.793135 | \n",
"3.023856 | \n",
"3.875496 | \n",
"5.436719 | \n",
"3.73831 | \n",
"2.549120 | \n",
"
\n",
"\n",
"
\n",
"
5 rows × 28 columns
\n",
"
"
],
"text/plain": [
" Date Ln/Sh Eq Hedge Fund USD Eq Mkt Ntr Hedge Fund USD \\\n",
"217 2012-02-29 0.026418 0.013335 \n",
"218 2012-03-30 0.004998 -0.001553 \n",
"219 2012-04-30 -0.004680 -0.004139 \n",
"220 2012-05-31 -0.045274 -0.031806 \n",
"221 2012-06-29 0.003438 0.009249 \n",
"\n",
" Ded Sh Bs Hedge Fund USD Global Mac Hedge Fund USD \\\n",
"217 -0.046567 0.007852 \n",
"218 -0.013541 -0.004271 \n",
"219 -0.025323 -0.002522 \n",
"220 0.090337 0.001936 \n",
"221 -0.027231 -0.013726 \n",
"\n",
" Mngd Fut Hedge Fund USD Emg Mkts Hedge Fund USD \\\n",
"217 0.012039 0.029177 \n",
"218 -0.029648 -0.007012 \n",
"219 0.004299 0.001492 \n",
"220 0.023829 -0.037889 \n",
"221 -0.035612 -0.001355 \n",
"\n",
" Evnt Drvn Hedge Fund USD Cnvrt Arb Hedge Fund USD \\\n",
"217 0.015809 0.018784 \n",
"218 0.007863 0.005535 \n",
"219 -0.002299 -0.002381 \n",
"220 -0.013256 -0.008387 \n",
"221 -0.001814 0.003276 \n",
"\n",
" Fx Inc Arb Hedge Fund USD ... Fx Inc Arb Hedge Fund Price USD \\\n",
"217 0.010017 ... 2.488409 \n",
"218 0.007377 ... 2.506766 \n",
"219 0.006870 ... 2.523987 \n",
"220 0.002377 ... 2.529986 \n",
"221 0.007563 ... 2.549120 \n",
"\n",
" Ln/Sh Eq Hedge Fund HWM USD Eq Mkt Ntr Hedge Fund HWM USD \\\n",
"217 5.312362 3.819347 \n",
"218 5.312362 3.819347 \n",
"219 5.312362 3.819347 \n",
"220 5.312362 3.819347 \n",
"221 5.312362 3.819347 \n",
"\n",
" Ded Sh Bs Hedge Fund HWM USD Global Mac Hedge Fund HWM USD \\\n",
"217 1.237623 7.793135 \n",
"218 1.237623 7.793135 \n",
"219 1.237623 7.793135 \n",
"220 1.237623 7.793135 \n",
"221 1.237623 7.793135 \n",
"\n",
" Mngd Fut Hedge Fund HWM USD Emg Mkts Hedge Fund HWM USD \\\n",
"217 3.023856 3.875496 \n",
"218 3.023856 3.875496 \n",
"219 3.023856 3.875496 \n",
"220 3.023856 3.875496 \n",
"221 3.023856 3.875496 \n",
"\n",
" Evnt Drvn Hedge Fund HWM USD Cnvrt Arb Hedge Fund HWM USD \\\n",
"217 5.436719 3.71773 \n",
"218 5.436719 3.73831 \n",
"219 5.436719 3.73831 \n",
"220 5.436719 3.73831 \n",
"221 5.436719 3.73831 \n",
"\n",
" Fx Inc Arb Hedge Fund HWM USD \n",
"217 2.488409 \n",
"218 2.506766 \n",
"219 2.523987 \n",
"220 2.529986 \n",
"221 2.549120 \n",
"\n",
"[5 rows x 28 columns]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Computes high water mark\n",
"def compute_hwmt(df, t, fund):\n",
" data = df[fund][df[\"Date\"] <= t]\n",
" return np.max(data)\n",
"\n",
"# Computes high water mark at the end of each month\n",
"for fund in df.columns:\n",
" if fund != \"Date\" and \"Price\" not in fund and \"HWM\" not in fund:\n",
" fund_hwm = fund.replace(\"USD\", \"HWM USD\")\n",
" fund_hwms = []\n",
" for i in df.index:\n",
" t = df[\"Date\"][i]\n",
" fund_hwms.append(compute_hwmt(df, t, fund.replace(\"USD\", \"Price USD\")))\n",
" df[fund_hwm] = fund_hwms\n",
"\n",
"display(df.tail(5))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3. Computing Drawdown for each fund style"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
"\n",
"\n",
" | \n",
"Date | \n",
"Ln/Sh Eq Hedge Fund USD | \n",
"Eq Mkt Ntr Hedge Fund USD | \n",
"Ded Sh Bs Hedge Fund USD | \n",
"Global Mac Hedge Fund USD | \n",
"Mngd Fut Hedge Fund USD | \n",
"Emg Mkts Hedge Fund USD | \n",
"Evnt Drvn Hedge Fund USD | \n",
"Cnvrt Arb Hedge Fund USD | \n",
"Fx Inc Arb Hedge Fund USD | \n",
"... | \n",
"Fx Inc Arb Hedge Fund HWM USD | \n",
"Ln/Sh Eq Hedge Fund DD | \n",
"Eq Mkt Ntr Hedge Fund DD | \n",
"Ded Sh Bs Hedge Fund DD | \n",
"Global Mac Hedge Fund DD | \n",
"Mngd Fut Hedge Fund DD | \n",
"Emg Mkts Hedge Fund DD | \n",
"Evnt Drvn Hedge Fund DD | \n",
"Cnvrt Arb Hedge Fund DD | \n",
"Fx Inc Arb Hedge Fund DD | \n",
"
\n",
"\n",
"\n",
"\n",
"217 | \n",
"2012-02-29 | \n",
"0.026418 | \n",
"0.013335 | \n",
"-0.046567 | \n",
"0.007852 | \n",
"0.012039 | \n",
"0.029177 | \n",
"0.015809 | \n",
"0.018784 | \n",
"0.010017 | \n",
"... | \n",
"2.488409 | \n",
"0.049735 | \n",
"0.371432 | \n",
"0.628099 | \n",
"0.000000 | \n",
"0.059759 | \n",
"0.042333 | \n",
"0.088816 | \n",
"0.000000 | \n",
"0.0 | \n",
...SOLUTION.PDFAnswer To This Question Is Available To Download
Submit New Assignment
Please select references for your assignment
Please select no of pages for your assignment
Please select level for your assignment
x
I am Online - Talk to me!
Please fill out the form below to start chatting with the next available agent.
Mehmet Mert
3