We need a risk model

Yuval, I don’t think P123 wants to lease one - though it’d great if it would. But perhaps the community could build one with help? I think creating betas for the many factors people unknowingly invest in here would go a long way to producing alpha and recreating trust in the simulations.

Once we have this, the ranking engine would provide returns not for stocks relative to each other, but relative to each other taking into consideration risk factors. Like, the ranking system now rewards beta depending on your time frame, as an example. I think it’s reasonable to think approximate coefficients are better than nothing.

My thinking is we create generic factors and use the linest or similar coefficient (now there are more functions) to see how sensitive each security is to that factor. Then we can choose which risk factor we want exposure to (or optimize so that we don’t have any). It would also allow us to study factor which have true alpha.

From goog top link on Barra (for those unaware).
The multi-factor risk model uses a number of key fundamental factors that represent the features of an investment. Some of these factors include yield, earnings growth, volatility, liquidity, momentum, size, price-earnings ratio, leverage, and growth; factors which are used to describe the risk or returns of a portfolio or asset by moving from quantitative, but unspecified, factors to readily identifiable fundamental characteristics.

I do not believe an answer saying we want to ignore this request in an effort to earn factor risk premia is a genuine. That is because you must measure that risk premia first and one cannot do that without a risk model.


This article seems relevant .

Surprise! Factor Betas Don’t Deliver Factor Alphas

With the following conclusions

By shorting four of the beta-based factors, investors are able to increase their exposures to the characteristics-based factors, meet their tracking error constraints, and earn Sharpe ratios of 0.78 (versus the market) and 0.91 (versus the value index).

From a practical sense… What does it mean to invest using factor betas? How do I “short four of the beta-based factors”? How many stocks is that? How could a normal investor deploy such a strategy? What kind of leverage, and capital is necessary? Do I have to watch the market all the time since shorting is involved?

Seems like a product very few would use, let alone understand. More for institutions than regular investors (individuals should just use small and micro caps to get alpha). If we develop it we would need to charge a lot of money for it to get any ROI. Maybe there’s a low hanging fruit somewhere?

So I read that you believe a risk model is unwanted, but while useful in producing excess returns (i.e. alpha), too expensive to justify the cost.

I cannot comment on what user think they need only to say that risk models are widely used and it’s unlikely we are so much smarter than the rest of the market that we don’t need one too. I think the marketplace performance results speak in favor of my perspective.

As far as understanding a risk model, it’s no different than understanding beta. Should we remove that, or correlation, from our toolbox for the same reason (that users may not fully understand the math)?

At the end of the day, users understand profit and loss and volatility. And this would at least go a long way to understand loss and volatility of their investments. I believe it would also result in great chance of profits.

