Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Using the class BollingerBands() inbuilt factor

Hello all,

I'm new to quantopian and python so excuse me if I'm asking a stupid questions.
I'm playing around with a notebook and am using the inbuilt Bollinger Band Factor which seems to work only the output is actually three numbers instead of the one number I was expecting !!
So the question is what do those three numbers represent exactly ? I looked in the documentation on the website but it doesn't say.
Also - how do I pick the right one when I want to use it as a screen potentially ?

Thanks

Hussein

2 responses

This worked for me - check out this response, below from Martin Clasen (Jun 30, 2016):


from quantopian.pipeline import Pipeline  
from quantopian.algorithm import attach_pipeline, pipeline_output  
from quantopian.pipeline.factors import BollingerBands

def initialize(context):  
    my_pipe = make_pipeline()  
    attach_pipeline(my_pipe, 'my_pipeline')

def make_pipeline():  
    bb = BollingerBands(window_length=20, k=2)  
    return Pipeline(columns={  
        'bb_upper' : bb.upper,  
        'bb_middle' : bb.middle,  
        'bb_lower' : bb.lower,  
    })

def before_trading_start(context, data):  
    # Store our pipeline output DataFrame in context.  
    print pipeline_output('my_pipeline')  

Thanks Mark - this is great.