Back to Community
Ranking System based on Trading Volume/Shares Outstanding

Hi Quantopian,

I am stuck trying to build a stock ranking system with two signals:
1. Trading Volume/Shares Outstanding.
2. Price of current day / Price of 60 days ago.
Then rank Russell 2000 stocks every month, long the top 5%, short the bottom 5%.

But I don't know how to mix Shares Outstanding with Trading Volume for a large stock universe. Can someone explain this with sample codes?

Thanks,

11 responses

Bo,

The browser-based backtester doesn't support large numbers of securities. There's a kind of built-in limit of 200 stocks (there is a hack work-around, but it has several drawbacks which make it impractical).

However, the Quantopian research platform should (hopfully) support your effort. If you don't have access, you can submit an algo to the Quantopian open contest, and get preferential treatment. The contest algo can be anything (although I must imaging that the Q intent is that you would actually try to compete).

What do you mean by "mix Shares Outstanding with Trading Volume for a large stock universe"? Are you talking about taking a ratio?

Grant

Grant,

Thank you for the response. I already have access to the Research tab. I tried to call get_fundamentals() in Research, but got this error: "NameError: name 'get_fundamentals' is not defined".

Yes. I just need two ratios:
1. Ratio1 (50% weight) = Trading Volume/Shares Outstanding
2. Ratio2 (50% weight) = Price(current day) / Price(60 days ago)

Then I will rank a large stock universe, then I can buy stocks in the top 5% and sell stocks in the bottom 5%. I'd like to back test this strategy monthly. Is it possible to do in Quantopian?

Thanks,
Bo

I don't know the current status, but see:

https://www.quantopian.com/posts/get-fundamentals-slash-query-from-a-research-notebook

So, it's either available, or on the way.

Hi Bo,

Grant is correct. When backtesting in minute mode or live trading, you can scan the prices and trading volumes of a maximum of 200 stocks. We need to enforce this cap to ensure algorithms can keep up with the flow of minute level market data. That being said, we are in the process of designing and API change that will allow you to screen for price/volume for a much larger universe before trading starts each day.

In research, you can scan as large a universe as you would like for price/volume. One of our engineers is currently working on porting get_fundamentals to research. Until that is done, you can import you own "shares outstanding" data. I know you can grab individual stock's shares outstanding historical data from Ycharts and Quandl. I'll be on the lookout for a publicly available market-wide dataset.

I don't have an exact timeline for either of these new features, but know that they are coming! Stay tuned for more details.

Andrew

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.

Bo,
We have just launched the Pipeline API, which makes this kind of algorithm very simple to write. I've pulled it together for you, and the code is attached.

The challenge for me in writing this was guessing how you wanted the ranks ordered, but I took a guess. I'm sure you can take it from here and turn it into something profitable!

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.
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.

if we can rank 2000 stocks this way does this mean that security limit of 500 has been lifted?

You still are limited to getting minutely data each day on 500 securities. However, you can calculate factors across the entire tradable universe of equities, on daily data, using the pipeline API.

We hope to change the 500 limit in the near future as well, but this opens up tons of different strategies that were previously not available.

I am a newbie..I didn't Understand this I thought pipeline will scan for all the stocks in the universe every minute, you guys didn't mention anything like this in the tutorial, Is it still 500 or it is lifted??

In q2 many of these restrictions are lifted.

Dan,

What's mean by Q2 when did they released it ?

KS

This should help you out with the history:

https://www.quantopian.com/quantopian2

Thanks
Josh

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.