The Quantopian Risk Model is a powerful new tool to help researchers and authors construct and evaluate algorithms suitable for capital allocations. The risk model is a way to see what risks your algorithm is exposed to, and whether those risks are expected and managed. For example, you might have an algorithm that is profitable, but the risk model analysis reveals that you've taken on unwanted energy sector exposure. You then can revise your strategy to manage that unexpected risk.
The risk model decomposes the risk of holding any stock (or portfolio of stocks) into a set of common risk factors and a residual risk. That residual risk is called asset/portfolio specific risk or specific risk for short. Colloquially, the return from specific risk is also referred to as alpha.
A benefit of this model is that it aligns your algorithm with Quantopian's allocation process. We are making allocations to algorithms that have good performance from specific risk while carefully managing their common risks (we will go into more detail on this objective in another post).
We are making the risk model available to you today in research, and soon in the IDE/backtest. We're also planning on launching a new contest, awarding prizes to the algorithm authors who create specific returns while managing common risk exposures.
Performance Attribution
Using the risk model to evaluate a stock or portfolio's common and specific returns is called performance attribution. You can see the performance attribution of one of your backtests by creating a tear sheet in research.
The performance attribution tear sheet is called from the BacktestResult
object.
bt = get_backtest('my_backtest')
bt.create_perf_attrib_tear_sheet()
The tear sheet includes:
- Summary table with your cumulative total, specific, and common returns
- A table with returns per factor, and risk exposures to that factor **
- Graph of cumulative specific, total and common returns
- Graph of daily risk exposures to a factor
- Graph of daily returns from a factor, and daily specific returns
On the backtest object, you can also access two properties,
- bt.factor_exposures gives you a dataframe of your exposure to each risk factor (your beta to that factor), per day.
- bt.attributed_factor_returns. gives you a dataframe of your returns from each factor, along with your specific, total and common returns, per day.
- Both of these are daily, neither are cumulative.
More Risk Model Uses
There are other uses of the risk model that we will expand in the near future. They're items in our development queue, but not ready to release just yet:
- You will be able to access the risk model from within your algorithm. In an algorithm the risk model can be used in several ways, including as an optimization constraint or in the definition of an alpha factor. You can already define and test alpha factors today in research, accessing the risk model via the Pipeline API. This becomes even more useful once available in the algorithm.
- The risk model can also be used to evaluate a factor. Alphalens is a great tool for understanding the total returns of a current factor. The risk model will help you see even deeper into your returns. It will help you understand if your signal has alpha (specific risk) or if your signal is actually built on a common risk foundation.
Components of the Quantopian Risk Model
The deliberate, careful design of a risk model codifies a particular view of the market. The Quantopian Risk Model is designed to identify the particular risk exposures that are desired by our investor clients.
The risk model consists of a series of cascading linear regressions on each asset. In each step in the cascade, we calculate a regression, and pass the residual returns for each asset to the next step.
Sector returns - Our model has 11 sectors. A sector ETF is specified to represent each sector factor. Each stock is assigned to a sector. We perform a regression to calculate each stock's beta to its respective sector. A portion of each stock's return is attributable to its sector. The residual return is calculated and passed to the next step.
Style risk - We start with the residual from the sector return, above. We then regress the stock against the 5 style factors together. The five styles in the Quantopian risk model:
- Momentum - The momentum factor captures return differences between stocks on an upswing (winner stocks) and the stocks on a downswing (loser stocks) over 11 months.
- Company Size - The size factor captures return differences between big-cap stocks and small-cap stocks.
- Value - The value factor captures return differences between expensive stocks and in-expensive stocks (measured by the ratio of book value of company to the price of the stock).
- Short-term Reversal - The short-term reversal factor captures return differences between stocks with strong losses to reverse (recent loser stocks) and the stocks with strong gains (recent winner stocks) to reverse in a short time period.
- Volatility - The volatility factor captures return differences between high volatility stocks and low volatility stocks in the market. The volatility can be measured in historical long term or near-term.
Once the sector and style components have all been removed, the residual is the specific return.
** When we talk about risk "factors" in the context of the risk model we are referring to the time series of data that is the result of decomposing returns into risk components. This use of the word "factor" isn't the same thing as the Pipeline API concept of a Factor. They are related, but different. The overloaded terminology can be confusing.