Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Looking to create stock screener

Hello Q community,

I am new to python & quantopian, although i have been reading around & must say i am impressed by the diversity of ideas around here. Keep it up!

Currently i am doing some manual trading based on mostly technical factors. Sometimes i feel a bit overwhelemed when it comes to futures/ stocks to know what names i should be keeping an eye on & frankly i don't enjoy (price) screen time much. What i am looking to create is a simple screener which will list the tickers of futures/ stocks that fulfill certain criteria. I have a feeling this would probably work using the Pipeline.

For example how would i go about attaining a list of tickers which fulfil the following criteria:
1. RSI of over 50 for the last week
2. 7 day fast moving average > 30 day slow MA

Any ideas/tips or things to read would be massively appreciated!

Thanks in advance,
Florian

6 responses

Hi Florian,

Feel free to check out this example notebook I wrote for you that demonstrates proper usage of a pipeline screen. It uses the criteria you mentioned and outputs a list of securities from January-August 2017.
Reading through the pipeline tutorial which incorporates information on factors, filters, and screens can really help as well! Let me know if you have any other questions.

Thanks,
Robert

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.

Hi Robert,

I stumbled upon the thread based on searching how to build a screener in Quantopian. I am a complete novice but your code covers a lot of what I actually need. Thank you so much for that!

I wanted to ask you whether I could import the OHLC4 ((open + high + low + close)/4)) prices somehow from quantopian.pipeline.data.builtin library because from what I understood the USEquityPricing is based only on the close prices?

And if I cannot do that, is the data_handle with get_pricing the only way to get the OHLC4 that I need? If so, can I apply that to the whole universe of Quantopian for the purposes of the screener?

Thank you!

Thank you!

Mihail,

Try something like this:

from quantopian.pipeline.filters import Q500US, QTradableStocksUS  
from quantopian.pipeline.data.builtin import USEquityPricing  
from quantopian.research import run_pipeline  
from quantopian.pipeline import Pipeline  
def make_pipeline():

    O = USEquityPricing.open.latest  
    H = USEquityPricing.high.latest  
    L = USEquityPricing.low.latest  
    C = USEquityPricing.open.latest

    OHLC4 = ( O + H + L + C )/ 4     

    pipe = Pipeline( columns={'OHLC4': OHLC4}, screen = Q500US())  
    return pipe  
result = run_pipeline(make_pipeline(), '2019-05-24', '2019-05-24')  

OHLC4

2019-05-24 00:00:00+00:00

Equity(2 [ARNC]) 22.116750
Equity(24 [AAPL]) 179.487500
Equity(53 [ABMD]) 263.202500
Equity(62 [ABT]) 75.934750
Equity(67 [ADSK]) 170.225000
Equity(76 [TAP]) 58.847500
Equity(114 [ADBE]) 276.672500
Equity(122 [ADI]) 99.280000
Equity(128 [ADM]) 39.298750

Awesome, Vlad.

I tried to run the screener but did not manage to and do not know why. I would be extremely grateful if you have a look at it (in the attached notebook).

The idea is supersimple - the screener returns stocks with bolinger band width < 0.001, where

// basis of bolinger band = sma(OHLC4,5)

// upper band = basis + 2*basis.std() // just saw that in the notebook I have left sma_5 instead of basis but that does not solve the problem

// lower band = basis - 2*basis.std() // just saw that in the notebook I have left sma_5 instead of basis but that does not solve the problem

// bolinger band width = (upper band - lower band) / basis

Mihail,

For use OHLC4 that way you need to create a custom factor.

Thanks! I think I just managed to do that but still getting errors.