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/

    Issue with dates on plot

    General Code/Help
    1
    1
    56
    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.
    • Olly Fallon
      Olly Fallon last edited by

      I am not sure if my dates are working correctly.

      cerebro.plot(
                      start=datetime.date(2022, 2, 3),
                      end=datetime.date(2022, 2, 4),
                      )
      

      results in an error:

      TypeError: descriptor 'date' for 'datetime.datetime' objects doesn't apply to a 'int' object
      

      Everything else does seem to work though if I resample my 1 minute feed using the inbuilt resampler, for eample to 5 minutes, I do get 5 minute data but with incorrect values. However, if I resample the dataframe prior to loading it into cerebro then it comes up correct. So I am concerned that somehow my dates formats are somehow incorrect.

      Dataframe looks like this:

      2022-02-04 15:56:00  38.9450  39.0800  38.9400  38.9950   914305.0
      2022-02-04 15:57:00  38.9950  39.0000  38.9400  38.9450   985518.0
      2022-02-04 15:58:00  38.9500  39.2500  38.9400  39.1800  1490947.0
      2022-02-04 15:59:00  39.1850  39.1900  38.9000  38.9066  1257336.0
      
      

      Can anyone advise on the error and what I could check?

      Many thanks

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