Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Custom factor Z-score for stock's pe_ratio over timeframe?

How can I create a custom factor which computes the z-score of a stock's pe_ratio over the last 2 years? Something like the following.

z-score = [pe_ratio.latest - pe_ratio (average last 2 years)] / pe_ratio (standard deviation last 2 years)