Why is OnData in my Algorithm called minutely for a symbol, even though I set UniverseSettings.Resolution to Resolution.Daily?
Thanks,
Markus
QUANTCONNECT COMMUNITY
Why is OnData in my Algorithm called minutely for a symbol, even though I set UniverseSettings.Resolution to Resolution.Daily?
Thanks,
Markus
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.
Mia Alissi
The
OnData
method in your algorithm is the primary event handler for receiving financial data events. It is triggered sequentially at the point in time the data is available; in backtesting and live. For daily data, this means the event is processed at midnight in backtesting or 6am the following day in live trading (source).However, it's important to note that the
OnData
event handler will be called regularly even if there was no new data. This is the default behavior when fill-forward is enabled for your asset.In your case, you are subscribing to minute-level data for the "SPY" equity and its options. The
OnData
method should be called every minute when there is data for these assets. However, it seems like theOnData
method is being called at the start of each trading day (9:31 AM) and then not being called again until the next trading day. This could be due to the lack of data for the assets you are subscribing to.If you are using custom data or certain types of options data, it's possible that the data is not available at every minute. For example, if you are using US Index Options data, the
Slice
may not contain data for your Index Option at every time step (source).To debug this issue, you could log the data that is available in the
Slice
object in theOnData
method. This will help you understand what data is available at each time step. Here is an example of how to do this:This will log the data available at each time step, helping you understand why
OnData
is being called every minute.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.
Melanie Schiefele
Hi Mia,
Thanks for your quick response. Sorry my question was probably too short. My ideal situation would be that OnData is called once a day with only data from my selected Universe.
As mentioned above I have:
UniverseSettings.Resolution = Resolution.Daily
in my Initialize function. I am not explicitly subscribing to any other data. Does this mean I am implicitly subscribing to SPY with minute resolution? I am actually logging my OnData function and I see that I get minutely updates for my Universe even though I set the Universe resolution to Daily. This is what confuses me.
Thanks,
Markus
Mia Alissi
The
UniverseSettings.Resolution
setting determines the resolution of the data that is subscribed to for the securities selected by the Universe Selection model. If you setUniverseSettings.Resolution = Resolution.Daily
, it means that the data for the securities in your universe will be in daily resolution (source).However, it's important to note that the
OnData
method can still be called more frequently than the resolution of your data. This is becauseOnData
is called whenever new data is available, not just when new data for your universe is available. For example, if you have other data subscriptions (e.g., for indicators or other securities),OnData
will be called whenever new data for these subscriptions is available.If you want
OnData
to be called only when new data for your universe is available, you can check theSlice
object that is passed toOnData
to see if it contains new data for your universe. Here is an example of how to do this:In this example,
self.myUniverseSymbol
is the symbol for your universe. This code will return immediately fromOnData
if theSlice
does not contain new data for your universe.If you are still seeing
OnData
being called every minute, it could be due to other data subscriptions in your algorithm. You might want to review your algorithm to see if there are any other data subscriptions that could be causingOnData
to be called every minute.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.
Melanie Schiefele
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!