optstrategy trouble with Unix timestamps
-
My dataset's datetime-stamp is formatted in Unix float notation. I've divided the datetime-stamp by 1000 so it can be passed with GenericCSVData no problem in a normal
addstrategy
backtest with the parameterdtformat=2
. However, when trying to optimize withoptstrategy
, I get an error:AttributeError: Can't pickle local object 'GenericCSVData.start.<locals>.<lambda>'
I assume the
dtformat=2
parameter I've set is the lambda function so I've just manually converted the Unix datetime-stamps into the %Y-%m-%d %H:%M:%S format and removed thedtformat=2
parameter. However, I then get another error that my format is still incorrect:ValueError: time data '20/09/01 02:00:00' does not match format '%Y-%m-%d %H:%M:%S'
Is there something I'm missing here?
-
@adenosine
your date-time format is more%y/%m/%d %H:%M:%S
rather than%Y-%m-%d %H:%M:%S
. or%d/%m/%y %H:%M:%S
since it is not clear where the year is shown. -
@ab_trader I took another stab and tried making the year more clear and get the same error.
Is there a difference between %y and %Y?
-
@adenosine said in optstrategy trouble with Unix timestamps:
Is there a difference between %y and %Y?
Sure, there is a difference. google, what is python date time string format
Also you separate the numbers by
/
, but in the format description you use-
. This can affect it as well. -
@ab_trader You were right. It was the
-
that was throwing it off . Thank you.