Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Valuation ratios error

I did a simple algorithm to find a error. If I use some valuation ratios (pe_ratio, ps_ratio, payout_ratio, pb_ratio, pfc_ratio) I don't have any error. But if a use forward_pe_ratio or peg_ratio, a error appears:

TypeError: Don't know how to construct AdjustedArray on data of type .
There was a runtime error on line 33.

I can't explain why this error appears only with certain valuation ratios. Would you help me with this error?

Thanks!

6 responses

Hi Carlos,

I took a look and I'm not sure what's causing this error so I've forwarded it along to our engineers, sorry about that!

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.

How can I know if this error is fixed?

Thanks!

Hi Carlos, it hasn't yet been fixed. We will likely post in the forums or respond to threads that mentioned this issue directly. Thanks for your patience.

Hi Carlos,

This bug has been fixed! You can now use forward_pe_ratio and peg_ratio.

Hi Jamie:

I checked the algorithm, it's fine, but the forward_pe_ratio and peg_ratio fail in this little notebook. The same error appears. I don't know if those errors have the same origin.

Thanks!

Running into the same issue when use get_fundamentals function. Any suggestions?

Code:

def before_trading_start(context, data):
"""
Called every day before market open.
"""
context.output = pipeline_output('my_pipeline')

"""  
  Called before the start of each trading day.  
  It updates our universe with the  
  securities and values found from fetch_fundamentals.  
"""

num_stocks = 20

# Setup SQLAlchemy query to screen stocks based on PE ration  
# 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.operation_ratios.revenue_growth,  
        fundamentals.valuation_ratios.peg_ratio,  
        fundamentals.valuation_ratios.forward_pe_ratio,  
        fundamentals.income_statement.ebit  
    )  
    # No Financials (103), Real Estate (104) or Utility (207) Stocks, no ADR or PINK, only USA  
    .filter(fundamentals.company_reference.country_id == "USA")  
    .filter(fundamentals.share_class_reference.is_depositary_receipt == False)  
    .filter(fundamentals.share_class_reference.is_primary_share == True)

    # Only pick active stocks  
    .filter(fundamentals.share_class_reference.share_class_status == "A")  
    # Only Common Stock  
    .filter(fundamentals.share_class_reference.security_type == "ST00000001")  
    .filter(fundamentals.company_reference.primary_exchange_id != "OTCPK")  
    .filter(fundamentals.valuation.market_cap != None)  
    .filter(fundamentals.valuation.market_cap >= 2e9)  
    .filter(fundamentals.valuation.market_cap < 1e100)  
    .filter(fundamentals.operation_ratios.roic > 0.1)

    .filter(fundamentals.valuation.shares_outstanding != None)  
    .filter(fundamentals.valuation_ratios.ev_to_ebitda != None)

    .order_by(fundamentals.operation_ratios.revenue_growth.desc())  
    .limit(num_stocks)  
)

# Filter out only stocks that fits in criteria  
context.security_list = [stock for stock in fundamental_df]  
print fundamental_df.head(5) # ['forward_pe_ratio']

debug info:

2010-01-04 PRINT security Equity(27993 [LINE]) Equity(36093 [IPI]) Equity(24831 [ESI]) \
revenue_growth 3.895252 2.43894 0.335742
peg_ratio None None None
forward_pe_ratio None None None
ebit 9.13037e+08 8.6269e+07 1.22208e+08

security Equity(36346 [LO]) Equity(23650 [ARO]) Equity(3450 [MNST]) \
revenue_growth 0.261333 0.177997 0.080506
peg_ratio None None None
forward_pe_ratio None None None
ebit 3.93e+08 1.05681e+08 9.2915e+07