The investment universe might be simplified into passive and alternative. Passive is cheap, index-following; alternative is the broad term given to those attempts to find inefficiencies and risks that can enhance performance. One of the main alternatives are hedge funds.
The first hedge fund is said to have been created by Alfred W. Jones.
You can read more about his fund here:
There are two defining characteristics of Jones’ fund:
it would take short positions to hedge against market risk. This is the way that market neutrality is achieved.
they charged 2:20, meaning that the investor must pay 2 percent of the funds under management and 20 percent of any gains that are made.
You can find most packages on Cran. This is the Ccomprehensive R Archieve Network. There are also some packages on Github
We will be using the Portfolio Analytics package. It can be found here. You can read about the functions in the Reference Manual and you can get some help with using the package by looking through the Vignettes.
There are two steps to using a package of functions:
Download the code onto your computer using the function
install.packages(). This will make the package available
when you want it.
Make the package functions available for your use right now by
using the functions library() or
require().
install.packages(PerformanceAnalytics)
require(PerformanceAnalytics)
## Loading required package: PerformanceAnalytics
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
##
## legend
You will see that there are a number of warnings that are presented
with the package. These include the other packages that are
automatically made available with this package. In our case that
includes zoo and xts. There are also
notifications that the functions as.Data and
legend have been overwritten. These names have been used by
Performance Analytics and their use has been given prominence. If you
want to use the standard functions you need to direct the software to
use the base version by using the syntax base::as.Date or
base::legend.
This is a package that is designed to analyse portfolio performance. It does with two data sets:
managers which includes the returns for 4 hedge
funds together with a hedge fund index as well as the S&P 500, the
US 10-year government bonds and treasury bills.
EDHEC with hedge fund performance indices (returns)
for a range of hedge funds.
These datasets can be used for practice.
head(managers)
## HAM1 HAM2 HAM3 HAM4 HAM5 HAM6 EDHEC LS EQ SP500 TR
## 1996-01-31 0.0074 NA 0.0349 0.0222 NA NA NA 0.0340
## 1996-02-29 0.0193 NA 0.0351 0.0195 NA NA NA 0.0093
## 1996-03-31 0.0155 NA 0.0258 -0.0098 NA NA NA 0.0096
## 1996-04-30 -0.0091 NA 0.0449 0.0236 NA NA NA 0.0147
## 1996-05-31 0.0076 NA 0.0353 0.0028 NA NA NA 0.0258
## 1996-06-30 -0.0039 NA -0.0303 -0.0019 NA NA NA 0.0038
## US 10Y TR US 3m TR
## 1996-01-31 0.00380 0.00456
## 1996-02-29 -0.03532 0.00398
## 1996-03-31 -0.01057 0.00371
## 1996-04-30 -0.01739 0.00428
## 1996-05-31 -0.00543 0.00443
## 1996-06-30 0.01507 0.00412
head(edhec)
## Convertible Arbitrage CTA Global Distressed Securities
## 1997-01-31 0.0119 0.0393 0.0178
## 1997-02-28 0.0123 0.0298 0.0122
## 1997-03-31 0.0078 -0.0021 -0.0012
## 1997-04-30 0.0086 -0.0170 0.0030
## 1997-05-31 0.0156 -0.0015 0.0233
## 1997-06-30 0.0212 0.0085 0.0217
## Emerging Markets Equity Market Neutral Event Driven
## 1997-01-31 0.0791 0.0189 0.0213
## 1997-02-28 0.0525 0.0101 0.0084
## 1997-03-31 -0.0120 0.0016 -0.0023
## 1997-04-30 0.0119 0.0119 -0.0005
## 1997-05-31 0.0315 0.0189 0.0346
## 1997-06-30 0.0581 0.0165 0.0258
## Fixed Income Arbitrage Global Macro Long/Short Equity
## 1997-01-31 0.0191 0.0573 0.0281
## 1997-02-28 0.0122 0.0175 -0.0006
## 1997-03-31 0.0109 -0.0119 -0.0084
## 1997-04-30 0.0130 0.0172 0.0084
## 1997-05-31 0.0118 0.0108 0.0394
## 1997-06-30 0.0108 0.0218 0.0223
## Merger Arbitrage Relative Value Short Selling Funds of Funds
## 1997-01-31 0.0150 0.0180 -0.0166 0.0317
## 1997-02-28 0.0034 0.0118 0.0426 0.0106
## 1997-03-31 0.0060 0.0010 0.0778 -0.0077
## 1997-04-30 -0.0001 0.0122 -0.0129 0.0009
## 1997-05-31 0.0197 0.0173 -0.0737 0.0275
## 1997-06-30 0.0231 0.0198 -0.0065 0.0225
We will use these for practice but you should use your own data for the assignment.
There are a set of standard performance charts that can be used.
charts.PerformanceSummary(managers[, 1:5])
It is also possible to generate a table of performance metrics
table.Stats(managers[, 1:5])
## HAM1 HAM2 HAM3 HAM4 HAM5
## Observations 132.0000 125.0000 132.0000 132.0000 77.0000
## NAs 0.0000 7.0000 0.0000 0.0000 55.0000
## Minimum -0.0944 -0.0371 -0.0718 -0.1759 -0.1320
## Quartile 1 0.0000 -0.0098 -0.0054 -0.0198 -0.0164
## Median 0.0112 0.0082 0.0102 0.0138 0.0038
## Arithmetic Mean 0.0111 0.0141 0.0124 0.0110 0.0041
## Geometric Mean 0.0108 0.0135 0.0118 0.0096 0.0031
## Quartile 3 0.0248 0.0252 0.0314 0.0460 0.0309
## Maximum 0.0692 0.1556 0.1796 0.1508 0.1747
## SE Mean 0.0022 0.0033 0.0032 0.0046 0.0052
## LCL Mean (0.95) 0.0067 0.0076 0.0062 0.0019 -0.0063
## UCL Mean (0.95) 0.0155 0.0206 0.0187 0.0202 0.0145
## Variance 0.0007 0.0013 0.0013 0.0028 0.0021
## Stdev 0.0256 0.0367 0.0365 0.0532 0.0457
## Skewness -0.6588 1.4580 0.7908 -0.4311 0.0738
## Kurtosis 2.3616 2.3794 2.6829 0.8632 2.3143
We can look at the distribution of returns with a boxplot as an alternative to the histogram.
chart.Boxplot(managers[, 1:5])
Look up the meaning of the box, whiskers and dots for the boxplot. What does this tell you about each of the strategies?
We might want to know more about the consistency of the performance and the level of risk that is being taken. For consistency, it is possible to calculate the rolling mean.
charts.RollingPerformance(managers[, 1:5], width = 12)
We can also calculate the drawdown for a fund. This is the length of the peak to trough (how far does it fall).
table.Drawdowns(managers[, 1])
## From Trough To Depth Length To Trough Recovery
## 1 2002-02-28 2003-02-28 2003-07-31 -0.1518 18 13 5
## 2 1998-05-31 1998-08-31 1999-03-31 -0.1239 11 4 7
## 3 2005-03-31 2005-04-30 2005-09-30 -0.0412 7 2 5
## 4 2001-09-30 2001-09-30 2001-11-30 -0.0312 3 1 2
## 5 1996-04-30 1996-07-31 1996-08-31 -0.0284 5 4 1