I'm not sure if I am overlooking something or doing something wrong, but, I tried to modify a code on Quantopian to work with Pylivetrader and am getting different results from the Pipeline.
First block is the Quantopian Code
def make_pipeline():
have_market_cap = morningstar.valuation.market_cap.latest.notnull()
avg_volume = SimpleMovingAverage(inputs=[USEquityPricing.volume],window_length=50)
filter_volume = avg_volume > 500000
last_price = Latest(inputs=[USEquityPricing.close], window_length=1)
filter_price = last_price > 1
dollar_volume = AverageDollarVolume(window_length=50)
filter_dollar_volume = dollar_volume > 2500000
sma_150 = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length=150)
filter_sma_150 = USEquityPricing.close.latest > sma_150
atr_10_percent = atr_10days_percent()
filter_atr_10 = atr_10_percent > 4
rsi = RSI(inputs=[USEquityPricing.close], window_length=3)
filter_overbought = rsi < 30
atr_10 = atr_10days()
stocks_to_trade = have_market_cap & filter_volume & filter_price & filter_dollar_volume & filter_sma_150 & filter_atr_10 & filter_overbought
Here is the Pylivetrader code
def make_pipeline():
have_market_cap = PolygonCompany.marketcap.latest.notnull()
avg_volume = SimpleMovingAverage(inputs=[USEquityPricing.volume],window_length=50)
filter_volume = avg_volume > 500000
last_price = Latest(inputs=[USEquityPricing.close], window_length=1)
filter_price = last_price > 1
dollar_volume = AverageDollarVolume(window_length=50)
filter_dollar_volume = dollar_volume > 2500000
sma_150 = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length=150)
filter_sma_150 = USEquityPricing.close.latest > sma_150
atr_10_percent = atr_10days_percent()
filter_atr_10 = atr_10_percent > 4
rsi = RSI(inputs=[USEquityPricing.close], window_length=3)
filter_overbought = rsi < 30
atr_10 = atr_10days()
stocks_to_trade = have_market_cap & filter_volume & filter_price & filter_dollar_volume & filter_sma_150 & filter_atr_10 & filter_overbought
They both output different set of stocks and maybe a couple of stocks will be the same in a week, but 95% are different.
Small fluctuations in historic price data could account for a small difference, but hardly any matching results seems very unlikely.
Does anyone have any insight into this?