Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Assistance with this algo would be appreciated

No trades are ever placed and it seems the "rebalance" subroutine never gets executed.

Please see my next post for the source code.

Many thanks if you are willing to have a look at it (it's quite short :-)).

Tim

4 responses

I have just realized that I can attach the source and the back-test results in a form that is much more convenient for inspection.
Sorry for not having figured it out earlier.

The Morningstar database seems to have no PEG ratios, so this line in your code means that no stocks get selected:

        .filter(fundamentals.valuation_ratios.peg_ratio != None)

Also, these two lines refer to 'pge_ratio' rather than 'peg_ratio':

    x = context.fund['pge_ratio'].quantile(0.80)  
    shorts = context.fund[context.fund['pge_ratio'] > x]

See this post for more on problems with peg_ratio in the Morningstar data.

Thank you, Michael, for this valuable piece of information and for the careful reading of my code.