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

3 comments:

  1. to be honest, this has been possible with the Systematic Investor Toolbox for years now. additional pro for SIT: you can use non-US factors too by using a different zip filename from French's site.

    ReplyDelete
  2. well aware of the fine work at Systematic Investor Toolbox. primary difference is Quandl makes the factors this easy and accessible across all platforms (but why would anyone use anything other than R anyway ;) ). thanks for reading and commenting.

    ReplyDelete
  3. nice to have, this data source. you can directly use type="xts" in Quandl() by the way.

    ReplyDelete