Building my own factor model to explain share price performance
I am looking to build a model which will help me to explain the drivers of the movement of a share (let's say BASF) over the past 1 month. With all of Trump's volatility the stock market has been very top down driven. I would like to distil the performance into factors and then the idiosyncratic return. Does anyone know how to do this, practically? I would like to build an excel model that can be adapted for any company (but let's start with BASF).. Any templates? Could someone give a step by step? Direct me to other resources? Many thanks.
To build a factor model to explain share price performance, here's a practical step-by-step guide based on the most helpful WSO content:
1. Understand the Basics of Factor Models
2. Gather Data
3. Set Up Your Excel Model
4. Run a Regression
5. Interpret Results
6. Adapt for Other Companies
7. Templates and Resources
Additional Tips:
For further insights, you might explore WSO's financial modeling resources or forums for shared templates and advanced techniques.
Sources: Reflections from year 4 as an equity analyst, How do I use fama-french 3 factor model to get the weightings of each stock in a portfolio?, Developing the "It Factor" as You Progress in Career - What Puts High Performers on Another Level?, My Investing Framework: How to Analyze a Company, Q&A: London L/S + event-driven analyst
These are quite difficult to build and require quite a lot of underlying data and tuning. I assume you are referring to something like a Barra model with common factors and maybe some custom factors as well. This GitHub repo does a good job building out a very basic factor model, https://github.com/0xfdf/toraniko/tree/main
Also, you can check out some old Barra factor models, there are PDFs online describing the basic underlying model. Search for "The Barra US Equity Model (USE4)" and "Barra Risk Model Handbook". These documents are not giving away secret sauces or underlying data source, but it's a good reference and describe some common factors and how they are constructed. Factor models can be pretty expensive to purchase, so it's not a bad idea to build a simple one just to get an idea about your exposures and PNL attribution. There is also this startup called Bayesline, I tried it out and it's OK. I prefer to build a custom model over something like this because I don't care about speed, I prefer to understand the underlying factors, what they represent, and being able to add, remove, and modify them anytime I need to.
yep. step 1 is always search github for template. lot of good PDFs right here for you to do exactly what you want @stl05 .
https://github.com/coamo2/Barra
https://github.com/coamo2/Barra/blob/master/papers/JPM_pure_factor_portfolios_and_multivariate_regression_analysis.pdf
https://github.com/coamo2/Barra/blob/master/papers/MSCI%20Characteristics%20of%20Factor%20Portfolios.pdf
https://github.com/coamo2/Barra/blob/master/papers/MSCI_The_Barra_US_Equity_Model_CHE5.pdf
https://github.com/coamo2/Barra/blob/master/papers/MSCI_The_Barra_US_Eq…
PS - if anyone hiring from a firm you're applying to lurks the board, and sees someone born 2005 graduating from SLU or WashU with factor model on resume... then they have your profile and history. keep opsec tight and/or keep your username activity professional.
Are you looking to build a cross sectional fundamental factor model or a time series one?
If cross sectional, I would definitely advise not to try, especially if you are using excel given the massive data requirements (basically you need a universe of stocks, say 500 stocks, plus their fundamental characteristics, say 5 factors and stock returns. In total that results in 3,000 datapoints at one point in time. If observing monthly data for 1 year, that in total requires 36,000 datapoints). Totally doable in Python but definitely not in excel.
As for the time series approach, it’s way less robust and typically used to analyze historical factor exposures of mutual funds over time. But basically you get the returns of the mutual fund + the returns of the factor ETFs (or you can generate a time series performance of custom factor portfolios) you chose and run a rolling regression over time. Analyzing the betas and t-stats over time can give you a perspective of the time varying factor exposures with some degree of lag. The methodology is pretty straightforward but you run into problems of noise (which may require further data processing such as PCA)
Overall I would recommend to try learning how to code in python first researching how to build a factor model. It can give you a very massive step up in terms of dealing with vast volumes of data (whether that is analysis or data processing).
The fama french 3 factor model says expected return on a single day (lets say 31/12/24) is equal to:
- the risk free rate on 31/12/24
- plus the coefficient (beta) multiplied by the market risk premium (return on market on 31/12/24 less risk free)
- plus the coefficient (beta) multiplied by "small minus big" (return of "small minus big" on 31/12/24)
- plus coefficient (beta) multiplied by "high minus low"
Then if I calculate the expected return and compare to the actual return on a 31/12/24, in theory the difference between expected return and actual return is the abnormal return or alpha on that day. Is that correct? For example if the expected return based on that formula is +0.5% and the stock actually returns +0.8% on 31/12/24 then the alpha is +0.3%?
And then the key question is can I just layer more and more betas (coefficients from regressions) onto this with the same logic..?
For example i could just add additional terms like this:
- add one for momentum (coefficient (from regression function on excel) multiplied by return of momentum on that day)...
- and add another for value (coefficient multiplied by return on value for that day)...
And I could just keep doing this again and again and again with any factor can come up with?
I can therefore make a basic model in excel (admittedly it is somewhat limited) doing this (I've done this already for Fama French 3 factor so far)?
The key question is if the maths and method stacks up for when i want to add more factors... as clearly Fama French is a model that "works" but it only uses the following factors: (1) market risk premium, (2) small minus big, (3) high minus low.
It seems like the factor models available commercially assume there are many more factors than Fama French so I just want to check this is the logic those are built on?
And the key question: would my method that I describe for adding additional factors "work"? Thanks for the responses so far - very insightful.
Interesting exercise. Seems like a decent process but you better make damn sure you understand what your factor returns actually include. And also keep in mind that if you keep jamming factors that you’re just going to overfit the data.
What do you mean by "make damn sure you understand what your factor returns actually include"... I guess, for example, if I am doing the work on a growth factor, I would have a basket of growth stocks and I would use their returns as a proxy for the growth factor... but of course there will always be noise in that data (e.g. the idiosyncratic returns of those stocks). I had assumed this was just a limitation of the method... but just checking if I am missing something?
Delectus fugiat iste quia qui amet. Qui facere ad pariatur veniam molestias mollitia voluptas. Qui illum nihil nobis ullam. Distinctio sit sequi quis. Labore aut earum ipsam nobis neque.
In molestiae magni quo repellendus. Et debitis eum perferendis et est dolor. Nihil voluptatem minus est reiciendis. In esse velit ea ut nisi dolor quo.
Eos consequatur doloremque accusantium soluta voluptate voluptatem. Est quam id dolore quidem. Pariatur laborum est fugiat provident recusandae voluptatem.
Odit minima consectetur commodi consequatur rerum in qui ratione. Rerum numquam animi id modi rem dignissimos. Rerum numquam voluptatibus nihil assumenda. Aut repudiandae nam eos. Et id earum ut accusantium facere atque. Quaerat vitae alias est. Saepe ut itaque magni velit ex vel sit ea.
See All Comments - 100% Free
WSO depends on everyone being able to pitch in when they know something. Unlock with your email and get bonus: 6 financial modeling lessons free ($199 value)
or Unlock with your social account...