QuantRocket logo
Disclaimer


Pipeline Tutorial › Lesson 15: Data Browser Integration


Browsing Pipeline Output in the Data Browser¶

Pipeline output can be opened in the Data Browser. This allows you to view plots of the pipeline columns you calculated and visualize how the calculated indicators change over time for any given security. The Data Browser also makes it easy to see a breakdown of the types of securities that are passing your pipeline screen so that you can validate your pipeline logic. Are the results concentrated in certain sectors? Do the results include security types that you would rather exclude?

In [1]:
from zipline.pipeline import Pipeline, EquityPricing, master
from zipline.pipeline.factors import SimpleMovingAverage
# import our InitialUniverse and TradableStocksUS functions
from codeload.pipeline_tutorial.tradable_stocks import InitialUniverse, TradableStocksUS

To demonstrate the Data Browser integration, let's create a Pipeline that includes 3 columns:

  • The daily closing price
  • The 200-day moving average of the closing price
  • A boolean indicator of whether the stock closed above the 200-day moving average that day. In the Data Browser, we can only view numeric columns, so we use the .as_factor() method to convert the boolean filter (True or False) into 1 or 0.

The universe for the analysis will be the TradableStocksUS universe.

In [2]:
def make_pipeline():

    initial_universe = InitialUniverse()
    universe = TradableStocksUS()

    # 200-day close price average.
    mean_200 = SimpleMovingAverage(inputs=EquityPricing.close, window_length=200, mask=universe)

    return Pipeline(
        columns={
            'close': EquityPricing.close.latest,
            '200_ma': mean_200,
            'above_200_ma': (EquityPricing.close.latest > mean_200).as_factor()
        },
        initial_universe=initial_universe,
        screen=universe
    )

Next, we run the pipeline for the date range of interest:

In [3]:
from zipline.research import run_pipeline
results = run_pipeline(make_pipeline(), start_date="2010-01-05", end_date="2011-01-05")

We can then open the pipeline output in the Data Browser by calling the IPython magic command %browse followed by the name of the results DataFrame:

In [4]:
%browse results

See the video below for a walk-through:

In [5]:
from IPython.display import VimeoVideo
VimeoVideo('920097406', width=600, height=450)
Out[5]:

Back to Introduction