Hello,
I'm a new user at Quantopian, and am trying to understand the API. In particular I don't quite understand the data sets available. I'm particularly interested in value oriented investing, and by extension the Morningstar fundamental data.
Can I think of the Pipeline API as a means of creating a custom universe instance? For example, could I recreate DollarVolumeUniverse using the Pipeline API? What would this look like?
Is there a way I can plot a data set for a security over time, just to get a feel for the data? Can I plot out a histogram for a particular metric at a given point in time? Being able to do so would be great for getting a visual feel for the type and granularity of the data in the data set.
How often is the fundamental data updated? Every day? Week? Month? Quarter? Updating earnings every quarter might be OK, but updating market cap every quarter wouldn't work as well. Thus my question.
Is it possible to get (say) the top 20% of stocks by market cap at any given point in time? How about bottom 20% by P/E? I could write the math to do this myself (as I have attempted below) but I'm hoping there's a more efficient approach.
I tried writing an algorithm to fetch market caps for all securities... my Python isn't that great, so suggestions on basic Python would also be appreciated. The interesting thing is that the log statement at the end showed far fewer than the 8000 securities that Quantopian claims to track.
def before_trading_start(context, data):
"""
Called before the start of each trading day.
It updates our universe with the
securities and values found from get_fundamentals.
"""
ranges_df = get_fundamentals(
query(
# put your query in here by typing "fundamentals."
fundamentals.valuation.market_cap,
fundamentals.valuation.shares_outstanding
)
.filter(fundamentals.valuation.market_cap != None)
.filter(fundamentals.valuation.shares_outstanding != None)
)
caps = [ranges_df[stock]['market_cap'] for stock in ranges_df]
log.info("Number of market caps collected: " + str(len(caps)))
Log output with start date 2011-01-04:
2011-01-04before_trading_start:73INFONumber of market caps collected: 4778
Log output with start date 2015-01-04:
2015-01-05before_trading_start:67INFONumber of market caps collected: 5189
Thanks!
Sunil