Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
P/B ratio not working

I am trying to add p/b ratio to my pipeline but I get an error.

pb_ratio = fundamentals.valuation_ratios.pb_ratio

pipe = Pipeline(  
        screen = high_dollar_volume,  
        columns = {  
            'pb'         : pb_ratio  
        }  
    )  

The error that I get is...
AttributeError: Neither 'UserInstrumentedAttribute' object nor 'Comparator' object associated with UserInstrumentedAttribute has an attribute 'ndim'

7 responses

Add .latest to the fundamental value you want to fetch, that way it should work.

pb_ratio = fundamentals.valuation_ratios.pb_ratio.latest  

@Luca

pb_ratio = fundamentals.valuation_ratios.pb_ratio.latest  

I get the following error...
AttributeError: 'UserInstrumentedAttribute' object has no attribute 'latest'

How do you import fundamentals?

This works for me:

from quantopian.pipeline.data import morningstar  
morningstar.valuation_ratios.pb_ratio.latest  

I am still getting the error, I have attached the source.

Just replace

fundamentals.valuation_ratios.pb_ratio.latest  

with

morningstar.valuation_ratios.pb_ratio.latest  

Brilliant!
thanks

hi Sean,
Do you know how to get a single stock's pb_ratio?
i want to check my holding positions, if a stock's pb_ratio is greater than 20, then sell it.