Back to Community
New to coding (Python, anyway), problem with pipeline screen

Hey guys, trying to use Pipeline, having some difficulty. I get I'm using a lot of filters, but it's a personal preference. Anyway to get this working? Thanks.

This is a template algorithm on Quantopian for you to adapt and fill in.  
from quantopian.algorithm import attach_pipeline, pipeline_output  
from quantopian.pipeline import Pipeline  
from import USEquityPricing  
from quantopian.pipeline.factors import AverageDollarVolume  
from quantopian.pipeline.filters.morningstar import Q1500US  
from quantopian.pipeline.factors import MovingAverageConvergenceDivergenceSignal  
from import morningstar

def initialize(context):  
    Called once at the start of the algorithm.  

    macd = MovingAverageConvergenceDivergenceSignal(inputs=[USEquityPricing.close])  
    pipe_screen = (morningstar.valuation_ratios.pe_ratio<15, morningstar.valuation_ratios.pe_ratio>0, morningstar.earnings_ratios.diluted_eps_growth>25, morningstar.operation_ratios.current_ratio>1.2, morningstar.operation_ratios.net_margin>0, macd > 0)

    price = [USEquityPricing.close]  
    pipe_columns = {'Price' : price}  
    pipe = Pipeline(columns = pipe_columns, screen = pipe_screen)  
    attach_pipeline(pipe, name='my_pipeline')

Error code I get is : "TypeError: zipline.pipeline.pipeline.init() expected a value of type zipline.pipeline.filters.filter.Filter or NoneType for argument 'screen', but got tuple instead.
There was a runtime error on line 22."

1 response

You need to combine those factors using the logical AND operator & instead of with a , (which creates a tuple).