Back to Community
DollarVolumeUniverse and set_universe to be Removed

The universe.DollarVolumeUniverse() and set_universe functions are finally being removed from the Quantopian API. These functions have been deprecated since we updated to Quantopian 2 in April 2016.

You can still select a dynamic trading universe based on dollar volume in pipeline. Better yet, you can use the Q1500US to trade the top 1500 most liquid stocks. The attached backtest defines a pipeline that selects the top 10% of stocks in the Q1500US by dollar volume.

We expect the removal of these functions to take place soon so you should consider updating your algorithms if they still use DollarVolumeUniverse or set_universe.

If you have any questions, or need help updating your code, please let us know.


Clone Algorithm
Total Returns
Max Drawdown
Benchmark Returns
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
This is a template pipeline for replacing DollarVolumeUniverse which will be removed
from the Quantopian API shortly.

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

from quantopian.pipeline.factors import AverageDollarVolume
from quantopian.pipeline.filters import Q1500US
def initialize(context):
    # Rebalance every day, 1 hour after market open.
    schedule_function(my_rebalance, date_rules.every_day(), time_rules.market_open())
    # Create our dynamic stock selector.
    attach_pipeline(make_pipeline(), 'my_pipeline')
def make_pipeline():
    Build a pipeline that gets the top 10% of stocks by average dollar volume, updated
    quarterly. Only considers stocks that are already in the Q1500US().
    adv = AverageDollarVolume(window_length=int(252 / 4))
    quarterly_adv = adv.percentile_between(90, 100, mask=Q1500US()).downsample('quarter_start')

    pipe = Pipeline(
    return pipe
def before_trading_start(context, data):
    Called every day before market open.
    context.pipeline_output = pipeline_output('my_pipeline')
    # These are the securities that are in the top dollar volume each day.
    context.universe = context.pipeline_output.index

def my_rebalance(context,data):
    Execute orders according to our schedule_function() timing. 
There was a runtime error.

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

3 responses

Can you update the Paris Trading example that uses the universe parameter? It's hard to learn these things when the examples are outdated.

Hi Jamie,

Ive been trying to get an answer on that but in vain so far: how do we convert DollarVolumeUniverse and set_universe to get the same universe with the new Pipeline? Basically, I think it all comes down to the window length of AverageDollarVolume(window_length=????????) but I wonder if there are other criterias embedded in DollarVolumeUniverse that would make the two functions pull different universes.

An answer on that would be very much appreciated.

thanks a lot in advance !

Hey everyone, DollarVolumeUniverse, set_unvierse, and update_universe have officially been removed from the API. As shown in the backtest attached to the original post, you can use the AverageDollarVolume(window_length=int(252 / 4)) pipeline factor to achieve the same functionality.

That said, you're probably better off using the QTradableStocksUS, our most recent pre-built universe of liquid stocks.