Back to Community
sorting entire universe according to 12 month momentum

i was wondering whether it is somehow possible to rank all stocks in the entire quantopian universe according to (some kind of) momentum? my understanding is that to do so, I would use the history function, which would however limit me to the 200 securities (or a couple more, depending whether the approach presented by MT in this threads: https://www.quantopian.com/posts/using-both-fundamental-and-technical-analysis is not only a temporary bug)?

could someone confirm that there is no other workaround for this issue than exploting the bug mentioned above (which is probably only a temporary solution anyway)?

thanks

8 responses

I'd love to see more universe-implementations too. Not just DollarVolumeUniverse.

One short term tact you could take is using Market Cap and Shares Outstanding from get_fundamentals() as a daily value in before_trading_start() for the full universe of available stocks from get_fundamentals()

So if "some kind" of momentum is a day-over-day momentum, then maybe you could take that tact. The 500 stock universe restrictions do not apply in before_trading_start() because you're not accessing pricing data.

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.

Hello Ueli,

In the Quantopian research platform, it is possible to loop over all the the securities in the entire Quantopian database. Here's a rough example I posted awhile back:

https://www.quantopian.com/posts/analysis-of-entire-quantopian-database-using-quantopian-research-platform

So, perhaps you would write a custom function, get_momentum(), and just feed it every security in a loop. As you go, stick the results in your favorite sortable data structure, and you should be all set. There are some limitations in getting data out of the research platform, which are built in to make it difficult to steal stock data sets from Quantopian, but you can probably copy-and-paste a limited amount of data into the backtester to try out an idea.

Grant

This isn't currently as easy as it could be. We are aware of the issue and working on a solution to help you do exactly this. Here is a recording of a webinar where we discussed the new approach we are planning. If you have feedback, we'd love to hear it.

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.

Ueli,

I'd add to Karen's note above, that in the meantime you can also take advantage of the 2x+ raise to the universe cap that we rolled out recently.

Here's a sample 12 month momentum algo that sorts a 5% universe based on the trailing 12 month price change, buys the top 10% (~40 stocks) and goes short the bottom 10%, rebalancing on the first trading day of each month.

Hope this helps you out while we keep working on making the full universe screen a reality!
Best, Jess

Clone Algorithm
80
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: 5568b2ec61b19f10922460dc
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.

I really appreciate the hints and suggestions. Unfortunately, also being limited to a 2x universe is still too much of a limitation.

Regarding the mentioned webinar: I really like the idea of a making a high level API available. Unfortunately it looks like this high level API is more of a workaround trying to allow as much data analysis as possible without exposing too much raw data (which I guess has been prohibited by Morningstar). Being restricted to this high level API in order to use an extended dataset however takes away a lot of the flexibility of the initial pure event based architecture. Especially the idea of using factors and filters reminds me of the Factor and Screen abstractions used by Bloomberg (FTST and EQS) which I consider more or less useless due to their lack of flexibility. As with every abstraction, it is never good enough to cover every usecase. Not having a powerful low level API to access the same data in these cases is very discouraging because there is always the risk of hitting a wall after having implemented 95% of the algorithm.

Just my two cents

Hi Ueli,
We continue to work on increasing the universe size. Our next goal is 1000 securities.

Did you watch the webinar to the part where we talked about customizing your factors, filters and classifiers? That will give you access to all of the data to with it whatever you like. The slides to the webinar are here (or will be shortly, I'm on a plane and they are uploading...) if that is an easier way for you to view the custom examples.

KR

Ueli,
The pipeline API was launched today and should help with these types of strategies. You can read all about it here.

I've also attached an example that calculates two factors (one momentum based, the other liquidity) and then ranks the universe by those factors. It longs 5% and shorts 5% of the resulting universe.

I believe we make all of the raw data available to you with this API. You have the ability to create custom factors using any piece of data from our pricing data or the Morningstar fundamentals data (and soon the Quantopian Store.) However, if there is something you would like to do and cannot, I would love to know about it. Our goal is flexibility and performance.

Clone Algorithm
819
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: 563a4dc98151f2472da8a847
We have migrated this algorithm to work with a new version of the Quantopian API. The code is different than the original version, but the investment rationale of the algorithm has not changed. We've put everything you need to know here on one page.
There was a runtime error.