9
$\begingroup$

I am trying to calculate the turnover for a portfolio strategy.

First I generate some random data and assign it dates:

data <- replicate(6,rnorm(1000))
data <- as.data.frame(data)    
dates<-seq(as.Date("1932/09/01"), as.Date("2015/12/01"), by = "1 month",tzone="GMT")-1
    rownames(data)<-dates

I convert it to xts format:

library(xts)
data<-as.xts(data,dateFormat="Date")

Then I use the Return.portfolio() function to calculate the rebalanced weights assuming an equal weighted strategy:

library(PerformanceAnalytics)
results <- Return.portfolio(data,rebalance_on="months",geometric=F,verbose=T)

In order to calculate the turnover I'm assuming that I need the beginning of period weights and end of period weight.

I extract these from the results:

bop <- results$BOP.Weight #beginning of period weights

eop <- results$EOP.Weight #end of period weights

Then to calculate the turnover I substract bop from eop and take the absolute value:

f<-abs(bop-eop)

Finally, to calculate the turnover I use the following formula:

 sum(f)*(1/(nrow(data)-1))

However, when I test this on real-data (where I know what the turnover should be) I get huge, unrealistic numbers with this method.

What am I doing wrong?

My definition of turnover comes from: Demiguel et al Constraining Portfolio Norms http://faculty.london.edu/avmiguel/DeMiguelGarlappiNogalesUppalMS.pdf page 806

The definition is:

enter image description here

$\endgroup$
  • $\begingroup$ I do not think your question is clear. Many notations should be defined before they are used; do not assume every one knows them. For the code, you need at least provide some comments. $\endgroup$ – Gordon Aug 11 '15 at 13:50
  • $\begingroup$ please see my edits. Now the problem is reproducible. $\endgroup$ – user1723765 Aug 11 '15 at 14:01
  • $\begingroup$ What is your definition of "turnover". Your two line calculation does not resemble any definition I know. $\endgroup$ – noob2 Aug 11 '15 at 14:41
  • $\begingroup$ My definition of annual turnover is (dollar value of securities sold + dollar value securities bought) divided by (beginning of year pfolio value + end of year pfolio value). Note that these are dollar values not weights. $\endgroup$ – noob2 Aug 11 '15 at 14:53
  • 1
    $\begingroup$ @user1723765, your problem is not reproducible unless you provide which data you used, the exact data sets (you said it works on your random data but not on "real data"), ....I hope you do not expect others to write a complete code solution in exchange for 100....Anyway, from what you describe the problem might be that some weights do not sum up to 1 or the like. But as your question currently stands it makes it very hard for someone to take interest in putting in time for guess work... $\endgroup$ – Matthias Wolf Aug 12 '15 at 3:09
4
+100
$\begingroup$

First and foremost you are using bad data. min(data) gets me -3.67 (it's random remember) which would be -367% as in the position went bankrupt and took out two other ones (could be possible in a levered porftolio). However for the sake of an reproducible answer lets use the edhec data set, very little changes to your original code need to be done.

library(PerformanceAnalytics)
data(edhec)
results <- Return.portfolio(edhec,rebalance_on="months",verbose=T)

bop <- results$BOP.Weight #beginning of period weights

eop <- results$EOP.Weight #end of period weights

There is a potential for error here in the non equal weight case as you are subtracting the beginning of period weights from the end of period weights when it SHOULD be the following period weights. E.g. the market has shifted your weights and you need to reset.

f<-abs(bop-eop)


YourTurnover=sum(f)*(1/(nrow(edhec)-1)) # 0.01242465
SanityCheck=sum(abs(eop-1/ncol(edhec)))/(nrow(edhec)-1) #0.01242465

Please note that the above definition of turnover is the sum of all the % weight changes divided by number of trading periods. Also the authors do NOT count the initial allocation in their turnover (e.g. the 100% change from cash to investments.) The sanity check is ONLY for the EW case.

An average turnover of 1.24% which appears to be in line for an equal weight strategy.

My suspicion if you are not running an equal weight strategy is the bop-eop line. As it should be EoP weights - next BoP weights.

$\endgroup$
  • $\begingroup$ fyi. the problem was with dividing the dataset by 100. I found this out by comparing my data to the edhec data. But for other portfolios I had to change my formula based on what you said. So thanks for your help! $\endgroup$ – user1723765 Aug 13 '15 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.