Skip to content

Add Factor Calculations for FF3 Model#128

Open
rajpandya737 wants to merge 9 commits intomainfrom
feat/add-factor-calcs
Open

Add Factor Calculations for FF3 Model#128
rajpandya737 wants to merge 9 commits intomainfrom
feat/add-factor-calcs

Conversation

@rajpandya737
Copy link
Member

@rajpandya737 rajpandya737 commented Nov 9, 2025

Basic FF3 factors calculated.
Closes #113

@rajpandya737
Copy link
Member Author

image

view looks like this under the performance tab

@rajpandya737 rajpandya737 marked this pull request as ready for review November 30, 2025 16:37
@rajpandya737 rajpandya737 requested a review from JadHay8 November 30, 2025 16:40
Copy link
Collaborator

@JadHay8 JadHay8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just merge main and fix conflicts. Make sure you don't overwrite new changes.

@rajpandya737 rajpandya737 self-assigned this Jan 18, 2026
logger.warning("Market variance is zero, cannot calculate market factor")
return 0.0

beta_market = covariance / market_variance
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong but isn't the point of importing and using the famafrench library that it can calculate all these factors when you give it the data and you just basically do ff.getFFfactors(...). It seems like we're not really leveraging the library much in general in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

FF library is to get the 3 factors since they are universal to the market and not specific to our portfolio. There is a database and its easier to pull data using the getFamaFrench module. From the above image, we are fetching rm-rf (expected market risk premium), SMB (small - big cap), and HML (high minus low). We then need to apply these factors specifically to our portfolio values. To find each beta, we take the covariance / variance for each.

Copy link
Member Author

@rajpandya737 rajpandya737 Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm looking into this some more, I will probably need to do some sort of regression instead of just finding out each of the betas for this portfolio, since apparently when you have more than 1 factor, cov / var isn't as accurate as it could be. Have to do something like this: https://www.youtube.com/watch?v=V0DbIRx2Prg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build Factor Exposure Tracker and Reports Top Performing Factors

2 participants

Comments