Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
AttributeError: 'Field' object has no attribute 'latest' (sentiment.sentiment_signal.latest)

Hello colleagues! I am new to quantopian and programming too so dont judge me too hard.
The problem is that I receive an error message: AttributeError: 'Field' object has no attribute 'latest'!
Seems the problem with a factor 'latest'.
I would be very glad to receive any help.
Thank you in advance.

def make_pipeline_2():  
    #Factor returns  
    sentiment_factor = sentiment.sentiment_signal.latest  
    # Our universe is made up of stocks that have a non-null sentiment signal that was updated in  
    # the last day, are not within 2 days of an earnings announcement, are not announced acquisition  
    # targets, and are in the Q1500US.  
    universe = (Q1500US()  
                & sentiment_factor.notnull())  
    # A classifier to separate the stocks into quantiles based on sentiment rank.

    # Go short the stocks in the 0th quantile, and long the stocks in the 2nd quantile.  
    pipe = Pipeline(  
        columns={  
            'sentiment': sentiment_factor,  
            'longs': (sentiment_factor >=4),  
            'shorts': (sentiment_factor<=2),  
        },  
        screen=universe  
    )  
    return pipe  
2 responses

Several of the Quantopian datasets can be accessed 'interactively' as well as the typical 'pipeline' method. The following imports the 'interactive' version of the sentdex data.

from quantopian.interactive.data.sentdex import sentiment

However, to use this data in a pipeline one must import the associated pipeline version. Like this.

from quantopian.pipeline.data.sentdex import sentiment  

One could import the datasets as different names to keep them distinct if desired. So, to fix the error 'Field' object has no attribute 'latest' , simply import the pipeline version of the sentdex data before running the pipeline.

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.

Thank you a lot! It works now