Universe Selection Issue - Expert Bot Consultation
Current Problem:
I have a news monitoring strategy in QuantConnect targeting 900 stocks, but ObjectStore is only loading 152 stocks instead of 900. The system runs without errors but the count is significantly lower than required.
Current Stock Retrieval Method:
Python
def coarse_selection(self, coarse): # Skip work unless refresh is required if not self.refresh_flag and self.universe_symbols: return self.universe_symbols # Convert to list first coarse_list = list(coarse) # Basic filtering liquid = [c for c in coarse_list if c.has_fundamental_data and self.MIN_PRICE <= c.price <= self.MAX_PRICE and c.dollar_volume > 10_000] # Sort by liquidity liquid.sort(key=lambda c: c.dollar_volume, reverse=True) # Send top 10,000 to next stage (11x final target to expand scope) selected = [c.symbol for c in liquid[:10000]] self.log(f"[CoarseSelection] Filtered {len(selected)} from {len(coarse_list)} symbols") return selected
Current Filtering Method:
Python
def fine_selection(self, fine): if not self.refresh_flag and self.universe_symbols: return self.universe_symbols filtered = [] for f in fine: try: # Get fundamental data shares = f.earning_reports.basic_average_shares.three_months mcap = f.market_cap # Apply criteria if (shares and shares <= self.MAX_SHARES_OUTSTANDING and self.MIN_MARKET_CAP <= mcap <= self.MAX_MARKET_CAP): filtered.append((f.symbol, shares)) except Exception: continue # Sort by share count (lowest first - low float) filtered.sort(key=lambda x: x[1]) # Take best stocks symbols_data = filtered[:self.UNIVERSE_SIZE] # Top 900 symbols = [item[0] for item in symbols_data] # Update cache self.universe_symbols = symbols self.universe_tickers = set([s.value for s in symbols]) # Save shares outstanding data self._shares_outstanding.clear() for symbol, shares in symbols_data: self._shares_outstanding[symbol] = shares # Save to ObjectStore self.save_universe_to_store(symbols_data) self.refresh_flag = False self.log(f"[FineSelection] Selected {len(symbols)} final symbols") return symbols
Current ObjectStore Save Method:
Python
def save_universe_to_store(self, symbols_data): """Save universe to ObjectStore with shares outstanding data""" try: tickers = [s[0].value for s in symbols_data] shares_data = {s[0].value: s[1] for s in symbols_data} data = { 'tickers': tickers, 'shares_outstanding': shares_data, 'last_update': self.time.strftime("%Y-%m-%d %H:%M:%S"), 'count': len(tickers) } self.object_store.save(self.STORE_KEY, json.dumps(data)) self.log(f"[ObjectStore] Saved {len(tickers)} symbols to cache") except Exception as e: self.error(f"[ObjectStore] Save failed: {e}")
Current Selection Criteria:
•Stock Price Range: $1 - $50
•Maximum Shares Outstanding: 30 million shares (Low Float)
•Market Cap Range: $5M - $100M
•Daily Dollar Volume: > $10K
•Final Target: 900 stocks
Current Configuration:
Python
self.UNIVERSE_SIZE = 900 self.MIN_PRICE = 1.0 self.MAX_PRICE = 50.0 self.MAX_SHARES_OUTSTANDING = 30_000_000 # 30M shares (Low Float) self.MIN_MARKET_CAP = 5_000_000 # $5M (Micro-cap) self.MAX_MARKET_CAP = 100_000_000 # $100M (Small-cap)
Scheduling Setup:
Python
# Weekly refresh every Monday self.schedule.on( self.date_rules.every(DayOfWeek.MONDAY), self.time_rules.before_market_open("SPY", 30), self.flag_universe_refresh ) def flag_universe_refresh(self): """Enable weekly refresh flag""" self.refresh_flag = True self.log("[Schedule] Universe refresh flagged for next selection")
Key Questions:
1. Why only 152 stocks instead of 900?
Is the issue with filtering criteria or data availability? The system shows:
Plain Text
[ObjectStore] Loaded 152 symbols from cache [ObjectStore] Last update: 2025-10-05 17:05:50
2. How to optimize selection criteria to reach 900 stocks while maintaining quality?
3. Should filtering ranges be adjusted? Such as:
•Increase market cap range?
•Lower minimum liquidity threshold?
•Adjust price range?
•Increase shares outstanding limit?
4. Is there an issue with refresh_flag logic preventing weekly updates?
The system loads from cache instead of performing new filtering.
5. What's the best fallback mechanism if 900 stocks meeting criteria aren't available?
6. How to ensure proper weekly refresh when refresh_flag = True?
Additional Context:
•Last Update: 2025-10-05 17:05:50
•Current Behavior: System loads from cache instead of fresh filtering
•Update Schedule: Every Monday 30 minutes before market open
•Target Use Case: News monitoring for low-float, small-cap stocks
•Expected Volatility: High (suitable for news-driven trading)
Specific Requests:
1.Diagnostic suggestions to identify why only 152 stocks are selected
2.Optimized filtering criteria to reach 900 stocks target
3.Improved refresh mechanism to ensure weekly updates work properly
4.Fallback strategies if target count isn't achievable with current criteria
5.Best practices for low-float stock selection in QuantConnect
Expected Outcome
A reliable system that consistently selects ~900 high-quality, news-sensitive stocks with proper weekly refreshes and robust ObjectStore management.
Note: This is for a news monitoring algorithm that sends Telegram alerts when relevant news breaks for selected stocks. The focus is on stocks that react strongly to news due to low float and small market cap.
Mia Alissi
Here’s diagnostic code you can adapt to your algorithm to precisely identify why your universe selection only returns ~152 instead of 900, and where your filter is most restrictive. This will help answer "Why only 152 stocks", and will inform how to adjust your criteria and fallback strategies:
How this helps you:
Next Steps To Diagnose & Fix:
MAX_SHARES_OUTSTANDING = 40_000_000), rerun, and compare logs—a jump in counts will show it’s a constraint.Fallback mechanism example (if fewer than 900 found):
Best Practices for News-Sensitive, Low-Float Stock Selection
Summary:
Use explicit diagnostic logging + stats to see exactly why so few stocks pass and tune your logic. Always check constraint-by-constraint exclusion, and implement fallback logic for low-population periods. This will make your ObjectStore and weekly refreshes robust and transparent.
Let me know if you want ready-to-merge code with fallback/relaxation logic as well!
Sources: Coarse Fundamental Top3 Algorithm, Coarse Fine Fundamental Combo Algorithm, Fundamental Universes - QuantConnect.com, Key Concepts - QuantConnect.com, Universe Selection Definitions Algorithm
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.
مطلق الشمري
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!