Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
There seems to be a problem with the morningstar fundamental data api

If I run the standard query from the help, i get mixed up data back. i am new to python/pandas so it might be just me...
Any ideas?

   # Setup SQLAlchemy query to screen stocks based on PE ratio  
    # and industry sector. Then filter results based on  
    # market cap and shares outstanding.  
    # We limit the number of results to num_stocks and return the data  
    # in descending order.  
    fundamental_df = get_fundamentals(  
        query(  
            # put your query in here by typing "fundamentals."  
            fundamentals.valuation_ratios.pe_ratio,  
            fundamentals.asset_classification.morningstar_sector_code  
        )  
        .filter(fundamentals.valuation.market_cap != None)  
        .filter(fundamentals.valuation.shares_outstanding != None)  
        .order_by(fundamentals.valuation.market_cap.desc())  
        .limit(num_stocks)  
    )  

from the debugger, the PE and Sector_code looks mixed up, duplicated for some stocks, just doesnt look right
fundamental_df fundamental_df: DataFrame 0_Security(24 [AAPL]): Series 0_pe_ratio: 13.947 1_morningstar_sector_code: 311.0 1_Security(8347 [XOM]): Series 0_pe_ratio: 311.0 1_morningstar_sector_code: 13.947 2_Security(26578 [GOOG_L]): Series 0_pe_ratio: 13.947 1_morningstar_sector_code: 311.0 3_Security(5061 [MSFT]): Series 0_pe_ratio: 311.0 1_morningstar_sector_code: 13.947 4_Security(1091 [BRK_A]): Series

it might be the debugger because when i run this
fundamental_df.iloc[0,:]
the values look correct

fundamental_df.iloc[0,:]  
    fundamental_df.iloc[0,:]: Series  
        0_Security(24 [AAPL]): 13.947  
        1_Security(8347 [XOM]): 13.7174  
        2_Security(26578 [GOOG_L]): 62.1118  
        3_Security(5061 [MSFT]): 13.8313  
        4_Security(1091 [BRK_A]): 15.015  
        5_Security(3149 [GE]): 19.084  
        6_Security(11100 [BRK_B]): 14.2857  
        7_Security(4151 [JNJ]): 19.0476  
        8_Security(8229 [WMT]): 15.4083  
        9_Security(23112 [CVX]): 11.2613  
        10_Security(8151 [WFC]): 11.6686  
        11_Security(27470 [RDS_B]): 14.43  
2 responses

Hi Attila,

Your instinct that this might be a bug with the debugger is likely correct.

This seems to be a reoccurrence of a long-standing bug we have not yet whacked. See this thread for an earlier workaround: https://www.quantopian.com/posts/debugger-problem

Generally, I think you can also work around like you did: by avoiding relying upon the nice nesting features in the debugger

Thanks,
Josh

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.

Thanks Josh,