scubamut
8/30/2018 - 10:20 AM

QUANTOPIAN TEMPLATE FOR ETFs

To create a quantopian pipeline for a custom list of ETFs

# Create a static list of some random iShares ETFs
my_etfs = (StaticAssets(symbols([
'IVV', #iShares Core S&P 500 ETF
'EFA', #iShares MSCI EAFE ETF
'AGG', #iShares Core U.S. Aggregate Bond ETF
'IJH', #iShares Core S&P Mid-Cap ETF
'IWM', #iShares Russell 2000 ETF
'IWD', #iShares Russell 1000 Value ETF
'IWF', #iShares Russell 1000 Growth ETF
'LQD', #iShares iBoxx $ Investment Grade Corporate Bond ETF
'EEM', #iShares MSCI Emerging Markets ETF
'EZU', #'iShares MSCI Eurozone ETF
])))


# instantiate the Latest_10 factor
latest_price = Latest_Close(mask = my_etfs)

high = USEquityPricing.high.latest
low = USEquityPricing.low.latest
open_price = USEquityPricing.open.latest
close = USEquityPricing.close.latest
volume = USEquityPricing.volume.latest

# Create a pipline with each of the factor outputs as columns
pipe = Pipeline(
            columns = {
            'high' : high,
            'low' : low,
            'close' : close,
            'open_price' : open_price,
            'volume' : volume,
            'latest_price' : latest_price,
            },
            screen = my_etfs
            )

# Run the pipeline and show the results
results = run_pipeline(pipe, '2016-07-08', '2016-07-08')
results