Monday, August 11, 2014

Fama/French Factors in 1 line of code

In the past, getting Fama/French factors from the Kenneth French dataset involved a convoluted procedure to download the zip file, unzip the file, clean the data, and convert to xts.  Now with Quandl, we can do it simply in one line of code.  Note:  this data is available in multiple formats (JSON, CSV, XML) from the API and for multiple code languages.

# use Quandl Kenneth French Fama/French factors
# http://www.quandl.com/KFRENCH/FACTORS_D

library(Quandl)
library(quantmod)

f <- Quandl(
"KFRENCH/FACTORS_D"
)

f <- as.xts(f[,-1],order.by=f[,1])

plot.zoo( f, main = NA )
mtext(
text = "Fama/French Factors from Quandl"
, adj = 0
, outer = T
, line = -2
, cex = 2
)

image