Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How can I filter on an equity object using Q's symbol name?

The pipline results returns a dataframe with an equity object in the index.
And I need to use Quantopian's symbol name to filter on a security certain securities.
For example I want to filter on securities with a quantopian's symbol starting by "AB".
any way to achieve it?
also if I could just retrieve the Q's symbol (not morningstar) in a column, that could help as I'd use the "startswith" ...?

4 responses

Take a look at StaticAssets in this thread https://www.quantopian.com/posts/using-a-specific-list-of-securities-in-pipeline

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Thanks Dan.
Let me detail a bit more what I wanted to achieve.
from the list of securities, I need to identify the "warrants". and I think the Warrants in quantopian have a symbol of "ABC_W".
so if I can filter on the symbol of securities, I thought I would be able to do something like "%_W" to filter on all the securities with symbols ending with W.
I know there is ".endwith" which could be used with morningstar fondamental data, but I am not sure how to do something similar with the equity object used to index the dataframe returned by the pipline.

I hope that's clarifying a bit more what I am trying to achieve, and many thanks for your guidance.

Maybe try something like this...

# Add a new column for the symbol to the output dataframe  
# The stock symbol can be gotten from the 'symbol' attribute of the equity object in the index  
pipe_output["symbol"] = [equity.symbol for equity in pipe_output.index.values]

# Filter the pipe_output to only those equities which end with '_W'  
# Presumably the warrants all end with '_W' so this will be a dataframe of just warrants  
just_warrants =  pipe_output[pipe_output.symbol.str.endswith('_W')]

Attached is a notebook which shows this in action.

Fabulous, thanks a million Dan!