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/

    Transformation from datetime(float) to datetime type?

    General Discussion
    2
    2
    187
    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.
    • A
      Alicc last edited by

      hi all,

      Seems the datetime in OrderData is of float type. Just want to know how to change float type to regular datetime type, Thanks~

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

        Backtrader uses the floating point datetime representation internally, both for line series (data feeds, indicators and so on) and orders.

        This is similar to the way the datetime is used in matplotlib. See https://matplotlib.org/_modules/matplotlib/dates.html for more info.

        The float based datetime could be easily converted to python datetime by using num2date() function (see dateintern.py module). Alternatively for data feeds, one may use the data.num2date() to directly get the python datetime for current data feed bar.

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