Back to Community
Quantopian Risk Model In Algorithms

A few weeks ago, we introduced the Quantopian Risk Model to make it easier to build strategies that are suitable for capital allocations. At the time of launch, the Quantopian risk model output was available in research for performance attribution. Performance attribution is a great tool for understanding your risk exposure after an algorithm has completed, but because it's done after the fact, it doesn't assist an algorithm with dynamically managing its risk exposure as it runs. Today, we're introducing new tools to help manage your risk in algorithms.

How Do I Access Risk Model Data?

The easiest way to access risk model data in an algorithm is to use risk_loading_pipeline, a new function we've added to the quantopian.pipeline.experimental module. risk_loading_pipeline constructs a pre-configured Pipeline that produces a column of output for each factor in the Quantopian Risk Model.

The pipeline created by risk_loading_pipeline works just like any other pipeline. Here's a simple example of how you can use risk_loading_pipeline in an algorithm:

from quantopian.pipeline.experimental import risk_loading_pipeline

def initialize(context):  
    attach_pipeline(risk_loading_pipeline(), 'risk_loading_pipeline')

def before_trading_start(context, data):  
    context.risk_loading_pipeline = pipeline_output('risk_loading_pipeline')  
    # Multiple pipelines are supported in an algorithm.  
    context.my_other_pipeline = pipeline_output('my_other_pipeline')

def my_method(context, data):  
    # Access context.risk_loading_pipeline in your methods.  

The value of context.risk_loading_pipeline in the example is a DataFrame containing a row for every asset and a column for every output of the pipeline. Since risk_loading_pipeline has an output for each column of the Quantopian Risk Model, its result will look like this:

The risk_loading_pipeline is a convenient way to access all the common risk factors in one go. You can also access individual risk factors, like in this example which accesses only the Size factor:

from quantopian.pipeline import Pipeline  
from quantopian.pipeline.experimental import Size

def initialize(context):  
    pipe = Pipeline()  
    pipe.add(Size(), 'size')  
    attach_pipeline(pipe, 'size_factor_pipeline')

def before_trading_start(context, data):  
    context.size_factor_pipeline = pipeline_output('size_factor_pipeline')

def my_method(context, data):  
    # Access context.size_factor_pipeline in your methods.  

Since you can access multiple pipelines in an algorithm, you can use the risk pipelines side-by-side with any pipelines that your algorithm has already defined. The risk model pipeline is also accessible in the research environment via run_pipeline:

from quantopian.pipeline.experimental import risk_loading_pipeline  
from quantopian.research import run_pipeline  
run_pipeline(risk_loading_pipeline(), '2014-01-01', '2014-01-02')  

How Can I Use This Data?

One of the main use cases is to keep your common risk exposure within certain bounds, perhaps in order to meet the contest entry criteria. You can do this by passing a constraint to order_optimal_portfolio, to help place orders such that your common risk exposure thresholds are not exceeded. The snippet shows an example of how you'd constrain your portfolio exposure to common risk:

from quantopian.pipeline.experimental import risk_loading_pipeline  
import quantopian.optimize as opt

def initialize(context):  
    attach_pipeline(risk_loading_pipeline(), 'risk_loading_pipeline')

def before_trading_start(context, data):  
    context.risk_loading_pipeline = pipeline_output('risk_loading_pipeline')

def place_orders(context, data):  
    # Constrain our risk exposures. We're using the latest version of the default bounds,  
    # except for momentum, where we've overridden the default and set a bound of 10% on both  
    # longs and shorts.  
    constrain_sector_style_risk = opt.experimental.RiskModelExposure(  
        risk_model_loadings=context.risk_loading_pipeline,  
        version=opt.Newest,  
        min_momentum=-0.1,  
        max_momentum=0.1,  
    )

    order_optimal_portfolio(  
        objective=some_objective,  
        constraints=[constrain_sector_style_risk],  
    )  

