Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Clarification: timestamp on datafeed return unclear value

    General Code/Help
    2
    5
    910
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Jacob
      Jacob last edited by

      I'm trying to understand a certain value of datetime that I can't understand.

      step by step:

      1. loading a .csv file with custom GenericCSVData.
      2. datetime is in timestamp format, so 'params' will have 'dtformat' set to 1 (int timestamp format)
      3. 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-30

      my clarification question is just to understand what is the value '(self.datas[0].datetime)[0]' represents? (734957.9999999999)

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        @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-30

        Your 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.

        1 Reply Last reply Reply Quote 0
        • Jacob
          Jacob last edited by

          was just wondering if I could easily make sense of the date format.
          was expecting the unix style timestamp

          I'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

          B 1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators @Jacob last edited by

            @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. And datetime is one of the defined lines for an OHLC timeseries.

            You probably want to read this: Docs - Platform Concepts and specifically the section (and its subsections) Lines

            1 Reply Last reply Reply Quote 0
            • Jacob
              Jacob last edited by

              Thanks @backtrader for the explanation

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors