Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Problem trying to run a simple morningstar valuation_ratio pipeline

I get this error:

ValueError: Bin edges must be unique: array([ nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan])

A variant of this worked in the research notebook. Why is an array of nan's being generated?

from quantopian.algorithm import attach_pipeline, pipeline_output  
from quantopian.pipeline import Pipeline  
from quantopian.pipeline.data.builtin import USEquityPricing  
from quantopian.pipeline.factors import AverageDollarVolume  
from quantopian.pipeline.data import morningstar  
def initialize(context):  
    """  
    Called once at the start of the algorithm.  
    """  
    # Rebalance every day, 1 hour after market open.  
    schedule_function(my_rebalance, date_rules.every_day(), time_rules.market_open(hours=1))  
    # Record tracking variables at the end of each day.  
    schedule_function(my_record_vars, date_rules.every_day(), time_rules.market_close())  
    # Create our dynamic stock selector.  
    attach_pipeline(make_pipeline(), 'my_pipeline')  
def make_pipeline():  
    """  
    A function to create our dynamic stock selector (pipeline). Documentation on  
    pipeline can be found here: https://www.quantopian.com/help#pipeline-title  
    """  
    exchange = morningstar.share_class_reference.exchange_id.latest  
    nyse_filter = exchange.eq('NYS')

    forward_yield = morningstar.valuation_ratios.forward_earning_yield.latest  
    total_yield = morningstar.valuation_ratios.total_yield.latest

    dollar_volume_decile = AverageDollarVolume(window_length=10).deciles()  
    top_decile = (dollar_volume_decile.eq(9))  
    forward_yield_decile = forward_yield.deciles()  
    top_yield_decile = (forward_yield_decile.eq(9))  
    total_yield_decile = total_yield.deciles()  
    top_total_yield_decile = (total_yield_decile.eq(9))

    return Pipeline(  
        columns={  
            'dollar_volume_decile': dollar_volume_decile,  
            'foward_earnings_yield': forward_yield  
        },  
        screen=(nyse_filter & top_yield_decile)  
    )  
def before_trading_start(context, data):  
    """  
    Called every day before market open.  
    """  
    context.output = pipeline_output('my_pipeline')  
    # These are the securities that we are interested in trading each day.  
    context.security_list = context.output.index  
    # Go long in securities for which the 'longs' value is True.  
    #context.longs = context.output[context.output['foward_earnings_yield']].index.tolist()  
def my_assign_weights(context, data):  
    """  
    Assign weights to securities that we want to order.  
    """  
    long_weight = 1 / len(context.top_yield_decile)  
    return long_weight  
def my_rebalance(context,data):  
    """  
    Execute orders according to our schedule_function() timing.  
    """  
    for security in context.portfolio.positions:  
        if security not in context.longs and data.can_trade(security):  
            order_target_percent(security, 0)

    for security in context.security_list:  
        if data.can_trade(security):  
            order_target_percent(security, context.long_weight)

def my_record_vars(context, data):  
    """  
    Plot variables at the end of each day.  
    """  
    pass  
def handle_data(context,data):  
    """  
    Called every minute.  
    """  
    pass