By default, the RiskModelExposure constraint will constrain the sector exposures to 18%, and the style exposures to 36%. These are both slightly under the contest entry criteria of 20% and 40% respectively. These default values may change in the future (for example, in response to a change in the contest entry criteria). If you'd always like to use in the latest version of the defaults, pass in quantopian.optimize.Newest as the version, and your algorithm's behavior will automatically update to match the new default behavior. On the other hand, if you'd like to ensure that your algorithm's behavior doesn't change when the defaults change, you can pass version=0, and your algorithm will always use the version zero defaults. Right now, version 0 is the only version of the defaults available, but we may add more.

You can also override some (or all!) of the defaults if you'd like to change your exposure limits to various factors. The snippet above shows an example where my momentum exposure is constrained to 10%, instead of the default of 36%. The documentation contains the full list of parameters that you can pass in to RiskModelExposure.

What Else Can I Do With This?

We're looking forward to working that out together! While performance attribution was a tool we had been using internally for some time, the risk data in algorithms is a new feature to both of us. Optimization constraints are a good first step (particularly to help meet the contest entry criteria), but we'd like to work together on:

  • Exploring use of the risk data in alpha generation and combination. While the risk model by itself is not an alpha model, there may be interesting approaches in 1) combining the risk factors with your existing alpha factors, 2) finding a combination of the risk factors that is an alpha factor, or 3) using the risk factors to design a factor-neutral pure alpha strategy.
  • Refining best practices for using the risk data in optimization constraints.

In the weeks to come we'll be posting more examples of ways to use the risk data in algorithms, along with more lectures and educational material about how to use the risk model across the platform.

Putting It All Together

The attached backtest is an example of a full-featured algorithm using the risk model. Thanks to the risk constraints, it now meets the new contest entry criteria.

Clone Algorithm
410
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5a3029c700506740c5231281
There was a runtime error.
Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

29 responses

Wow. Simply attach this risk factor pipeline and then add the output as a constraint to the order method. The resulting algorithm should magically meet all the exposure requirements of the contest. Nice.

This is cool. But why isn't the beta to market a built in factor for the risk model?

@ Burrito Dan: the Q risk model does not involve the market factor is due to its factor model structure. To select factors, we need to choose the common factors which are uncorrelated with each other as much as possible while the combination of selected factors can represent the returns of most assets in the market as much as possible. We think the current setting of common factors was our best choice to achieve that goal without making the process of calculation for the risk model too complicated. The model is never done, and we have several changes and improvements in mind to be tested and made in the future.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

@Rene Isn't the market factor orthogonal to the common factors, by construction?

@Burrito Dan: The market factor is highly correlated with most of the sector factors.

Is this re-balancing twice a week or everyday?

This is definitely a step-up for quantopian. Great job, Q team!

@Abhijeet: Can you expand on this point, "2) finding a combination of the risk factors that is an alpha factor" and perhaps gives examples of all 3 bullets?

The market factor is highly correlated with most of the sector factors.

@ Rene -

