Clarification: timestamp on datafeed return unclear value
-
I'm trying to understand a certain value of datetime that I can't understand.
step by step:
- loading a .csv file with custom GenericCSVData.
- datetime is in timestamp format, so 'params' will have 'dtformat' set to 1 (int timestamp format)
- adding a simple strategy that on 'next' will try to print the timestamp value
the timestamp I used in the data: 1364636880 (which correlate to '30 March 2013 09:48:00')
if I do 'print((self.datas[0].datetime)[0])' I get: 734957.9999999999
and if I do ''print(self.datas[0].datetime.date(0))' I get: 2013-03-30my clarification question is just to understand what is the value '(self.datas[0].datetime)[0]' represents? (734957.9999999999)
-
@jacob said in Clarification: timestamp on datafeed return unclear value:
the timestamp I used in the data: 1364636880 (which correlate to '30 March 2013 09:48:00')
if I do 'print((self.datas[0].datetime)[0])' I get: 734957.9999999999
and if I do ''print(self.datas[0].datetime.date(0))' I get: 2013-03-30Your input date is the 30th of March of 2013 and the output is in isoformat 2013-03-30.
Were you expecting anything else?
@jacob said in Clarification: timestamp on datafeed return unclear value:
my clarification question is just to understand what is the value '(self.datas[0].datetime)[0]' represents? (734957.9999999999)
It's the timestamp coded inside a
float
. -
was just wondering if I could easily make sense of the date format.
was expecting the unix style timestampI'm focusing now on learning the library and although a lot of things are very intuitive.
some things I can't see while debugging which leave a gap in my understanding.I will give an example of what i mean:
if while debugging I 'watch' self.datas[0] I don't see in the object hierarchy having '.datetime' yet alone find it also have .date() function.this leave me with a concern that i will not be able to fully use the system cause i can't see everything.
(found the above code in the docs but i doubt i could have found it myself)I switched now to use pycharm (instead of VS) but still can't see attributes like '.datetime'
but it did help me find the num2date() function that convert the float number to a normal date -
@jacob said in Clarification: timestamp on datafeed return unclear value:
was expecting the unix style timestamp
From Wikipedia - Unix time:
Unix time (also known as POSIX time[citation needed] or UNIX Epoch time[1]) is a system for describing a point in time, defined as the number of seconds
It would be difficult to express anything in the sub-second realm with the Unix timestamp.
@jacob said in Clarification: timestamp on datafeed return unclear value:
if while debugging I 'watch' self.datas[0] I don't see in the object hierarchy having '.datetime' yet alone find it also have .date() function.
I believe in this case the trees don't let you see the forest. If something is not found in a lines object itself, it will be sought in the defined
lines
. Anddatetime
is one of the defined lines for anOHLC
timeseries.You probably want to read this: Docs - Platform Concepts and specifically the section (and its subsections)
Lines
-
Thanks @backtrader for the explanation