Hi,
I am simply trying to write the day of the week in my CoarseSelectionFilter():
def Initialize(self):
self.SetStartDate(1998, 1, 1)
self.SetEndDate(1998, 3, 1)
self.MinPriceForSelectionFilter = 10.0
self.NumAssets = 10
self.SetCash(100000)
self.AddUniverse(self.CoarseSelectionFilter)
# what resolution should the data *added* to the universe be?
self.UniverseSettings.Resolution = Resolution.Daily
def CoarseSelectionFilter(self, coarse):
self.Debug(self.Time.DayOfWeek)
But I get this error:
Runtime Error: AttributeError : 'datetime.datetime' object has no attribute 'DayOfWeek'
at CoarseSelectionFilter in main.py:line 24
It looks to me that Time is a .net dateTime object so I don't understand why I get this error?
ANy help is greatly appreciated.
Derek Melchin
Hi Jambo,
`self.Time` is a Python datetime object. To get the day of week value, we need to call
self.Time.weekday()
See the attached backtest for reference.
Best,
Derek Melchin
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.
Jambo dev
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!