Skip to main content
Pipelines are an advanced way to compute cross-sectional factors and filters for many assets before your trading logic runs. They are useful for universe selection, ranking, and factor-based strategies. Pipeline support depends on having the right data loaders configured. The standard run path wires pricing data for EquityPricing; custom datasets require custom loaders.

Basic idea

  1. Build a Pipeline object.
  2. Attach it in initialize.
  3. Read its output after initialization, usually in before_trading_start.
  4. Use the output to choose assets or target weights.

Building a pipeline

You can add columns after construction:

Screens

A screen filters which assets appear in the output.
You can also set a screen after construction:

Common factor examples

Latest OHLCV values

Moving average

Returns

Average dollar volume

Ranking and filtering

Factors support methods such as: Example:

Reading pipeline output

context.pipeline_output(name) is available after initialization.
The output type follows the pipeline engine and loader path. In Zipline-compatible paths it is a pandas DataFrame indexed by asset for the current session.

Custom factors

Use CustomFactor for calculations that are not covered by built-in factors.
Add it to a pipeline:

When to use pipelines

Use pipelines when:
  • You need a daily ranked universe.
  • You compute the same cross-sectional factors for many assets.
  • You want to keep expensive universe-selection logic outside handle_data.
Use data.current and data.history directly when:
  • You trade only a small fixed list of assets.
  • Your signal is simple and per-asset.
  • You do not need cross-sectional ranking.