Notebook
In [96]:
from quantopian.pipeline import Pipeline
from quantopian.research import run_pipeline, volumes, prices
from quantopian.pipeline.data import Fundamentals, USEquityPricing
from quantopian.pipeline.factors import SimpleMovingAverage, BusinessDaysSincePreviousEvent, AverageDollarVolume
from quantopian.pipeline.filters import QTradableStocksUS
In [99]:
def make_pipeline():
    
    universe = QTradableStocksUS()
    
    #Fundamentals variables
    roe = Fundamentals.roe.latest
    sma_200 = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length=200)
    volume = USEquityPricing.volume.latest
    price = USEquityPricing.close.latest
    average_volume = data.history(context.assets, fields="volume", bar_count=90, frequency="1d").mean()
    
    #Filters for universe
    sma_filter = USEquityPricing.close.latest > sma_200
    volume_filter = volume > 500000
    roe_filter = roe > 0.05
    universe = universe & sma_filter & roe_filter
    
    return Pipeline(
        columns = {'Price': price, 'ROE': roe, 'SMA 200': sma_200, 'Volume': volume,},
        screen = universe
    )
In [100]:
result = run_pipeline(make_pipeline(), '2019-03-10', '2019-03-10')
result.head(10)

NameErrorTraceback (most recent call last)
<ipython-input-100-20e3e7df895c> in <module>()
----> 1 result = run_pipeline(make_pipeline(), '2019-03-10', '2019-03-10')
      2 result.head(10)

<ipython-input-99-ba3e17de05a5> in make_pipeline()
      8     volume = USEquityPricing.volume.latest
      9     price = USEquityPricing.close.latest
---> 10     average_volume = data.history(context.assets, fields="volume", bar_count=90, frequency="1d").mean()
     11 
     12     #Filters for universe

NameError: global name 'data' is not defined
In [ ]:
 
In [ ]: