Hi all,
I'm super new to Quantopian, and currently working through a tutorial to set up my first algorithm.
I'm trying to do something super, super simple - set up a Pipeline to screen for companies with market cap > $50m. However, I'm running into trouble and can't find anything in the docs that answers this simple question.
In the research environment I get the following error when I run the code below: "AttributeError: 'Latest' object has no attribute 'factor'"
However, if i replace
& market_cap > 50000000)
with
& market_cap.isnotnull()
the error disappears.
I'm confused. The docs states:
The most common way to construct a Filter is via one of the comparison operators (<, <=, !=, eq, >, >=) of Factor. For example, a natural way to construct a Filter for stocks with a 10-day VWAP less than $20.0 is to first construct a Factor computing 10-day VWAP and compare it to the scalar value 20.0:
from zipline.pipeline.factors import VWAP
vwap_10 = VWAP(window_length=10)
vwaps_under_20 = (vwap_10 <= 20)
market_cap is set up as a factor (a numerical value), so why isn't this working? I'm so confused! Would really appreciate any info the community could share here.
Thanks,
from quantopian.pipeline import Pipeline
from quantopian.research import run_pipeline
from quantopian.pipeline.filters.morningstar import Q1500US
from quantopian.pipeline.data import Fundamentals
from quantopian.pipeline.factors.fundamentals import MarketCap
def make_pipeline():
sentiment_factor = sentiment.sentiment_signal.latest
market_cap = Fundamentals.market_cap.latest
# Our universe is made up of stocks that have a non-null sentiment signal that was updated in
# the last day, are not within 2 days of an earnings announcement, are not announced acquisition
# targets, and are in the Q1500US.
universe = (Q1500US()
& sentiment_factor.notnull()
& market_cap > 50000000)
pipe = Pipeline(
columns={
'sentiment': sentiment_factor,
'longs': (sentiment_factor >=4),
'shorts': (sentiment_factor<=2),
},
screen=universe
)
return pipe