Question for Mia: Empty Fundamental History in Live Mode
"Hello Mia! I'm getting empty data when trying to load universe immediately in Live Mode. Need your help!"
The Problem
My code returns 0 stocks when trying to bootstrap universe in initialize():
Python
def initialize(self): self.spy_symbol = self.add_equity("SPY", Resolution.MINUTE).symbol # Try to load stocks immediately self.log("[Initialize] تحميل الأسهم فوراً...") reference_time = self.time - timedelta(days=1) initial_symbols = self._get_top_dollar_volume_symbols(reference_time) self.log(f"[Initialize] تم تحميل {len(initial_symbols)} سهم") # Shows: 0 stocks! def _get_top_dollar_volume_symbols(self, reference_time): fundamental_history = self.history( Fundamental, reference_time, reference_time, Resolution.DAILY ) fundamental_list = [] if not fundamental_history.empty: # This is EMPTY! # ... filtering logic return [f.symbol for f in top]
Log Output
Plain Text
[Initialize] تحميل الأسهم فوراً... [Initialize] تم تحميل 0 سهم [OnSecuritiesChanged] إجمالي الأسهم النشطة: 1 (only SPY)
Questions
1.Why is fundamental_history empty?
•Is reference_time = self.time - timedelta(days=1) correct?
•Does self.time work correctly in initialize() in Live Mode?
•Should I use a different reference time?
2.Does self.history(Fundamental, ...) work in Live Mode?
•Is Fundamental data available in Live Mode?
•Do I need a subscription or special permissions?
•Is there a different API for Live Mode?
3.Alternative approach for Live Mode?
•Should I use self.coarse_universe_history() instead?
•Should I use a fixed list of symbols (like SP500)?
•What's the recommended way to bootstrap universe in Live Mode?
4.How to debug this?
•How can I check if fundamental_history has data?
•How can I see what reference_time value is?
•Any logging I should add?
My Environment
•Platform: QuantConnect Cloud
•Mode: Live Trading (Paper)
•Goal: Load 900 stocks immediately when algorithm starts
•Current Result: 0 stocks loaded
What I Need
Please provide:
1.Explanation of why data is empty
2.Correct code to load stocks in Live Mode initialize()
3.Alternative approach if Fundamental history doesn't work in Live Mode
4.Best practice for immediate universe loading in Live Mode
Thank you! 🙏
Mia Alissi
Here is a clear explanation and solution for your issue, 'مطلق':
1. Why is
fundamental_historyempty in Live Mode?initialize()runs, no fundamental files are available yet. QuantConnect downloads and processes fundamental data only after you add a symbol or universe and the first data event actually happens.self.timeininitialize(): At this point,self.timeis basically just the “deployment time” of your algorithm—not a market day, not a real-time data moment. There is no lookback data loaded.reference_time = self.time - timedelta(days=1)is not going to return valid market data duringinitialize(), because the data pipeline isn’t loaded yet!Result:
When you call
self.history(...)ininitialize()for Fundamentals (or even price data), it will return an empty DataFrame because no data has been loaded at all.2. Does
self.history(Fundamental, ...)work in Live Mode?initialize()for universe-wide fundamentals.3. Recommended approach for immediate universe loading in Live Mode
add_universe()with a coarse or fine selector. The fine selector receivesFineFundamentalobjects with all fundamental fields, and is only called when the data is ready (typically after 7am ET in Live mode).self.schedule.on()) to call history—by then, data is always loaded.4. How to debug and log availability?
self.time, and fundamental fields on a sample symbol in yourfineselector—if it prints, universe data has arrived.on_securities_changed: Log each new security added/removed; you can then request price/fundamental history for those symbols (it will work now).self.schedule.on()to request history after a delay (ex: 10 minutes after market open) and print length of result.Sample Best-Practice Code Pattern
Summary Table
When Is Fundamental Data Ready? What to Do Duringinitialize()in Live Mode ❌ No Don’t request! In fine selector / after universe builds ✅ Yes Use them! Inon_securities_changed✅ Yes Request history/log After scheduled callback ✅ Yes Safe to check dataBottom Line:
In Live Mode, you must wait until after universe selection before asking for fundamental data or history. Use logging in your universe selectors and
on_securities_changedto verify when data is ready.If you need further clarification or code snippets, let me know!
Sources: Fundamental Regression Algorithm, Fundamental Universes - QuantConnect.com, US Fundamental Data - QuantConnect.com, Corporate Fundamentals - QuantConnect.com, US Equity Coarse Universe - QuantConnect.com
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!