Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Long-Short Equity with Risk Model

I modified the Long-Short Equity template in the Lecture Series to use the new risk model to bring it up to speed for contest submission. Here I'm using a combination of sentiment and broker ratings to rank securities in the QTradableStocksUS. Definitely feel free to swap out the factors that I used for factors of your own design.

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.

8 responses

And here is the contest check notebook.

Thank you Max,

I played with the code a little bit and found out that removing the 300 top/bottom pipeline filter improves overall metrics. My guess is that the factors have low autocorrelection and there's a lot of shuffling in there. The optimizer sometimes seem to benefit from having the whole universe to play with.

Here's a tweak to Charles' algo. I changed the universe to be more volatile. Note that turnover is pretty high, and commissions and slippage are both set to zero.

Grant,

With all due respect, I think your tweak goes against what I was proposing. You would probably be better off by adding a volatility component as a factor, and rank it on the whole QTradableUniverse, instead of filtering it up front.

This is a template for people to add their own factors, so tweaking this particular algo isn't really the goal here IMO. But still, just for fun, lower volatility seems to work better:

Charles, that's a neat find. I agree that it's likely the autocorrelation, but I'd have to dig a little deeper.

I made another version of this algorithm that does not use the premium dataset. It has negative returns, but perhaps there is another combination of factors that follows a similar idea that performs better.

You can make that positive instead of negative returns with a simple flip of long, short using a minus sign in front of pipeline_data.combined_factor on line 147. These might all have overridden commissions and slippage, not sure that's a great idea except maybe temporarily during testing.

The point of the template is to have something that you can slot your own factors into. The factors that I provided are placeholders to show how the mechanics work. Feel free to tinker with any aspect that you like!