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.