-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a Historical Beta Regression Plot #2145
Conversation
The use case I had in mind, other than just looking up betas, is to check the beta of a single stock with respect to a sector ETF e.g. if I want to trade AMD with a sector hedge, I need to trade ~1.3x more XLK than the size of my AMD trade. It doesn't seem like putting this in the portfolio menu would (easily) allow this because I can't find a way to create a simple portfolio of one stock. This would be a great feature for the portfolio menu as well though because @colin99d is right beta is important to portfolio construction also but I think the use cases are slightly different. Up to you guys though, let me know how to proceed. |
It makes sense to have this somewhere. We already have rolling betas for the To have this in the |
My view is that comparison analysis is to compare tickers in terms of historical, volume, balance sheet, ... the use case here seems to be very distinct. This shouldn't include any ETFs. Plus you can only select a stock and ETF which seems completely out of style of Portfolio menu should allow to do this as the use case that @ricwillis98 is mentioning is having just 1 stock in said portfolio. Plus, it's looking into an ETF which is something that As a matter of fact @JerBouma, |
Im team @JerBouma here. Ive actually had this on a long list of TODOs -- having a function for beta in Portfolio doesn't make sense, as I am researching a specific tickers beta. But beta should also be an optimization factor as many Strats will look to keep a certain beta range. |
But we are talking about My only (big) problem with having this in
This is why I think portfolio is more recommended since the whole menu is built allowing you to load a portfolio of any asset and an ETF as a benchmark. |
What if I wanna look at beta between SBUX and F? |
I get your point @DidierRLopes. It isn't in line with our structure we have in place. However, being able to calculate a beta to some ETF is common practice to gauge risk of that asset. As you will be doing that for one asset always, the portfolio menu doesn't make sense either. I think it's fine you have a command that takes one stock and one ETF, you don't have to load in the ETF, you just have to select it in the command. It could even be an index. Don't forget that this is in essence just calculating a component of CAPM. |
That's a different use case from the one presented above:
But if that was the case, I still wouldn't think that |
I'd be way more open to create a new menu where we add this. @northern-64bit actually added a |
Sorry for jumping into this discussion, but I think that this should be in the qa menu since this is more of a quantitative feature and we already have VaR, CVaR and CAPM there. The best thing is if all of these kind of features is in one menu. Otherwise a new menu for this also sounds solid. |
I think it could fit in qa as well @northern-64bit. What if I just put it there as a command (not a menu) and use an optional arg for the reference ticker e.g. you could call just "beta" to get beta to SPY or "beta --ref XLK" or "beta --ref SBUX" to get beta of the loaded stock w.r.t another stock or ETF. Does that keep everyone happy? @DidierRLopes @JerBouma @jmaslek |
At least makes me happy :) |
Perfecto!! 😄 |
All finished - I moved to qa, added tests and comments, and updated docs. Could I get a code review please @DidierRLopes @jmaslek ? |
Sounds great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! @ricwillis98 🙏🏽 🙏🏽 |
Description
Added beta regression plot to stocks/qa/beta
Summary of the change / bug fix.
Added the ability to view the regression plot where beta comes from (with respect to any stock or ETF).
Link # issue, if applicable.
N/A
Screenshot of the feature or the bug before/after fix, if applicable.
Relevant motivation and context.
This feature is particularly useful for checking the beta of a stock relative to it's sector ETF e.g. TSLA with respect to XLK to put on a sector hedge/hedged trade.
List any dependencies that are required for this change.
None
How has this been tested?
Added unit tests
N/A
Checklist:
Others
pre-commit install
.pytest tests/...
.