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/

    Date Format Error

    General Code/Help
    2
    2
    849
    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
      asuralm last edited by

      The problem looks strange to me. When I load a GenericCSVData, I got this error:
      0_1492051320133_upload-8f621b76-d419-483b-aad8-eb3053887fe3

      I use the same data file as another datafeed, it gives me this, neither works:
      0_1492051412184_upload-fb81cdc4-09ce-4f16-b7e8-c93edfcb44fc

      As you can see, the two data file, one is AG.CSV, and one is AG_1.CSV, they are exactly the same, but the parsed date format in the first case is separated by '/', and the second is separated by '-'. However, neither of them works properly.

      The code looks the following:

      data_AG = bt.feeds.GenericCSVData(dataname='AG_1.csv', dtformat='%y-%m-%d', datetime=0, open=1, high=2, low=3, close=4, volume=7, openinterest=8)
      
      cerebro.adddata(data_AG)
      

      How to deal with this problem please?

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

        %m is for months with 2-digits. See: [Python Docs - Basic date and time types](file:///D:/dro/99-misc/docs/devel/python-2.7.10-docs-html/library/datetime.html#module-datetime). Section: 8.1.7. strftime() and strptime() Behavior

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