Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
HTTPError: 500 Server Error: INTERNAL SERVER ERROR in Research Notebook when calling get_fundamentals

I am using Quantopian Research Notebook, which is awesome! Everything runs fine until this Monday (2015-12-21), I try to run the exactly the SAME Notebook as before, but it generates a lot HTTPError: 500 Server Error: INTERNAL SERVER ERROR when the get_fundamentals API is called.

The PROBLEM is caused by using query( ).filter(fundamentals.company_reference.primary_symbol.in_(stock_list)) for ONLY SOME set of stock_list, for example, in the following code segment:

import datetime  
today = datetime.datetime.now().strftime('%Y-%m-%d')  
fundamentals = init_fundamentals()

good_list = ['AAPL', 'F', 'BABA', 'GE', 'KMI']

bad_list = ['CBD', 'MCI', 'WIT', 'SID', 'GFA', 'ERIC', 'ITUB', 'BWIN_A', 'RBPA_A']

stock_list = bad_list

fund_test_1 = get_fundamentals(  
    query(fundamentals.valuation_ratios.pe_ratio,  
          fundamentals.valuation.market_cap)  
          .filter(fundamentals.company_reference.primary_symbol.in_(stock_list)),  
          today, '5q')

fund_test_1

#############

# `.filter(fundamentals.company_reference.primary_symbol == stock_symbol)` ALSO CAUSE the same `HTTPError` for SOME `stock_symbol`

stock_symbol = 'CBD' # OR ANY symbol in above `bad_list`  
fund_test_2 = get_fundamentals(  
    query(fundamentals.valuation_ratios.pe_ratio,  
          fundamentals.valuation.market_cap)  
          .filter(fundamentals.company_reference.primary_symbol == stock_symbol),  
          today, '5q')

fund_test_2  
  1. stock_list = good_list: everything just fine.
  2. stock_list = bad_list: then HTTPError: 500 Server Error: INTERNAL SERVER ERROR will occur.
  3. stock_list = good_list + bad_list: HTTPError won't occur, BUT fund_test_1.minor_axis will only contains those in good_list.

Acctually the bad_list is very long when I was testing, I only list a few here.

This is a VERY strange error because I didn't change anything of my Notebook, it was running without any problem before. But when I re-run the Notebook this week, the error happens.

Please let me know what happens here and how to fix the problem. Thanks!

3 responses

Can anyone help? Does this kind of error exist in Algorithm IED?

It seems that this error occurs when there is no data available for a stock. If you change '5q' to '1q' you can see that you get an empty dataframe returned for the stocks in the 'bad list', and a value for p/e ratio and market cap for the ones in the 'good list'. This is a bug and I have notified our engineers.

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.

This bug has been fixed and now a query resulting in no data correctly returns an empty dataframe.