Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Notebook: Filtering by Ranking Score?

Hi,

I'm trying to learn how to create a screener in the Notebook module. After some searching I was able to get the basics down (I think). My next step is to try to setup something similar to Piotroski's f score.

I've setup my criteria in the format:

if varfactor > 0 :  
        factor_score = 1  

Then I summed upthe scores and set a sum filter:
total_score = factor_score1 + factor_score2 + etc. score_filter = total_score > 6 equities_list = score_filter

I then tried to screen the pipeline using:
screen = equities_list

However, given the above, I get the following error:
``` TypeErrorTraceback (most recent call last)
in ()
1 #Run the pipeline to view output securities:
----> 2 result = run_pipeline(make_pipeline(), '2019-01-04', '2019-01-04', chunksize=252)

in make_pipeline()
76 'Score': total_score,
77 },
---> 78 screen = equities_list
79 )
80

/build/src/qexec_repo/zipline_repo/zipline/pipeline/pipeline.py in init(self, columns, screen, domain) 42 columns=optional(dict),
43 screen=optional(Filter),
---> 44 domain=Domain
45 )
46 def init(self, columns=None, screen=None, domain=GENERIC):

/build/src/qexec_repo/zipline_repo/zipline/utils/input_validation.pyc in _check(func, argname, argvalue) 451 'funcname': get_funcname(func),
452 'argname': argname,
--> 453 'actual': actual(argvalue),
454 },
455 )

TypeError: zipline.pipeline.pipeline.init() expected a value of type zipline.pipeline.filters.filter.Filter or NoneType for argument 'screen', but got bool instead.
```

Any thoughts on why I'm getting this error? Am I missing something related to properly formatting the scoring system as integers? Any suggestions are greatly appreciated.

4 responses

You might want to post your notebook. I can't figure out what you're trying to do. The error you're getting is that the screen parameter you're initializing the Pipeline with is the wrong data type. It should be a Filter.

Notebook attached, appreciate the quick reply!

Okay, so when you're creating your pipeline, roa, cfo, and such are factors. The result doesn't get calculated until the pipeline is run. The screen in a pipeline is the total universe of stocks you're choosing from. So the definition of your pipeline would be something like this:

    pipe = Pipeline(  
        columns={  
            'roa_filter' : roa > 0,  
            'cfo_filter': cfo > 0,  
            'roachange_filter': roa > roa_1yr,  
            'quality': cfo > ni,  
            'ltd_filter': ltd < ltd_1yr,  
            'cratio_filter': cratio > cratio_1yr,  
            'shares_filter': shares <= shares_1yr,  
            'margin_filter': margin > margin_1yr,  
            'ato_filter': ato > ato_1yr  
        },  
        screen = Q1500US(),  
    )  

Then after you run it, you would sum up the columns that are true:

make_pipeline()  
result = run_pipeline(make_pipeline(), '2019-01-04', '2019-01-04', chunksize=252)  
result['sum'] = result.sum(axis=1)  
tradeable_assets = result[result['sum']>6]  

That's perfect, thanks again for your help!!