Factor modelling is everywhere these days. I wrote about smart beta here. It is good to quantify performance drivers but the usual caveats apply to quantitative studies utilizing backward looking data, “past performance does not guarantee future results”.
I wanted to share a little exercise I did in Python comparing a fund, stock, or anything with a ticker available on Yahoo Finance with the Fama French 3 factor model – Market Returns, Size, and Book Value. Eugene Fama also graciously publishes the factors monthly on his website for free. The script automatically pulls the monthly data from the website and aligns it with the corresponding dates from Yahoo Finance. Obviously any fund information can be compared as well or new factors should you have access to the returns.
Here is the Tweedy, Browne Global Value Fund from 1993 to 2016:
We can also plot the excess returns versus the factors to get a visual representation:
You can get the code on my *Github Page. Factor away!
* I had a hard time initially figuring out Github and how to post code from my local drive. It is a tool designed for collaboration and version control which I didn’t really have a need for. I just wanted a place to upload and share simple code instead of linking to text files. If anyone else had these issues, you have company. Here is how I handled it:
Open an account on Github.com and create a new repository.
Download the Github Desktop application and install.
In the Desktop app, ‘CLONE’ the repository by clicking on the ‘+’ icon in the top left and selecting the ‘CLONE’ tab.
This creates a directory on your local drive, perhaps something like Documents\Github\ExampleRepository ; Add your *.ipynb files to this directory, most likely in Documents\Ipython Notebooks.
Now click on ‘CHANGES’ tab in the top middle, add a summary and description and select ‘COMMIT’
Click ‘SYNC’ on the top right of the app. The file should now be on Github.com