If the market factor is highly correlated with the sector factors, then what is the point of having the sector factors in the first place? This makes it sound like the sectors aren't all that distinct from the overall market, and as such, aren't really strong risk factors (i.e. diversification across sectors doesn't really achieve anything). I guess you'll flesh this out in the Quantopian Risk Model white paper you are working on; if so, no need to reply here.

@Abhi @Rene: I have some perplexing results from constraining 2 factors: momentum and short_term_reversal.

How I implemented the method to use the risk model data from Pipeline to Optimize API:

# In myPipeline(), the risk factors are added:

myPipeline.add(Momentum(), 'momentum')  
myPipeline.add(ShortTermReversal(), 'short_term_reversal')

# In before_trading_start(), the risk factor values are assigned to context.riskData:

context.riskData = pipeline_output('myPipeline')

# In Optimize API, the 2 factor exposure limits are set to override the opt.Newest defaults:

momentumExposure = 0.4  # Testing range 0.3~0.6  
reversalExposure = 0.4  # Testing range 0.2~0.5

constrainStyleRiskFactors = opt.experimental.RiskModelExposure(  
    risk_model_loadings = context.riskData,  
    version = opt.Newest,  
    min_momentum = -momentumExposure,  
    max_momentum = momentumExposure,  
    min_short_term_reversal = -reversalExposure,  
    max_short_term_reversal = reversalExposure  
)

constraints.append(constrainStyleRiskFactors)  

The results show that momentum risk is reasonably well controlled to set limits - I have also tested a range from 0.3~0.6 to be sure.

Not so for short_term_reversal, whereas the Exposure Summary table reports 0.53, the Daily Style Factor Exposures chart shows roughly +0.25 risks above 0.53 not constrained, plus a few spikes into the 0.9+ zone.

I wonder what could be amiss.. why the high +0.25 and spikes that could not be constrained by the ShortTermReversal() factor.

Possible that the ShortTermReversal() method was detecting that the strategy returns somehow matched the "short_term_reversal" signals, or the strategy simply could not be effectively constrained by the method used otherwise for common short_term_reversal trades?

I'm ok to send a tear sheet to show the results if you are able to help. Thanks

@ Karl : The short-term reversal factor is a faster moving factor (14-day window length) comparing to other risk factors. If you find a strategy has large exposure in the short-term reversal on the performance attribution tearsheet, I suggest you to consider changing it from the design of this algo. If you want to use the optimization tool to bound short-term reversal factor exposure, you probably need to rebalance algo’s positions frequently. Note: Using optimization may change an algo's behaviors in an expected (proper) way, but it is also possible to change an algo's behaviors in an unexpected (improper) way. Observing the performance attribution notebooks and using the optimization tools on the research platform can help to determine whether the algo is running as designed.

Don't know if I can post the following here. So, taking a chance. If anyone objects, I will take it off. If Q objects, they can delete it too since again it does reference the strategy at the top of this thread.

Took the above Risk Model as starting point. Wanted to see if I could extract more from it.

None of the programming logic was changed, only fixed variables that in a way dictate how the strategy will behave.

Increased selectable candidates, changed the time of day of the schedule_function to a more subdued time period (less variance), increased the bet size (less trades), put in a small leverage fraction (1.07). Eliminated the stocktwits thingy. I do not think it has any value whatsoever. This way, remaining consistent with my views. Increased the impact of the fcf_zscore (gave it dominance) for a very simple fundamental reason: a company having more free cash will tend to invest more in its own future. Reduced the beta impact, giving it more of a flat line (damped variance swings). Increased the allowed beta spread, reason is simple there too: increasing it allowed more price variance to enable more fringe trades. Each step increasing overall performance a notch.

In all, just numbers that control the ever moving swarm of price variances. See the attached tear sheets.

The strategy is now in a position where it might even win a contest with its 16.9% CAGR, while keeping its beta, volatility and drawdowns relatively low.

But, in reality, going forward, the strategy would fail in other regards. It has very little real alpha. The strategy is linear and therefore would also degrade going forward, not because it is a bad strategy, but because it does not compensate for growth degradation. It is definitely subject to the law of diminishing returns, and this, by design. To do better, it will have to take care of that limitation. There are solutions to that inherent problem. Note that any linear strategy is subject to this return degradation.

Just removing the stocktwits influence increase performance, and in itself does answer the question of its value. It also reduced the number of trades by more than half. More profits, less expenses, how could I refuse. It also confirms my evaluation of it.

Even if the tear sheet says there is alpha, looking at the cumulative return on the logarithmic scale show there is almost none. You do get a return that is above but close to the market average, however, calling it alpha might be an exaggeration.

This does not mean that the strategy is worthless. Because of its low beta and low volatility, it could be combined with more volatile strategies to reduce overall variance and volatility. It might even hold its own after compensating for the return degradation.

The profits seems to come mainly from having extended the holding period by a couple of weeks thereby benefiting from the underlying market trend. There are no surprises here. But still, no real sustainable alpha either. It is by design that this strategy will produce less and less return-wise going forward.

The strategy is scalable to some extent which is a big thing (tested up to 4x, could go a bit more). It could give some control over a set of more volatile strategies since volatility gets averaged out. It is not so good when leveraging since it would barely cover its borrowing costs.

For the moment, that is about all I could extract without changing the program's logic which would in essence change its very nature.

My note is to show how much impact just changing variables (outside of the program's logic) can improve overall performance. As if slightly reshaping this swarm of variance around its center of mass was sufficient to almost triple its performance as it rolled down history.

Loading notebook preview...
Notebook previews are currently unavailable.

@evgeny We'd like this thread to be about the risk model usage in general. Can you please delete your reply, and repost it as a new stand-alone thread? Thank you!

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

@Guy, Great analysis and modifications. Can you please post exact values of the variable modifications so I can reproduce it? I tried based on your narrative but coud not reproduce it. I would like to try your suggestion:

Because of its low beta and low volatility, it could be combined with more volatile strategies to reduce overall variance and volatility. It might even hold its own after compensating for the return degradation.

This study also confirms my previous analysis that the beta constraints has no effect to the final portfolio beta of uncorrelated returns. So in effect, it is not needed to have beta constraints just the requirement that the portfolio beta be between -0.3 and 0.3.

Hi everyone,

This might be a rather noobish question, but I'm new to Quantopian so please bear with me.

So I was playing around with this risk model as shown in Abhijeet's article above. I had an algorithm that was designed to allocate 100% of the portfolio into a long position based on certain criteria. When I added the risk_loading_pipeline and the constrain_sector_style_risk to the constraints in the order_optimal_portfolio command, I notice the algorithm began shorting. I realize it's probably doing so in an effort to hedge and hence maintain the Sector and Style exposures under constraints, but how is it deciding which short positions to take? There are no short positions in my Target Weights that I'm telling it to order.

Some insight into how it's shorting and how this risk model makes decisions in general would be very helpful!

@Nishanth

If you are using the TargetWeights objective then the algorithm will try to find weights that minimize the 'distance' from the specified weights, while at the same time satisfying all the constraints. Conceptually, the optimize function loops through all possible permutations of weights for all securities. Possible weights can be either positive or negative corresponding to long or short the security. The distance is simply the square root of the sum of the squares of the differences from the specified target weights (ie Euclidean distance). Optimize chooses the set of weights that result in the smallest distance while also meeting all the provided constraints.

As a simple example showing why optimize would ever short a security, consider a universe of only AAPL and IBM. These are both in the tech sector. If the target weight for each is .5 (ie both long), the default risk factor constraint will try to limit tech sector exposure to +-18%. Ordering all long of each will result in a 100% sector exposure. Therefore, the automagic optimize method will modify the weights to get the exposure within the constraints. So, it shorts one of them to achieve this. Probably a toss up which will be shorted if this were the only constraint. However, the other risk constraints will typically kick in and decide.

Hope that helps.

@Nishanth -

You should be able to get a long-only portfolio with:

constraints.append(  
        opt.PositionConcentration.with_equal_bounds(  
            min=0,  
            max=MAX_POSITION_SIZE  
        ))  

Set MAX_POSITION _SIZE > 0.

In respect of John Loeber's Fame-French post and presentation slides, is it possible to use the Quantopian Risk Model to define and constrain Fame-French Factors risks?

Thanks

@Karl good question. Fundamentally, the Q risk model is not same with the Fama-French based model. However, I think you could try to just constrain sector factors, value factor, size factor with Q risk model to achieve similar results.

Hi Karl,

If you want to constrain exposure to some of the risk factors, but leave others unconstrained, you could do it a couple of ways. Like you mentioned, FactorExposure is one possible approach - if you want to constrain just a few of the risk factor exposures, and leave most of them unconstrained, it's a good bet.

However, if you want to constrain most of the risk factor exposures, and leave just a few unconstrained, you could save a few lines of code with a combination of opt.NotConstrained and RiskModelExposure. For example, if you wanted to constrain all of the sector factors, along with size and value, that works out to 'constrain everything except momentum, short_term_reversal, and volatility'. One way to write that is:

opt.experimental.RiskModelExposure(  
  risk_model_loadings=context.risk_loading_pipeline,  
  version=opt.Newest,  
  min_momentum=opt.NotConstrained,  
  max_momentum=opt.NotConstrained,  
  min_short_term_reversal=opt.NotConstrained,  
  max_short_term_reversal=opt.NotConstrained,  
  min_volatility=opt.NotConstrained,  
  max_volatility=opt.NotConstrained,  
)

@Karl, interesting findings and the "Less is More" is befitting the moniker! Consistent with my findings at the Optimize API constraints about the redundancy of beta constraint with dollar neutral constraint also has the "Less is More" theme.

Forgot to tell you, it's also "vintage", LOL!

The algo above might be the best starting point right now in my opinion. If recreation is one's goal here, you can skip this message. For those who want to succeed and make money, sorry to sound dramatic but you'd be wise to pay careful attention to this and dig into it, spend some time experimenting with this code presented, to understand rather than brushing this aside as we humans tend to do as we coast along. People don't like bad news so just imagine what amazingly great news it is going to be, once you resolve this discomfort standing in our way ...

The algorithm above looks healthy in the chart for those ~4 years and yet if started on its posted date to today is down -2.27%.
This could be why. The fundamentals might not be as reliable as we would like to think ...

At Upcoming Changes to Morningstar Fundamental Data, Doug Baldwin did some detailed work investigating the update frequency on fundamentals. He found that uncertainties are pretty much beyond the pale. The notebook contains more information. We would have to write quite a bit more code to work around the troubles noted, these things are outside of Quantopian's control, it's based on the data feed.

At Fundamentals updating daily vs monthly or quarterly my backtest for profiling fundamental updates shows for fcf_yield and earning_yield used by the backtest above, the number of value changes are distributed widely (unlike some others quite a bit more consistent). And what does that mean. Most companies report Fundamentals.cash once per year. Is fcf (Free Cash Flow) yield based on share price in relation to Fundamentals.cash at last report? If that's the case I would expect them all to change every day. Are the inconsistencies in data updating or company reporting, both or neither? The answers will have to come from bigger brains than mine.

Hi Blue Seahawk,

My understanding, and also confirmed by the fundamental data source page, is that:

fcf_yield = fcf per share / price
earning_yield = EPS / price [the inverse of P/E)

Since prices update daily, these values will always update daily as well. The numerator only update quarterly however, when companies release their 10Qs (quarterly and non-audited I believe) and 10Ks (annual and audited).

FCF comes from the cashflow statement, and is the cash generated from operations, after all capital expenditures have been paid for. Cash is a balance-sheet entry on the asset side :), and is not directly related to FCF unless the company retains all FCF on the books as cash. Increase/growth in both are a good and healthy sign in my book.

Just my 2 SEK worth, hope this helps.

Joakim

Appreciated. I wonder how often an increase in 10Q fcf vs previous quarter translates to price increases (from value investors) or from my type looking to anticipate what they will be doing. :) I added some more data on fundamentals here.

