Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Market cap filters understanding

Hello and hi from another beginner!

I am new to Quantopian. I would like to start research with market cap ranges. I selected two ranges, big and small. But some of the equities fall into both ranges. Why?

from quantopian.pipeline import Pipeline  
from quantopian.research import run_pipeline  
from quantopian.pipeline.data import morningstar


def make_pipeline():  
    million = 1000000  
    billion = 1000 * million

    market_cap = morningstar.valuation.market_cap.latest

    return Pipeline(  
        columns={  
            'market_cap': market_cap,  
            'big': 10 * billion < market_cap < 200 * billion,  
            'small': 50 * million < market_cap < 300 * million,  
        },  
    )


date = '2017-06-15'  
result = run_pipeline(make_pipeline(), date, date)  
result.head()  

To take a visible example, why is AAME both big and small at the same time? According to Yahoo Finance it's market cap is 74.51M, so it should be only in "small" category. What am I doing wrong?

Additionally, is there a way to display market cap as a full float, not a scientific notation (with "e")?

Thanks in advance!
Remy

2 responses

OK! I know what I was doing wrong so answering my own question in case anyone comes looking for it.

Combining filters in Quantopian works like this:

...
'big': (10 * billion < market_cap) & (market_cap < 200 * billion),  
'small': (50 * million < market_cap) & (market_cap < 300 * million),  
...

thanks for the answer