Back to Community
Lecture 17 - help needed

Please update Lecture 17 to reflect changes that have been made to accessing fundamentals data. When i run the code below from the lecture:

# Get most recent free cash flow, operating cash flow, and total revenue data
fundamentals = init_fundamentals()
today =
data = get_fundamentals(query(fundamentals.cash_flow_statement.free_cash_flow,
.filter(fundamentals.valuation.market_cap > 1e8, # Filter by market cap & industry
fundamentals.company_reference.industry_template_code == 'T'), today).T

I'm getting the following error message:

ValueErrorTraceback (most recent call last)
in ()
4 # Get most recent free cash flow, operating cash flow, and total revenue data
----> 5 fundamentals = init_fundamentals()
6 today =
7 data = get_fundamentals(query(fundamentals.cash_flow_statement.free_cash_flow,
/build/src/qexec_repo/qexec/research/ in init_fundamentals() 63 def init_fundamentals():
64 raise ValueError(
---> 65 'The init_fundamentals method has been removed. To use fundamental'
66 ' data in your notebooks and algorithms, use Pipeline.\n'
67 'See:',
ValueError: The init_fundamentals method has been removed. To use fundamental data in your notebooks and algorithms, use Pipeline.

I'm still learning and I don't know how to reference the fundamentals data using Pipeline yet. Could you please assist. Thank you

Loading notebook preview...
3 responses

I too am new here.

But I think they have changed where the fundamentals come from. I know you can pull them from the Morningstar data set. So you'd need to replace:
fundamentals = init_fundamentals()
from import morningstar

and then the individual elements that you are looking for would be provided by:

The problem is I think this data can only be pulled in within a pipeline, so I think you'd have to re-write the model with a pipeline. I don't have enough experience to assist with that.

Good luck! And apologies in advance if I am sending you in the wrong direction.

Thank you Paul. I haven't started working with Pipeline yet. I guess I can skip it for now and then come back later. Again, thank you.

Hi. I came back to this lecture after learning about Pipeline. Replace the fundamentals code with this:

from quantopian.pipeline import Pipeline  
from quantopian.research import run_pipeline  
from quantopian.pipeline.filters import QTradableStocksUS  
from import morningstar

def make_pipeline():  
    # Filter by market cap & industry  
    market_cap_filter = morningstar.valuation.market_cap.latest > 1e8  
    industry_filter = morningstar.company_reference.industry_template_code.latest.eq('T')  
    return Pipeline(  
        columns = {  
            'free_cash_flow': morningstar.cash_flow_statement.free_cash_flow.latest,  
            'operating_cash_flow': morningstar.cash_flow_statement.operating_cash_flow.latest,  
            'total_revenue': morningstar.income_statement.total_revenue.latest  
        screen = QTradableStocksUS() & market_cap_filter & industry_filter  

# Get free cash flow, operating cash flow, and total revenue data  
data = run_pipeline(make_pipeline(), '2020-06-28', '2020-06-28')  

Hope this helps.