Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
quantamental research- need help on creating algorithms

Hello fellow Quants!

I've been trying out Quantopian Platform for a while, but only recently I have gained a better understanding of its platform usage & features .

I would greatly appreciate if anyone could help to solve the following problems that I have encountered:

  • which library should i use when trying to import fundamental data? Should I use morningstar or fundamentals?
  • was trying to use 'dividend' as a ranking factor to create a long/short equity strategy, but when I trying to test-run the pipeline function, the IDE returns syntax errors. I've attach my notebook in case anyone wants to have a look

Thanks for the help.

Thomas

5 responses

First things first...

Use the 'Fundamentals' library it has replaced the Morningstar library. See https://www.quantopian.com/posts/faster-fundamental-data .

Second, the syntax you are using is incorrect. It doesn't like starting a line with a parenthesis and some other things. Should be something like this


def make_pipeline():  
    """  
    Define a pipeline.  
    """  
    # Create an arbitrary factor  
    # Use the 'latest' method to make a factor from a dataset field  
    cashflow_operation = Fundamentals.cf_yield.latest  


    # Create a filter  
    # Fundamantal data is only available for stocks and no ETFs ETNs etc  
    # One way to filter those out is to use a built-in filter like Q1500US  
    q1500us = Q1500US()  


    pipe = Pipeline(  
        columns = {  
            'cashflow_operation': cashflow_operation,  
        },  
        screen = q1500us)  
    return pipe

Attached is a notebook with this. Good luck.

Forgot to attach the notebook.

Hi Dan,

Greatly appreciate your help. I will take a look at the code.

Cheers.

Thomas

Hi Dan,

Its seems like I managed to re-run the first few parts of the code you provided on my end, however i wasn't able to test out the last part of the code, as the notebook returns the following messages. I was wondering if that means that I'm missing something in the algorithm?

Thanks

Thomas

TypeErrorTraceback (most recent call last)
in ()
----> 1 results= run_pipeline(make_pipeline(),'1-5-2017','1-5-2017')

in make_pipeline()
12 'cashflow_operation': cashflow_operation ,
13 },
---> 14 screen=q1500us)
15
16 return pipe

/build/src/qexec_repo/zipline_repo/zipline/pipeline/pipeline.py in init(self, columns, screen) 39 columns=optional(dict),
40 screen=optional(Filter),
---> 41 )
42 def init(self, columns=None, screen=None):
43 if columns is None:

/build/src/qexec_repo/zipline_repo/zipline/utils/input_validation.pyc in _check(func, argname, argvalue) 444 'funcname': get_funcname(func),
445 'argname': argname,
--> 446 'actual': actual(argvalue),
447 },
448 )

TypeError: zipline.pipeline.pipeline.init() expected a value of type zipline.pipeline.filters.filter.Filter or NoneType for argument 'screen', but got function instead.

Hmm...
I believe the error is saying that the filter you defined for the screen is wrong. The error says it's NoneType. That usually means it was never defined.

Make sure you have this line of code someplace before setting the screen

    q1500us = Q1500US()

Also, make sure you import the factor Q1500US like this

from quantopian.pipeline.filters import  Q1500US

Those are the first things which come to mind. Maybe that helps?