Exploring Financial Data - Yats.com

Mar 3, 2010 - along the project, including stocks indexes, hedge fund index. ... get S&P data with the symbol ^GSPC (you can choose whatever stock index ...
139KB taille 8 téléchargements 238 vues
Exploring Financial Data Daniel Herlemont

March 3, 2010

Contents 1 Introduction

1

2 Exploring European Indices

1

3 Using YAHOO/Reuters Financial Data

2

4 Exploring Hedge Funds data from CSFB/Tremont indexes 4.1 Reading the data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 Preparing the data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3 Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4 Statistical data, risk measures and risk adjusted performance measures 5 Annex

1

. . . .

. . . .

. . . .

3 3 4 4 4 6

Introduction

The objective of this practical work is to explore some financial data that will be used all along the project, including stocks indexes, hedge fund index.

2

Exploring European Indices

In this section, we will use the data already available within R EuStockMarkets To load the data, execute the follwing command: > data(EuStockMarkets) 1

3 USING YAHOO/REUTERS FINANCIAL DATA ˆ explore the structure of the data with the command str(EuStockMarkets) ˆ plot the data with plot(EuStockMarkets) or plot(EuStockMarkets,plot.type="single") ˆ Extract the data for one indice: for example, prices=EuStockMarkets[,"FTSE"] ˆ plot the graph with command ”plot(prices)”. ˆ compute the returns with both methods

– r1=diff(prices)/prices[-length(prices)] or r2=diff(log(prices)) – compare the two methods ... mean, standard deviation, ... what are the differences if any ? explain use summary, or plot r1 against r2 plot(r1,r2) ˆ draw the histogram of returns ˆ superpose the gaussian fit ˆ Use the option xlim and ylim to zoom on the left tail of the distribution

3

Using YAHOO/Reuters Financial Data

It is possible to downlaod YAHOO financial stock quotes from the site http://finance. yahoo.com. The function get.hist.quote from the package tseries. can do this automatically and the function plotOHLC can be used to plot nice graphics. However, for time being it is preferable to download the data ”by hand”. For example to get S&P data with the symbol ^GSPC (you can choose whatever stock index you like, FTSE, CAC40, DAX, Eurostoxx, ... ). ˆ go to the S&P page http://finance.yahoo.com/q/hp?s=^GSPC ˆ go to ”historical prices” link

Daniel Herlemont

2

4 EXPLORING HEDGE FUNDS DATA FROM CSFB/TREMONT INDEXES ˆ then click on ”downlaod data to spreadsheet” and save the file to your current directory in "^GSPC.csv", for example. In addition to close prices, yahoo data provides the open prices as well as the high and the low of the days. The Highs and the Lows will be very useful to get more efficient estimators for the volatility. ˆ load the data into R with with quotes=read.csv("^GSPC.csv"), ˆ extracts the date and closing prices. dates=quotes[,"Date"] closes=quotes[,"Close"] ˆ The quotes are in reverse (time) order, use the function rev dates=rev(dates) closes=rev(closes) ˆ parse the dates with dates=as.Date(dates) ˆ then plot the prices plot(dates,prices,type="l") ˆ Draw the histogram as we do in the previous section and compare the historical quantiles with the normal quantiles:

curve(quantile(r,prob=x),xlim=c(0,0.05)) curve(qnorm(x,mean(r),sd(r)),add=TRUE) ˆ Conclusions !!!

4

Exploring Hedge Funds data from CSFB/Tremont indexes

4.1

Reading the data

ˆ get the raw data from: http://www.yats.com/downloads/CSFBTremont-2010.csv and save the file in your current directory. The data contain the monthly rates of returns of the different indexes. ˆ load the data into a data.frame with the function rhf=read.csv("CSFBTremont-2010.csv").

Daniel Herlemont

3

4 EXPLORING HEDGE FUNDS DATA FROM CSFB/TREMONT INDEXES

4.2

Preparing the data

ˆ examine the data with str(rhf) (str means structure). ˆ replace missing data (NA) by 0 with the command rhf[is.na(rhf)]=0 ˆ remove the dates (first column) with rhf=rhf[,-1] rhf. ˆ divide by 100 (the data are in percentage) ˆ Reverse the order to get the right time order rhf=apply(rhf,2,rev) ˆ The commands can be put into a function and save into a script file util.R.

4.3

Graphics

ˆ recover the prices from the returns into the variable phf ˆ plot the price of the Equity Market Neutral (phf[,"Equity.Market.Neutral"]) ˆ plot all the prices into a same graphic, including a legend (see matplot). ˆ print the correlation matrix using cor as well as the covariance matrix cov). Conclusions ?

