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/

    Get historical time data

    General Code/Help
    datetime pandas data
    2
    3
    979
    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.
    • J
      J. Javier Gálvez last edited by

      Hi, Backtraders!

      I want to get n bars back the current day as a pandas dataframe. Reading various topics in this forum I was able to do it for OHLCV data, but not for DateTime.

      I'm using self.data.datetime.get(size=self.n_bars, ago=0) but I got just an array of float numbers instead of an array of datetimes.
      I thought the float number could be transformed to datetime with datetime.fromtimestamp(timestamp) but the result was a very different time of what was supposed to be.

      So, I ask for help to know what that float number mean or more concretely how to get the last n bars of the datetime column.

      Thanks in advance.

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

        Because there are no datetime objects used inside the library.

        See here (just 2 days old): https://community.backtrader.com/topic/1151/datetime-format-internally/

        J 1 Reply Last reply Reply Quote 1
        • J
          J. Javier Gálvez @backtrader last edited by

          Thank you very much @backtrader. I didn't notice that thread. The solution works like a charm.

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