Trend Following Factors from Hsieh and Fung
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
The beauty of R and academic replication is that on the Friday before Memorial Day weekend I can read an academic paper and do some analysis all before breakfast. In this case, the paper is
Hsieh, David A. and Fung, William, The Risk in Hedge Fund Strategies: Theory and Evidence from Trend Followers. The Review of Financial Studies, Vol. 14, No. 2, Summer 2001 .
Available at author’s site at Duke University: PDF file.with data courtesy of the authors available at http://faculty.fuqua.duke.edu/~dah7/DataLibrary/TF-Fac.xls
Let’s get the factors into R and run some very introductory analysis on the Edhec data from PerformanceAnalytics. The factors as defined by the authors are:
Trend Following Risk Factors from Fung and Hsieh, RFS (2001)
PTFSBD: Return of PTFS Bond lookback straddle
PTFSFX: Return of PTFS Currency Lookback Straddle
PTFSCOM:Return of PTFS Commodity Lookback Straddle
PTFSIR: Return of PTFS Short Term Interest Rate Lookback Straddle
PTFSSTK:Return of PTFS Stock Index Lookback Straddle
![]() |
From TimelyPortfolio |
![]() |
From TimelyPortfolio |
What a nice way to ease into the weekend. Now for the hard part–thinking about how I might use this.
#Hsieh, David A. and Fung, William, | |
#The Risk in Hedge Fund Strategies: Theory and Evidence from Trend Followers. | |
#The Review of Financial Studies, Vol. 14, No. 2, Summer 2001 . | |
#Available at SSRN: http://ssrn.com/abstract=250542 | |
#http://faculty.fuqua.duke.edu/~dah7/DataLibrary/TF-Fac.xls | |
require(gdata) | |
require(quantmod) | |
require(PerformanceAnalytics) | |
require(FactorAnalytics) | |
URL <- "http://faculty.fuqua.duke.edu/~dah7/DataLibrary/TF-Fac.xls" | |
#get xls sheet TF-Fac starting at the row with yyyymm | |
hsieh_factor <- read.xls(URL,sheet="TF-Fac",pattern="yyyymm",stringsAsFactors=FALSE) | |
hsieh_factor.clean <- hsieh_factor | |
#clean up date to get to yyyy-mm-dd | |
hsieh_factor.clean[,1] <- as.Date(paste(substr(hsieh_factor[,1],1,4), | |
substr(hsieh_factor[,1],5,6), | |
"01",sep="-")) | |
#remove percent sign and make numeric | |
hsieh_factor.clean[,2:6] <- apply( | |
apply(hsieh_factor[,2:6], | |
MARGIN=2, | |
FUN=function(x) {gsub("%", "", x)}), | |
MARGIN=2, | |
as.numeric)/100 | |
#get rid of NAs | |
hsieh_factor.clean <- hsieh_factor.clean[,1:6] | |
hsieh_factor.xts <- as.xts(hsieh_factor.clean[,2:6],order.by=hsieh_factor.clean[,1]) | |
chart.CumReturns(hsieh_factor.xts, | |
main="Hsieh and Fung Trend Following Factors", | |
xlab=NA, | |
legend.loc="topleft") | |
mtext(text="Source: http://faculty.fuqua.duke.edu/~dah7/DataLibrary/TF-Fac.xls", | |
side=3,adj=0.10,outer=TRUE, col="purple",cex=0.75,line=-4) | |
chart.Correlation(hsieh_factor.xts,main="Hsieh and Fung Trend Following Factors") | |
mtext(text="Source: http://faculty.fuqua.duke.edu/~dah7/DataLibrary/TF-Fac.xls", | |
side=1,adj=0.10,outer=TRUE, col="purple",cex=0.75,line=-1.5) | |
#get edhec data for sample factor analysis | |
data(edhec) | |
cta <- edhec[,1] | |
index(cta)=as.Date(format(index(cta),"%Y-%m-01")) | |
cta.factors <- na.omit(merge(cta,hsieh_factor.xts)) | |
chart.RollingStyle(cta.factors[,1],cta.factors[,2:NCOL(cta.factors)], | |
width=36, | |
colorset=c("darkseagreen1","darkseagreen3","darkseagreen4","slateblue1","slateblue3","slateblue4"), | |
main="Edhec CTA by Trend Following Factors Rolling 36 Months") | |
mtext(text="Source: http://faculty.fuqua.duke.edu/~dah7/DataLibrary/TF-Fac.xls", | |
side=1,adj=0.10,outer=TRUE, col="purple",cex=0.75,line=-5) |
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.