Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Piotroski F-Score Alphalens notebook

Feedback and improvements welcome.

I grabbed the Pipeline custom factor posted by Praveen Bhushan here:

https://www.quantopian.com/posts/piotroskis-f-score-algorithm

Note that the output of the factor is put through this function, with WIN_LIMIT = 0.0:

def preprocess(a):  
    a = np.nan_to_num(a - np.nanmean(a))  
    a = winsorize(a, limits=[WIN_LIMIT,WIN_LIMIT])

    return preprocessing.scale(a)  
8 responses

Hi Grant, what is the purpose of the preprocess function?
Also your Piotroski score isn't 1-9, have you normalised it?

Hello Kaya -

The preprocess function allows for the possibility of winsorizing (removes outliers - see https://en.wikipedia.org/wiki/Winsorizing). It also transforms the data, converting to z-scores, via sklearn.preprocessing.scale (for a single factor, this does nothing, but when combining factors, all of the factors need to be similarly scaled in some fashion).

Thanks Grant.
I made it into an algo and it doesn't seem to perform anywhere near what some others have got with f-score and what is blogged about. Can you see what I am doing wrong?

Not sure. Whatever you are using as your benchmarks ("it doesn't seem to perform anywhere near what some others have got with f-score and what is blogged about"), you'll need to do a detailed comparison, to make sure you've implemented your algo in the same fashion. Keep in mind that inevitably, anything in the public domain claiming to provide good performance is somehow biased (sometimes intentionally!). So, to make fair comparison, you need to apply the same bias.

Here are a couple of benchmarks that got me interested.. although i want to use it as part of a larger strategy.

Piotroski1

Piotroski sorted by ebita

Piotroski 3

Also the winsorize is very cool too, thanks for that.

As part of a larger strategy, if the factor has even a little bit of "alpha" you should be able to combine it with other factors.

thanks for the model @Leo