Skip to content
All library documents

Equity Pipeline Screening by Liquidity, Trend, and Price

Article Strategy library · Author: QuantRocket

Summary

This QuantRocket pipeline example builds a daily screen for common stocks. It first limits the starting universe to common shares, then retains securities in the upper decile of 30-day average dollar volume, trading above their 20-day simple moving average, and priced between the stated lower and upper bounds. The output includes the moving average, the latest low, and a 63-day exponentially weighted standard deviation of closing prices.

The example demonstrates how to combine universe selection, liquidity and trend conditions, price filters, and factor columns in one equity research pipeline. It is a construction example rather than a complete trading strategy: it gives no entry or exit rules, portfolio sizing, transaction-cost analysis, or performance evidence. The selected price bounds and lookback windows are fixed inputs, so their suitability depends on the market, data, and intended use.

Key ideas

  • The initial universe is restricted to common stocks.
  • A 30-day dollar-volume percentile filter selects the most liquid portion of the universe.
  • The screen requires price above its 20-day simple moving average and within fixed price bounds.
  • The pipeline returns the moving average, latest low, and exponentially weighted closing-price variability.
  • The example defines a research screen, not a full trading or portfolio management process.

Tags

Full text
# pipeline


# pipeline









## Source (Apache-2.0)

```python
# Copyright QuantRocket LLC - All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from zipline.pipeline import Pipeline, EquityPricing, master
from zipline.pipeline.factors import AverageDollarVolume, SimpleMovingAverage, ExponentialWeightedMovingStdDev

def make_pipeline():
    """
    Create a pipeline with the following rules:

    screen
    - common stocks only
    - must be liquid (top 10% by dollar volume)
    - must be above 20-day moving average
    - must not be too cheap or too expensive

    columns
    - 20-day moving average
    - prior low
    - standard deviation of closing prices
    """
    mavg = SimpleMovingAverage(
        window_length = 20, inputs = [EquityPricing.close])

    are_common_stocks = master.SecuritiesMaster.usstock_SecurityType2.latest.eq(
        "Common Stock")
    are_liquid = AverageDollarVolume(window_length=30).percentile_between(90, 100)
    are_above_mavg = EquityPricing.close.latest > mavg
    are_not_too_cheap = EquityPricing.close.latest > 10
    are_not_too_expensive = EquityPricing.close.latest < 2000

    pipeline = Pipeline(
        columns = {
            "mavg": mavg,
            "prior_low": EquityPricing.low.latest,
            "std": ExponentialWeightedMovingStdDev(
                inputs=[EquityPricing.close],
                window_length=63,
                decay_rate=0.99)
        },
        initial_universe=are_common_stocks,
        screen=(
            are_liquid
            & are_above_mavg
            & are_not_too_cheap
            & are_not_too_expensive
        )
    )

    return pipeline

```

Shown in full with attribution under the source's licence. Licence: Apache-2.0

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.