EquityPricing; custom datasets require custom loaders.
Basic idea
- Build a
Pipelineobject. - Attach it in
initialize. - Read its output after initialization, usually in
before_trading_start. - Use the output to choose assets or target weights.
Building a pipeline
Screens
A screen filters which assets appear in the output.Common factor examples
Latest OHLCV values
Moving average
Returns
Average dollar volume
Ranking and filtering
Factors support methods such as:| Method | Meaning |
|---|---|
factor.top(N) | Keep the top N assets by factor value |
factor.bottom(N) | Keep the bottom N assets |
factor.percentile_between(min, max) | Keep assets between percentile bounds |
factor.rank() | Rank assets by value |
factor.zscore() | Cross-sectional z-score |
factor.demean() | Subtract cross-sectional mean |
Reading pipeline output
context.pipeline_output(name) is available after initialization.
Custom factors
UseCustomFactor for calculations that are not covered by built-in factors.
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.
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.