Loading the fine universe faster for US equities

Back

Hi, 

I have a question if it is posisble to speed up loading the universe at the start of the back-test of an algorithm. I leverage the coarse and fine filters (see example below) to load the universe at a given reset day (e.g., weekly, monthly). Loading the universe for the first time takes quite some time ranking them by market cap first and then filtering on additional criteria. 

Is there a way to improve the query speed and load the fine filtered universe quicker?


def SelectCoarse(self, algorithm, coarse):
# update universe once a week, month, etc.
if not self.is_reset:
return Universe.Unchanged

else:
universe_coarse = [x for x in coarse if x.HasFundamentalData]
return symbols_coarse

def SelectFine(self, algorithm, fine):
# update universe once a week, month, etc. th
if self.is_reset:
return Universe.Unchanged

else:
# filter by market cap and limit the number of securities (e.g., 200 stocks)
universe_mkt_cap_sorted = sorted(fine, key=lambda k: k.CompanyProfile.MarketCap, reverse=True)[ :self.universe_limit]

# sample of filters used to reduce the universe further
universe_fine = [x for x in universe_mkt_cap_sorted
and (not x.CompanyReference.IsREIT)
and (not x.SecurityReference.IsDepositaryReceipt)
and (x.CompanyProfile.MarketCap > 0)
and x.ValuationRatios.PBRatio > 0
]
symbols_list = [x.Symbol for x in universe_fine]
return symbols_list
Update Backtest







 
0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Goofball,

To speed up the fine universe selection, we can filter down the universe to a smaller set in the coarse selection method. Since the algorithm is filtering down by market cap during fine universe selection, try filtering down by dollar volume in coarse selection since securities with higher market cap usually have higher dollar volume.

Best,
Derek Melchin

0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!