Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
about filter: Top Loser/Winners

Dear Quantopians,
I try to create filter! Work with template algorithm.
Lets see on basic template function:

def my_pipeline(context):  
    """  
    A function to create our dynamic stock selector (pipeline).  
    """  
    pipe = Pipeline()

    # Create a dollar volume factor.  
    dollar_volume = AverageDollarVolume(window_length=1)  
    pipe.add(dollar_volume, 'dollar_volume')  
    # Pick the top 1% of stocks ranked by dollar volume.  
    high_dollar_volume = dollar_volume.percentile_between(99, 100)  
    pipe.set_screen(high_dollar_volume)  
    return pipe  

But I need to filter with Day's - Top losers and Top winners 5-10 Narrowed down, for example! How to do that? I cant find that with quantopian API lib.
Is it custom filter? Any ideas to start with?
Thanks a lot.

2 responses

Hi Kirill,

Thanks for posting. First, you can create a Factor for the previous day's returns. You can do that with the built-in Factor Returns with window_length 1. The documentation for Returns can be found here.

Then, to find the top and bottom 5-10 for that Factor, you can use the .top and .bottom functions on that Factor. Here is the documentation for those.

Please try doing the Getting Started tutorial and Pipeline tutorial to learn more and to build a strong foundation.

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.

thx Nathan, of course I will doing tutorials. nice to hear from Quantopian's member!