Question 1: How to filter stocks by Float (shares available for trading)?
I want to filter for low float stocks (max 10 million shares). What's the correct way to access float data in FineSelectionFunction? Is it SharesOutstanding or is there a specific Float field?
def FineSelectionFunction(self, fine):
fine = list(fine)
filtered = []
for x in fine:
# How to get Float? Is this correct?
shares = x.CompanyProfile.SharesOutstanding
if shares and shares > 0 and shares <= 10000000:
filtered.append(x)
return [x.Symbol for x in filtered]
Question 2: Why is my algorithm not executing any trades?
My algorithm runs without errors but executes 0 trades. I'm using:
• CoarseSelectionFunction (price $0.5-$15, volume > 20000)
• FineSelectionFunction (market cap $5M-$100M)
• Scheduled scans at 9:45, 10:30, 12:00, 14:00
The scan runs but stock_data dictionary seems empty. What am I missing?
def OnSecuritiesChanged(self, changes):
for security in changes.AddedSecurities:
symbol = security.Symbol
if symbol not in self.stock_data:
self.stock_data[symbol] = {
'prices': RollingWindow[TradeBar](20),
'added_date': self.Time
}
def OnData(self, data):
for symbol in self.stock_data:
if data.Bars.ContainsKey(symbol):
self.stock_data[symbol]['prices'].Add(data.Bars[symbol])
Question 3: How to properly use Universe Selection with Daily resolution?
I set self.UniverseSettings.Resolution = Resolution.Daily but my RollingWindow never fills up. Do I need to request history manually? How do I warm up data for universe stocks?
self.UniverseSettings.Resolution = Resolution.Daily
self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction)
self.SetWarmUp(timedelta(days=20))
Question 4: What fundamental data is available for small cap stocks ($5M-$100M market cap)?
I'm targeting micro-cap stocks but many seem to have missing data. Which fields are reliably available?
• MarketCap
• SharesOutstanding
• Float
• Volume
Question 5: How to debug why no stocks pass my filters?
How can I log how many stocks pass each filter stage? My Debug statements don't appear in backtest logs.
def CoarseSelectionFunction(self, coarse):
filtered = [x for x in coarse if
x.HasFundamentalData and
self.min_price <= x.Price <= self.max_price and
x.Volume >= 20000]
self.Debug(f"Coarse: {len(filtered)} passed") # This doesn't show in logs
return [x.Symbol for x in filtered[:300]]
Alexandre Catarino
Hi mutlaq,
Taking your five questions in order:
1) Filtering by float
The Morningstar dataset on QuantConnect doesn't carry a free-float field — shares_outstanding (on f.company_profile) is total shares outstanding, not tradeable float. The closest available fields are:
Since float ≤ shares outstanding, filtering shares_outstanding < 10_000_000 is a conservative float filter: everything that passes genuinely has a float under 10M, but you'll also drop stocks whose float is under 10M while total shares are above it. For a low-float strategy that's usually an acceptable trade-off.
2) Zero trades / empty stock_data
The usual suspects, in order of likelihood:
3) RollingWindow never fills at daily resolution
set_warm_up only pumps data through securities that are already subscribed when the algorithm starts — universe-selected symbols join later and get no warm-up at all, so their windows sit empty until 20 live trading days have passed. The fix is to seed the window with a history request when the security enters the universe:
With that in place you don't need set_warm_up for the universe at all.
4) Reliable fields for micro caps
Most reliable, because they come from the price file rather than financial statements: f.price, f.volume, f.dollar_volume, f.market_cap. Next tier: f.company_profile.shares_outstanding and market_cap from the company profile. There is no float field (see #1). Deep financial-statement and ratio fields get increasingly spotty as market cap shrinks — always guard against None/zero before comparing. Also note that requiring has_fundamental_data is what defines coverage: companies Morningstar doesn't cover (a lot of the $5M–$50M space, especially OTC) never reach your fine selection.
5) Counting stocks at each filter stage
Log one summary line per selection pass, with the time included:
Three reasons your Debug() calls vanish:
One line per day from universe selection survives all three.
Best regards,
Alex
Mutlaq
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.
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!