Universe selection - Volume instead of DollarVolume

I would like one of my universe filters to be based on avg volume (shares) , not dollar volume. Is there any way to do this?  Thanks

Update Backtest

Yes! When using QuantConnects universe selection the data can be filtered by getting todays total volume using CourseFundamental.Volume. This is by using the coarse selection function, which passes CoarseFundamental objects for filtering. In the backtest below you can see an example on how the coarse selection is used:

It seems the original questions is related to average volume over a given time. I am also having issues with this. The code below always returns 0.0 for average volume and I do not know why. Any help is appreciated.

AddEquity("SPA", Resolution.Daily);
var avgVolume14Days = SMA("SPA", 14, Resolution.Daily, x => ((TradeBar)x).Volume);
Console.Write("avgVolume14Days: " + avgVolume14Days);
// Console displays
avgVolume14Days: 0.0

When trying to implement the code above I was receiving the correct output. If the SMA value was outputted right after its initialization, then the value will be 0 since indicators are not ready when you first create them. The indicators will be ready based upon their period and their status can be checked via indicator.IsReady. Once the data is fed into the SMA, the correct values exist. The algorithm below is how the SMA should be implemented:


Thanks for the reply. It appears that since the data for SMA is only accessible after the OnData function has fired, you wouldn't be able to use that information in a Universe creation filter. Correct?

What I ended up doing was creating a getAvgVol function:

// Symbol and Volume from Universe coarse filter
private decimal getAvgVol(Symbol sym, decimal volume) { // Symb
decimal totalVolume = 0;
var hist = History(sym, TimeSpan.FromDays(14), Resolution.Daily).ToList();
foreach(var tb in hist) {
totalVolume += tb.Volume;
return totalVolume > 0 ? volume/totalVolume : 0;

Update Backtest


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.


This discussion is closed