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
If you have any questions, or need help updating your code, please let us know.
|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( screen=quarterly_adv ) 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. """ pass