Q Tribe, I'm a bit confused here (not a surprise). I can stop the below code in the debugger and get things to respond with the correct values. But when I try and run it in a backtest and I get this error:
Runtime exception: AttributeError: 'NoneType' object has no attribute 'year'
(enter whatever you're trying to pull off of the start_date)
Each of these fail
def initialize(context):
startDate = context.portfolio.start_date.date() # fails
startDate = context.portfolio.start_date
startDate = datetime.datetime(startDate.year, startDate.month, startDate.day) # fails
Yet if I stop and interrogate the various incantations of startDate:
MySecurityList[0]["Date"]
date: datetime.date(2006, 10, 31)
startDate
Timestamp: 2006-10-31 00:00:00+00:00
MySecurityList[0]["Date"] == startDate
False
MySecurityList[0]["Date"] == startDate.date()
True
Where MySecurityList looks like this:
MySecurityList = [
{"Date":datetime.date(2006,10,31), "Stuff here": ...
Any ideas, clues or whiskey to offer?