Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
TypeError: 'Latest' object is not callable

Hey guys I would like to use operating gains in my fundamental algorithm. Unfortunately I get the TypeError: 'Latest' object is not callable or if I cut the .latest I get the TypeError: 'BoundColumn' object is not callable.

operating_gains_losses = morningstar.cash_flow_statement.operating_gains_losses.latest(mask=universe)

Does someone know how to fix this?

Thanks a lot and kind regards

3 responses

A first comment. You should be using the newer 'Fundamentals' instead of 'Morningstar' to get fundamental data. Take a look at this post. https://www.quantopian.com/posts/faster-fundamental-data

The answer to the question however is that '.latest' is an attribute and not a method so it can't be called. That's what's causing the error "TypeError: 'Latest' object is not callable". Just omit the parenthesis and it should work.

operating_gains_losses  = Fundamentals.cash_flow_from_continuing_operating_activities.latest

The one constraint with this is that a mask isn't available. If you want to add a mask then one can use the built in factor 'Latest' and then pass it the dataset you want to use.

operating_gains_losses = Latest(inputs=[Fundamentals.cash_flow_from_continuing_operating_activities], mask =universe)

Make sure you import 'Latest' before using it. Also remember to import 'Fundamentals'. Check out the documentation (https://www.quantopian.com/help) for info.

Good luck.

Thanks for your helpful answer, Dan! I just want to add one comment that there usually isn't any sort of benefit to masking a latest pipeline term. All that will do is have the term return NaNs where the mask is false. The mask doesn't get applied until after the data was retrieved, so it won't help to speed things up, either. Depending on what else you're doing in your pipeline, it's usually better to supply the filter as a screen to your entire pipeline, or as a mask to a computation that uses the data later on.

I hope this helps.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

The fundamentals are different by the way:

a = operating_gains_losses
b = cash_flow_from_continuing_operating_activities

2018-03-05 05:45 log_pipe:81 INFO  
                  min            mean             max  
    a    -684000000.00    -131600000.00    17000000.00  
    b    -19845000.00    3630431000.00    7671000000.00  

There's more information if you run this.

.

@Jamie I'm having trouble nailing the right way to handle the mask and screen.

This returns 5 securities

def make_pipeline():  
    m = QTradableStocksUS()      # mask  
    m = AverageDollarVolume(window_length=11).top(5, mask=m)

    ...

    pipe = Pipeline(  
        screen  = m,  

This returns only 2. It is the route I thought you were referring to but I must have misunderstood.

def make_pipeline():  
    m = QTradableStocksUS()      # mask

    ...

    pipe = Pipeline(  
        screen  = m & AverageDollarVolume(window_length=11).top(5),