Setting a list of stocks as screen in pipeline

Hey guys, brand new here! I’ve had an algorithm running on Quantopian for quite some time and I’ve been working on bringing it over with pylivetrader, along with pipeline_live and zipline. I believe I am almost done, but I am trying to set a custom screen on my pipeline and while it works in Quantopian, I cannot seem to get it to work in my environment.

stocks = StaticAssets(symbols('SPY', 'F', 'TSLA, 'MSFT')

Basically I would like to set these as a custom screen and only trade those stocks. I believe there is an issue with the zipline filter StaticAssets, but I am not sure. Any help would be greatly appreciated.

1 Like

What kind of issue exactly are you referring to?

Well, it seems that my factors aren’t working on my StaticAssets list.

I am importing the following:

from zipline.pipeline import Pipeline
from pylivetrader.api import attach_pipeline,pipeline_output
from pylivetrader.api import ( order_percent, get_datetime, get_open_orders, cancel_order, schedule_function, order_target_percent, date_rules, time_rules, symbol, symbols)
from pipeline_live.data.alpaca.factors import (AverageDollarVolume, SimpleMovingAverage, RSI, ExponentialWeightedMovingAverage)
from pipeline_live.data.alpaca.pricing import USEquityPricing
from zipline.pipeline.filters import StaticAssets
from zipline.utils.tradingcalendar import trading_days
from zipline.utils.tradingcalendar import get_early_closes
import datetime
import numpy as np
import pandas as pd
import logbook
import talib
logbook.set_datetime_format(lambda: pd.Timestamp.now(tz='America/New_York'))

And this is my initialize where I am calling my make_pipeline() method:

def initialize(context):

context.spy = symbol('SPY')
attach_pipeline(make_pipeline(), "pipeline")

And this is my make_pipeline() method:

def make_pipeline():

stocks = (StaticAssets(symbols('SPY', 'F', 'TSLA, 'MSFT')))

sma_50 = SimpleMovingAverage(
inputs=[USEquityPricing.close],
window_length=50, 
mask=stocks 
)
sma_15 = SimpleMovingAverage(
inputs=[USEquityPricing.close],
window_length=15, 
mask=stocks
)
uptrend = sma_15 > sma_50
downtrend = sma_50 > sma_15

rsi = RSI(inputs=[USEquityPricing.close],
window_length=14, 
mask=stocks
)

pipe = Pipeline(
columns={ 
'close_price': close_price, 
'rsi': rsi, 
'SMA_50': sma_50, 
'SMA_15': sma_15, 
'Downtrend': downtrend, 
'Uptrend': uptrend
}, 
screen = (stocks)
)
return pipe

Basically what’s happening is that my algo is running but for some reason the sma15, sma50 and rsi are coming back as NaN and it’s not applying the screen of the stocks to the pipe. Instead, it’s returning all US Equities, but the factors are returning as NaN. I’m a little stuck as this code was working perfectly fine on Quantopian and I can’t see where the issue might be. Any help would be great hitoshi. Thank you so much for your response and I appreciate your time.