Notebook
In [5]:
from quantopian.pipeline.factors import AverageDollarVolume, RSI, SimpleMovingAverage
from quantopian.pipeline.filters import Q500US, QTradableStocksUS, Q1500US
from quantopian.pipeline.data.builtin import USEquityPricing
from quantopian.research import run_pipeline
import talib
import numpy as np
from quantopian.pipeline import Pipeline

def make_pipeline():

    #Factors and corresponding filters for BB Width (-+2 stdev of SMA(OHLC4,5)) of under 0.01

    #Defining OHLC4
    
    O = USEquityPricing.open.latest  
    H = USEquityPricing.high.latest  
    L = USEquityPricing.low.latest  
    C = USEquityPricing.open.latest

    OHLC4 = ( O + H + L + C )/ 4     
    
    #Moving average for last 5 days:
    
    basis = SimpleMovingAverage(inputs=OHLC4, window_length=5)
    
    #Bolinger band Width:
    
    upper_band = sma_5 + 2*(basis.std())
    lower_band = sma_5 - 2*(basis.std())
    
    BBW_5 = (upper_band - lower_band)/basis

    BBW_consolidation = BBW_5 < 0.01

    #Construct the pipeline that incorporates factors and filters from above:
    pipe = Pipeline(
        columns={
            'BBW': BBW_consolidation,
            
        },
        screen = Q500US
    )
    
    return pipe

#Run the pipeline to view output securities:
result = run_pipeline(make_pipeline(), '2019-05-24', '2019-05-24', chunksize=252)

result
TypeErrorTraceback (most recent call last)
<ipython-input-5-1b3ff5cf2e51> in <module>()
     45 
     46 #Run the pipeline to view output securities:
---> 47 result = run_pipeline(make_pipeline(), '2017-01-01', '2017-08-02', chunksize=252)
     48 
     49 result

<ipython-input-5-1b3ff5cf2e51> in make_pipeline()
     22     #Moving average for last 5 days:
     23 
---> 24     basis = SimpleMovingAverage(inputs=OHLC4, window_length=5)
     25 
     26     #Bolinger band Width:

/build/src/qexec_repo/zipline_repo/zipline/pipeline/mixins.pyc in __new__(cls, inputs, outputs, window_length, mask, dtype, missing_value, ndim, **kwargs)
    138             missing_value=missing_value,
    139             ndim=ndim,
--> 140             **kwargs
    141         )
    142 

/build/src/qexec_repo/zipline_repo/zipline/pipeline/term.pyc in __new__(cls, inputs, outputs, window_length, mask, domain, *args, **kwargs)
    477             # Allow users to specify lists as class-level defaults, but
    478             # normalize to a tuple so that inputs is hashable.
--> 479             inputs = tuple(inputs)
    480 
    481             # Make sure all our inputs are valid pipeline objects before trying

/build/src/qexec_repo/zipline_repo/zipline/pipeline/term.py in __getitem__(self, key)
    210     @expect_types(key=Asset)
    211     def __getitem__(self, key):
--> 212         if isinstance(self, LoadableTerm):
    213             raise NonSliceableTerm(term=self)
    214         return Slice(self, key)

/build/src/qexec_repo/zipline_repo/zipline/utils/input_validation.pyc in _check(func, argname, argvalue)
    451                     'funcname': get_funcname(func),
    452                     'argname': argname,
--> 453                     'actual': actual(argvalue),
    454                 },
    455             )

TypeError: zipline.pipeline.term.__getitem__() expected a value of type zipline.assets._assets.Asset for argument 'key', but got int instead.