Back to Community
Leveraged ETF Screen in Pipeline

If not using https://www.quantopian.com/posts/the-q500us-and-q1500us, this is another example for screening out the contest-prohibited leveraged ETF's

from quantopian.algorithm import attach_pipeline, pipeline_output  
from quantopian.pipeline  import Pipeline  
from quantopian.pipeline.data    import morningstar as mstar  
from quantopian.pipeline.factors import CustomFactor, AverageDollarVolume  
from quantopian.pipeline.filters.morningstar import IsPrimaryShare

def initialize(context):  
    tradable = (  
        IsPrimaryShare()  
        & (ETFScreen() != 1)    # No leveraged ETF's  
        &  mstar.balance_sheet.limited_partnership.latest.isnull()  
        &  mstar.share_class_reference.security_type.latest.eq('ST00000001')  
        & ~mstar.share_class_reference.is_depositary_receipt.latest     # ~ means 'not'  
        & ~mstar.share_class_reference.exchange_id.latest.startswith('OTC')  
        & ~mstar.share_class_reference.symbol.latest.endswith('.WI')  
        & ~mstar.company_reference.standard_name.latest.matches('.* L[. ]?P.?$')  
    )  
    pipe = attach_pipeline(Pipeline(), name='zoo')  
    dollar_volume = AverageDollarVolume(window_length=20) # Tossed in, for '&' next line  
    pipe.set_screen( (dollar_volume > 10**7) & tradable )

class ETFScreen(CustomFactor):  
    inputs = [] ; window_length = 1  
    def compute(self, today, asset_ids, out):  
        out[:] = asset_ids.isin(security_lists.leveraged_etf_list.current_securities(get_datetime()))  
1 response

TYVM!

security_lists is now depreciated. Do u have a new updated version?

Dan