Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Enhancing Mean Reversion Algorithms

Mean-reversion is one of the most widely known trading strategies in quantitative finance. In his post about Enhancing Short-Term Mean-Reversion Strategies, Rob Reider discusses his experience working with strategies rooted in mean-reversion, and suggests ways in which a standard mean-reversion strategy can be augmented.

Extending from that, I explored enhancing a mean-reversion strategy using Alpha Vertex’s PreCog 500 data set. After studying the original mean-reversion algorithm found here, I developed the following hypothesis. Alpha Vertex’s 5 day forecasts could be used to discern which stocks to go long and short on in a mean-reversion strategy, and lead to less instances of a position being closed after the stock reverting.

The methodology I followed is as such. First, after researching the Alpha Vertex data and finding enough overlap between the group of stocks covered here and the Q500 universe, I divided the forecast returns into quantiles. Then, in addition to using standard mean-reversion logic to determine which stocks I should take long and short positions in, I added stocks in the highest and lowest quantile of forecast returns to the long and short baskets respectively.

Implementing this strategy resulted in slightly higher returns over the same time period than the original algorithm. Also, other metrics, including Beta, Sharpe Ratio, and Drawdown had more satisfactory values. Also, it may be worth noting that volatility was also lower.

I’m curious about exploring these results further and would love to hear from the community. I’d love to hear ways my implementation of this algorithm could be improved. Thanks in advance.

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.

4 responses

Here are the results of the backtest.

Hi Jeremy -

It is important to note that the Alpha Vertex PreCog dataset was loaded March 6, 2017 and thus most of the data are considered in-sample:

https://www.quantopian.com/posts/alpha-vertex-precog-dataset#58c31ee6125e066b29568aaa
https://www.quantopian.com/posts/quantopian-partner-data-how-is-it-collected-processed-and-surfaced

I see from the little "Q" next to your name that you are affiliated with Quantopian, so perhaps this is old news to you, but I thought I'd point it out for the masses. It doesn't necessarily invalidate your results, but in my opinion, they need to be taken with a grain of salt, until more out-of-sample data are available (the minimum used by the Q Fund team is 6 months).

Also, in your algo above, I'd point out that you are using:

    # Set commissions and slippage to 0 to determine pure alpha  
    set_commission(commission.PerShare(cost=0, min_trade_cost=0))  
    set_slippage(slippage.FixedSlippage(spread=0))  

Hi all,

I tried to clone this algo to learn more about the mean reversion strat utilised. I can see from the error log that the following import failed from line 23 (No module was found):

import precog_top_500 as precog

Any solutions? Thanks!

Hi Martin,

Unfortunately, AlphaVertex stopped updating the dataset in January 2018, so we removed the dataset from Quantopian. My suggestion would be to create your own factor and replace the dataset_500.predicted_five_day_log_return column with something you create. From a technical perspective, you should be able to put any pipeline factor in its place. Conceptually, I'm not sure what a suitably comparable factor would be, but there are several of other datasets that you can look through for ideas.

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.