4.4

Statistical data, risk measures and risk adjusted performance measures

Compute the following statistics for each fund: ˆ the annualized rate of returns using arithmetic and geometric means, compare the two methods ? ˆ the annualized and volatility ˆ The Sharpe ratio

r − rf σ with rf the risk free that we can supposed to be about 4% / year, r, the annualized return and σ, the annualized volatility. sharpe =

ˆ The skewness) and the excess kurtosis in annualized data (see the annex 5) Daniel Herlemont

4

4 EXPLORING HEDGE FUNDS DATA FROM CSFB/TREMONT INDEXES ˆ The historical and normal quantile (Value at Risk) at 99% et 95% ˆ The maximum drawdown (see annex 5) ˆ Comments ?

Based on the the previous statistics (incl. correlations), select the best three funds to invest. Expected results: > options(digits = 2) > cbind(ROR, vol, sharpe, skewness, kurtosis, mdd, varg95, varh95, + varg99, varh99) ROR vol sharpe skewness kurtosis mdd varg95 9.6 7.8 0.72 -0.0567 0.1957 19.7 4.5 7.9 7.2 0.55 -0.7815 1.2781 32.9 4.1 -1.1 16.9 -0.30 0.2139 0.1314 46.7 7.9 9.2 15.5 0.34 -0.2178 0.3870 45.1 8.1 6.2 10.8 0.21 -3.3968 12.6477 45.1 5.6 10.4 6.0 1.07 -0.7430 1.1703 19.1 3.7 11.5 6.7 1.12 -0.6661 0.9868 22.5 4.1 10.0 6.4 0.93 -0.5770 0.8567 18.5 3.8 7.4 4.2 0.81 -0.3222 0.4338 8.2 2.6 5.1 6.0 0.18 -1.2080 2.2434 29.0 3.3 12.9 10.3 0.87 -0.0062 0.2617 26.8 5.9 10.6 10.0 0.66 0.0038 0.2856 22.0 5.6 6.7 11.8 0.23 0.0112 0.0034 17.7 6.1 8.1 5.4 0.76 -0.5095 0.5134 24.7 3.2 varh95 varg99 varh99 Hedge.Fund.Index 2.95 6.0 6.3 Convertible.Arbitrage 2.00 5.5 6.4 Dedicated.Short.Bias 7.14 11.2 8.7 Emerging.Markets 7.00 11.1 10.2 Equity.Market.Neutral 0.86 7.7 2.1 Event.Driven 1.84 4.9 5.1 Event.Driven.Distressed 1.76 5.4 5.2 Event.Driven.Multi.Strategy 2.18 5.1 4.9 Event.Driven.Risk.Arbitrage 1.22 3.4 3.1 Fixed.Income.Arbitrage 1.62 4.5 6.8 Global.Macro 3.56 7.9 7.0 Long.Short.Equity 3.44 7.6 7.5 Managed.Futures 4.88 8.5 7.4 Multi.Strategy 1.95 4.3 4.9 Hedge.Fund.Index Convertible.Arbitrage Dedicated.Short.Bias Emerging.Markets Equity.Market.Neutral Event.Driven Event.Driven.Distressed Event.Driven.Multi.Strategy Event.Driven.Risk.Arbitrage Fixed.Income.Arbitrage Global.Macro Long.Short.Equity Managed.Futures Multi.Strategy