Looks good with the original date range, nearly 3x. If anyone can find a way to avoid the Mar 2016 downturn, would be great.

Clone Algorithm
82
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5ac354b804eeea42662c8c66
There was a runtime error.

For the purpose of utilizing risk_loading_pipeline in an algo, is it necessary to include the references to "algo"?
Such as,
import quantopian.algorithm as algo
algo.attach_pipeline(risk_loading_pipeline(), 'risk_loading_pipeline')
algo.schedule_function
algo.order_optimal_portfolio

None of my existing algos use "algo" before attach_pipeline, schedule_function or order_optimal_portfolio.
Should they? Is there something about risk_loading_pipeline that needs "algo" to work properly?

Thanks

You don't technically need to use algo. before any of those functions. The algorithm module is 'magically' already imported in Quantopian algorithms. However, it is considered good practice to explicitly import all modules to make it more clear where they came from. We are making an effort to take this approach when writing new tutorials, documentation, and examples.

I hope this helps.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

I am trying to backtest between 2006 and 2008 and on few of the days for some stocks, I get exceptions similar to the one below that I got for May 3, 2006:

ValueError:NaN or Inf values provided to FactorExposure for argument 'loadings'. Rows/Columns with NaNs: row=Equity(28054 [DBC]) col='momentum' row=Equity(28054 [DBC]) col='short_term_reversal' row=Equity(28054 [DBC]) col='size' row=Equity(28054 [DBC]) col='value' row=Equity(28054 [DBC]) col='volatility'

Could you please add the missing data on those days? You can get the list of days and stocks for which data is missing by using the QTradableStocksUS Universe and running a backtest. After 2008 onwards, the risk factor data runs fine.