Regarding a practical sense of what it all means, that is somewhat putting the cart in front of the horse. I read your remark as “how would we do this?”. If I read that right, my first impression is to simply have the following tools or ability to build them:

  1. Custom benchmarks using a ranking system. Once built like any live portfolio, it can be adjusted.
  2. Using those, any security will be able to have a beta to it, or correlation. We have those functions.
  3. We are able to use those betas and correlations to control our exposure when building portfolios. For example, simulations and ports can be controlled to all or some of these exposures (like industry exposures). We already have maxcorrel, screen variable, or frank, or size positioning functions.
  4. Ranking systems will show bucket returns for the excess returns of the securities (actual security return - (beta coefficient x return of security ). This is admittedly a different kind of development lift.

That would be the concept of a minimum viable risk model. I think all but the ranking system engine could possibly be done with what we have now, which was why I addressed the expert here, Yuval. Caching this for superfast throughput and employing this in the ranking system could be for the developers if Yuval knew how to “code” items 1-3 above.


While I am not sure about the risk model approach and if it is worth the effort here, I do think there is a possible compromise that might be easy for P123 to implement.

Why not allow us to select our own simulations as a hedging tool? Thus I could create a 300 stock equal-weight Microcap Value simulation rebalanced every 4 weeks as my benchmark. Next I design my own custom flavor of Microcap Value which I think is amazing. I run it market neutral with 100% dollar hedged against my Microcap Value index.

Ditto for any strategy you develop. Just make your own ‘benchmark index’ with the factors you want to neutralize against to see if alpha exists.

This serves a dual purpose in that it allows us to use the advanced simulator for long/short portfolios. The book feature doesn’t work for this because you can only go 50/50 maximum whereas a market neutral portfolio should be 100/100.


I think we already have the ability to do this if we download the data as csv?

Create the simulation of your benchmark.
Create your other simulation.
Download the results and compare / regress etc. to see if your port has alpha.

This would enable you to see if you have alpha. I would also add that if you wanted to implement a hedged version as you have envisioned it above, it would be transactionally expensive as you would be buying extra factor beta and selling that portion off (as the hedge) and then paying the borrow. In other words, you would have to approximately double your transaction costs and include borrow costs in your simulation. A risk model would minimize this expense as you would avoid those added costs and complexity, even if you wanted to take this approach because you would be at least more efficiently trading to get the exposure you are seeking.

All that being said, I think your idea ought to be included as it’s step 1 in my sugestion.

For me, I want to run long/short models. My clients want them and yes, I can do it by hand but what would take seconds in P123 takes me a very long time to manually do it in excel, calculate all the stats and drawdown. I make one little change in the sim and then export it all and do it again. Not efficient when a firm wants to put $100mm or more in a long/short fund and they see you doing it with crayons on the back of an envelope.

Maybe this would have some use for you as well? Not sure.

With all that p123 has going on, I am trying to think of an approach which has broader appeal and application while at the same time is easy to code.

I think what I’m proposing is a smarter way to do want you want. I would get behind anything that helps manage risk other than the crude tools available; that includes your suggestion if that’s all we can get - then let’s start somewhere and not let good be the enemy of perfect. I think custom series can be expanded to do custom sims/port like we want. Then we reference it as a hedge or otherwise.

As far as the theoretical long short approach, it is optimal but I believe P123 requires more sophistication to do a long short portfolio than it has now, and wants to build. Namely, long short portfolios require walk forward optimization - it cannot be built in parts interdependently in a manner that should work well over time. I’d love to hear from someone here who can prove me wrong.

We’d also need borrow costs. I think I suggested an algorithm to do create a borrow factor (vs purchasing it) some time ago and it went into the p123 black hole, presumably for lack of interest (no pun intended).

Returning to the issue: we need a risk model or the ability to create our own betas to at least manage or limit our exposures.

Marco? Yuval?

I am agnostic on how P123 should prioritize possible projects here today. Agnostic except to say P123 is finishing a ML/AI project and well,……might want to finish it. I could understand how they might not take on any projects until that is done. I use P123 every day with a machine learning algorithm. It does what I want and I am not aware of a personal need for any new projects for myself. I.e., truly agnostic.

But while we are talking about machine learning projects, Korr123 mentions walk-forward validation which is an established machine learning method. I hope P123 at least looked at that.

Korr is particularly good at using correlation and covariance matrices. I doubt that this is his only use for his math skills. And to be clear, I am not familiar with the risk model he is proposing here—although Portfolio Visualizer MAY have something along those line. But to be sure I am missing some of his finer points: that is just a given.

Generally when using correlation for stocks transaction costs can be a little bit of an issue, I think. Or it has been for me. When you are buying and selling stocks the correlation matrix changes enough that you have to readjust the holdings of most of the stocks in your portfolio or be only partially hedged.

But beta weighting (without using the correlations) of the stocks might be easier to implement. Especially if you have ports with a smaller number of holdings this might be useful.

I think beta weighting of long positions is less useful for portfolios of 30 or more stocks. My port uses 30 stocks. So again, I am pretty agnostic on some of this.

But beta weighting should probably be used in some form if you are doing any shorting I think. And if you are using 5-stock ports it is a little bit crazy not to beta-weight. You are already highly exposed to “unsystematic risk” and compounding that with a highly volatile recent momentum flier (or whatever you are doing with a 5-stock port) is just crazy. Totally crazy to hold this stock in equal weight to other less volatile stocks in the port (full stop).

TL;DR: While incorporating the correlations might be a larger project, beta weighting of the assets in a port or sim might be something worth looking at for individual members. That is not to say I have much of a preference for what P123 does on this.


Robert -

Riccardo, who is more involved in this particular issue than I am, told me, “We are evaluating creating our own time series for factor models, so that we can use them in various parts of the website, for example estimating the exposure of a particular strategy to specific risk factors.” This is something we’ve been thinking about for several years. If there’s some progress to report, I’ll let you know.

I see. So this is a no for now.

I would warn users to be careful with any ML tools without a risk model. That is a recipe for disaster for most. Of course we’ll have pockets of the lucky ones among those exceptional, who claim skill, but the marketplace will just look worse, overall, imo. I know of no one who recommends using any form of optimization (ML/AI) without strong risk management guardrails.

@Jrinne beta requires correlation. You’re remark is well taken in terms of correlation stability and overtrading, but that’s just a lookback variable, like we use for any factor available here, to be incorporated into one’s strategy. The widely accepted lookback is a few years for stability. AQR has some published research on this and I supposed if we cannot select it ourselves, we just use something along those lines for now. And regarding your remark about finishing projects, I’m 100% in agreement.

In my mind, creating a weighted benchmark (as Hemmerling described) and using the linest function wasn’t a big ask, especially because the team is working on these functions for the ML/AI release and has already released a few.

Appreciate the attention to this matter by all. Thank you.


Thanks for the tips/information. I use correlations along with volatility measures for ETFs. I am reticent to talk about what I do for stocks but I hear you.

You said; " AQR has some published research on this…"

I am learning all of the ways volatility, beta and correlation can be combined. I have read about what you do in texts. But have more experience with corrdlation among the holdings (e.g., Risk Parity).

PV uses AQR factors. Maybe this is along the lines of what you are thinking about with regard to some of AQR’s research?

Anyway, thank you for your input!


Hi Jim,

Yes, I saw that after you mentioned it earlier. That’s exactly to what I was referring. If you know of a way to combine PV and P123 in order to incorporate a risk factors like that, please let me know! I’m not familiar with PV.

We need a way to ensure we are not just factor loading, like a huge value bet 01-08. Or massive small cap or liquidity bet, as a few examples. I’m not saying that’s inherently bad, just that we ought to be able to know for risk management purposes.


This thread has been quite interesting to me. But there was one thing I failed to grasp in the discussion, and that is that no one defined the term “risk”, at least that I recognized. Is “risk” as used here the MPT definition of risk, which I believe is the mean variance of actual returns to expected returns, perhaps as measured by the Sharpe ratio? Or is risk perhaps the PMPT definition of risk, which is the mean variance of actual returns less than expected returns, as measured by the Sortino ratio? Or is risk here defined by some machine learning / artificial intelligence concept? Or something else?


I am hesitant to go into much depth because it will not take me long to say something that is just plain wrong as far as what Korr123 has in mind.

But I would just add to the measures of volatile you mentioned: beta. P123 has this variable as a factor. Mutual funds etc like beta for their asset allocations for sure.

Investopedia link: Beta.


This has been a debated topic. P123 previously took the position that, mainly, and someone correct me if I’m wrong, risk is a qualitative measure and that it can be managed by selecting great securities, almost exclusively. Empirical studies looking into the past would tell you how much you could lose, or at least enough to feel comfortable risking capital for the uncertain future excess returns. Those are what we see today as the risk summaries, rolling tests, and some factors limiting industry exposure, for example. All of those are great to have.

I think the evidence is that while that may have been enough in the past, it is questionable to at least not equally consider the quantification of that risk. After all, doesn’t everyone look at both quantitative and qualitative aspects of a potential investment?

How we quantify and manage it, is the focus of this thread. I proposed tools to help us do that, individually, if we want to focus on risk in a more comprehensive fashion.

Hope that answers it.

Cary -

As you know, whole books have been written on the subject of financial risk (Peter Bernstein’s Against the Gods is a pretty good one), and on how to measure it. Here are my off-the-cuff thoughts:

Laypeople (people outside the financial industry) tend to think of financial risk as the probability of a permanent loss of money.

Many people in the financial industry and most academics tended to think of risk as variability in returns (i.e. the denominator in the Sharpe ratio), at least until the 1990s.

A subset of those considered two sources of risk: market risk (as measured by beta) and idiosyncratic risk (the variability in returns that is not accounted for in beta).

Now many in the financial community and most academics are focused on risk-factor loading, which is a much more complicated subject, and one which I don’t fully understand. This is the subject of many of Robert’s posts in this thread. In a nutshell (I may be wrong), we compare a portfolio’s long-short returns to a long-short portfolio based on a specific factor (value, size, quality, etc.). I’m not exactly sure how to quantify risk by doing so, but there are plenty of folks who are (including at least one at Portfolio123). If Robert knows how this is done, perhaps he can explain it here.

The major question I have about all these concepts of risk is this one: how persistent are the quantitative measures? Beta, for example, is quite persistent. A portfolio with low beta over a five-year period is unlikely to have high beta over a subsequent five-year period. Drawdowns, on the other hand (a popular measure of risk among laypeople, since it mimics a permanent loss of capital if capital is withdrawn at a low point), have less persistence: a portfolio with a huge drawdown in one crash may have a relatively low drawdown in another. Variability in returns is, I believe, a less persistent measure than beta, but it may be more persistent than drawdowns.

I would guess that risk-factor loading measures are pretty persistent, but I really don’t know. I would be happy to be enlightened.

I’m not sure how complex this is really.

I am one of those who, for a time, put MktCap (smaller is better) into a ranking system. If I had a crystal ball (which I guess I thought I did) that would have been great!

In 2018, not so great it turns out. My crystal ball and my backtests were not perfect at predicting the future :dizzy_face: My only question is this: Why was I shocked at my limited ability to predict the future?

I was loading-up on a factor, wasn’t I? This put me at risks by some definitions of risk. Everyone understands this don’t they?

People do understand that, I think. And most–I would say–either still include MrktCap (lower is better) in their ranking systems or not (consciously). You have made a decision about risk.

Or maybe some members have a more subtle approach and want to control their exposure to this factor even if they still want to load up a little on this factor.

Maybe diversify elsewhere and keep it in your model if it helps your model. Get some understanding and control of your diversification.

Anyway, if you care whether you have a lot of small-cap exposure OR care about the risks (however you measure risk) of having a lot of small-cap exposure Robert has a way of finding out what your risk is—and controlling it to some extent.

Maybe this is advanced or complex because it looks at the correlation to these risk factors but correlation is probably something that is not too complex of a topic for the forum, I hope.

And let me see with this Portfolio Visualizer output. Hmmmm…. No coincidence it seems. Small-cap funds are more loaded with the small-cap factor. (SMB). And value funds turn out to be more loaded with value (HML). Seems to work. Shocked again :dizzy_face:

So, I do something a little different to control my risk (but am looking at this again). I am not recommending it to anyone. But, I don’t see how anyone at P123 would not be able to use this if they wanted to. It could be understood by anyone—enough to use it I think.

And certainly a legitimate and useful topic that is actually discussed a lot on the form. Eg., does MktCap belong in the ranking system? Kurtis Hammering addressed putting MktCap into a ranking system very recently.

TL;DR. This is not rocket science and it is not too complex of a topic for a site that is about to market ML/AI algorithms, IMHO.

Example of how you could look at some funds and adjust your exposure to that FAMA and French Factors (including size or small-cap exposure):



You asked how Portfolio Visualizer could be made to work with P123.

Your port/sim returns can be uploaded into Portfolio Visualizer. You could then upload other ports/sims and include ETFs along with the ports.

I think you could get the factor loadings you want that way. But I have not tried it with your risk model.

I do understand that you may be wanting to do this on the individual sim/port level. That is more difficult but I am not convinced that it is entirely impossible with Python. You may have some insight into this last point.


What we need is a MinimumViable Product that fits into what we currently have relatively easily. And go from there. (read: yeah, we’re kind of asking you guys to help us design a product)

When you see the AI/ML you will see how it dove tails nicely. For example we did not throw away the ranking system. You simply create a one factor ranking system with a single AI predictor factor.

So something similar is needed here , so it gets going . I’m also adding it to the Road Map. We’ll try to put together a wireframe design soon. We’re thinking of just upgrading the hedge to allow you to hedge against a number of factor beta models. Whether the rebalance spits out a list of stocks to short for the hedge , or a single transaction for each factor, remains to be seen . But for an MVP just a single transaction per factor should be good.


Yuval, said: “I’m not exactly sure how to quantify risk by doing so, but there are plenty of folks who are (including at least one at Portfolio123). If Robert knows how this is done, perhaps he can explain it here”.

First, I think having that knowledgeable employee(s) share his or her thoughts on this topic here would provide unique insight as they would be the only one(s), I know, who most intimately can speak to the nexus between a risk model and P123. Yuval, I asked you originally because you seem to the expert on creating things on the platform that no one else can.

From my perspective, to answer without math, I think reading this is the best place to start.


If you want details and math, read this: https://roycheng.cn/files/riskModels/barra_risk_model_handbook.pdf

For others, factor loading can be thought of as beta against a different benchmark(s).
I agree with Jim’s remarks, and want to highlight his implicit remark of including ML/AI but not factor loading on this platform. That seems paradoxical for two reasons: 1) ML/AI is far more statistically and programmatically complex as a creator or user. 2) Factor loading, the foundation of a risk model, is the precursor to AI/ML in portfolio construction.

And thank you, Jim, for providing that info re PV and the screenshot. It’s precisely what I’m talking about, which dovetails to Marco’s response.

I’m happy to start a working group on how we can create an MVP for this - given there’s involvement by P123 and a commitment to deliver it. I think this platform enables smaller groups to work together. I’m happy to do so if others are as well. I suppose I can go it alone, though that’s far less preferable.

Thank you,