The corr´elation (in %):

Daniel Herlemont

5

5 ANNEX

A B C D E F G H I J K L M N A 100 53 -46 69.8 27.7 74.6 66.7 75.2 48.2 54.5 82.7 82.2 15.3 46.4 B 53 100 -25 42.5 20.7 65.3 58.8 64.0 46.6 78.4 34.0 43.0 -10.9 69.5 C -46 -25 100 -53.3 -13.1 -56.4 -56.1 -50.1 -46.4 -19.5 -11.8 -67.4 11.0 -17.6 D 70 43 -53 100.0 13.6 70.2 62.7 70.1 48.9 40.4 45.1 65.1 -5.5 25.0 E 28 21 -13 13.6 100.0 29.2 33.4 23.7 14.3 32.3 7.2 18.2 -1.2 34.6 F 75 65 -56 70.2 29.2 100.0 94.0 95.0 67.2 55.2 41.5 71.9 -8.2 51.5 G 67 59 -56 62.7 33.4 94.0 100.0 79.2 57.3 51.3 35.0 64.1 -7.9 44.9 H 75 64 -50 70.1 23.7 95.0 79.2 100.0 65.4 53.5 45.3 70.7 -8.1 51.8 I 48 47 -46 48.9 14.3 67.2 57.3 65.4 100.0 32.0 22.4 57.3 -8.2 31.5 J 54 78 -20 40.4 32.3 55.2 51.3 53.5 32.0 100.0 40.1 37.9 -8.4 62.8 K 83 34 -12 45.1 7.2 41.5 35.0 45.3 22.4 40.1 100.0 46.2 27.9 26.0 L 82 43 -67 65.1 18.2 71.9 64.1 70.7 57.3 37.9 46.2 100.0 4.7 41.0 M 15 -11 11 -5.5 -1.2 -8.2 -7.9 -8.1 -8.2 -8.4 27.9 4.7 100.0 2.7 N 46 70 -18 25.0 34.6 51.5 44.9 51.8 31.5 62.8 26.0 41.0 2.7 100.0

5

Annex

How to annualized returns ? Suppose that we know the average of the monthtly rate of returns rmonth . then a usual practice consists in multiplying by 12 ryear = 12rmonth . However this method assume that returns are additive. This is not exactly the case. The rigth procedure is to compute the geometric mean of the Total Return, 1 + ryear = (1 + rmonth )1 2 the other moments mean

=

E(X)

variance =

2

σ = standardDeviation

=

S = skewness

=

K = excessKurtosis

=

(1) 2

E(X ) − E(X) √ variance E[(X − EX )3 ] σ3 E[(X − EX )4 ] −3 σ4

In case of normal distribution skewness = excessKurtosis = 0 Under the √ hypothesis of the independence of returns, the scaling factor for the skewness and excess kurtosis are 1/ ∆T and 1/∆T . The Maximum Drawdown (or peak to valley) is an important risk measure in alternative management. It measures the difference between a high and low of the Net Asset Value (NAV). This the maximum loss that an investor may incurred. More precisely, let W (t) be the NAV of the fund at time t and M (t) the running maximum. M (t) = max W (s) 0≤s≤t

The current drawdown is D(t) is D(t) = M (t) − W (t) Daniel Herlemont

6

5 ANNEX Note that D(t) ≥ 1. or in percentage Dpercent (t) = −

M (t) − W (t) M (t)

(minus to get a positive measure) The maximum drawdown the max of DD: M DD(t) = max DD(s) 0≤s≤t

or in percentage M DDpercent (t) = max Dpercent (t) 0≤s≤t

In R, the code is the following: > drawdown.percent = function(x) 1 - x/cummax(x) > maxDrawdown.percent = function(x) max(1 - x/cummax(x))

Daniel Herlemont

7