Well I was using OnEndofDay(self) in an algorithm, just to get the open, high, low, close. Like this
def OnEndOfDay(self)->None:
self.previous_close = self.Securities[self.symbol.Value].Close
self.previous_vol = self.Securities[self.symbol.Value].Volume
self.previous_high = self.Securities[self.symbol.Value].High
self.previous_low = self.Securities[self.symbol.Value].Low
self.previous_open = self.Securities[self.symbol.Value].Open
Then I saw this warning message
‘def OnEndOfDay(self, symbol: str) -> None
def OnEndOfDay(self, symbol: typing.Union[QuantConnect.Symbol, str]) -> None
def OnEndOfDay(self) -> None
End of a trading day event handler. This method is called at the end of the algorithm day (or multiple times if trading multiple assets).
This method is deprecated and will be removed after August 2021. Please use this overload: OnEndOfDay(Symbol symbol)
Full name: QuantConnect.Algorithm.QCAlgorithm.OnEndOfDay’.
So I'm wanting to learn how to use the new method. Does one have to setup a loop somewhere in the program to loop through all the securities and send them to ‘def OnEndOfDay(self, symbol: str) -> None’ Kind of makes it seem more like just a standard scheduled event? Like how am I suppose to know when to call this without scheduling it?
Newoptionz
And also why does it say ‘Please use this overload: OnEndOfDay(Symbol symbol)’ should this not be Please use this overload: OnEndOfDay(self, symbol): ?
Newoptionz
When I run the algo still using OnEndofDay(self), I get the following waring, ‘
Usage of QCAlgorithm.OnEndOfDay() without a symbol will be deprecated August 2021. Always use a symbol when overriding this method: OnEndOfDay(symbol)’ - luckily it still works in 2022?
Louis Szeto
Hi Newoptionz
It is obsoleted but still usable for backward compatibility. We do not recommend using it since different assets have different “end of day” time. It would be better to use a scheduled event for your purpose.
LEAN engine was primarily written in C#, while compatible with Python by PythonNet, so the warning message is a C# implementation.
Best
Louis
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.
Newoptionz
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!