Backtrader Community

    • 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/

    Error loading daily data when using todate

    General Code/Help
    2
    5
    1187
    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.
    • T
      Trade Prophet last edited by

      Hello,
      I'm trying to load daily data from .csv files, but
      bt does not load any data from .csv file when using 'todate' parameter.
      Using this command :

                 data = bt.feeds.GenericCSVData(dataname=dataname, seperatotr=',',
                                                         dtformat='%Y-%m-%d',
                                                         datetime=0,
                                                         open=1,
                                                         high=2,
                                                         low=3,
                                                         close=4,
                                                         volume=5,
                                                         openinterest=-1,
                                                         adjclose=-1,
                                                         reverse=True,
                                                         timeframe=bt.TimeFrame.Days,
                                                         compression=1,
                                                         fromdate=datetime.datetime(2015, 1, 1),
                                                         todate=datetime.datetime(2016, 1, 1)
                                                         )
      

      on this data :

      Date,Open,High,Low,Close,Volume
      ...
      2016-01-05,201.40,201.90,200.05,201.36,110845848
      2016-01-04,200.49,201.03,198.59,201.02,222353536
      2015-12-31,205.13,205.89,203.87,203.87,114877856
      2015-12-30,207.11,207.21,205.76,205.93,63317680
      2015-12-29,206.51,207.79,206.47,207.40,92640672
      2015-12-28,204.86,205.26,203.94,205.21,65899940
      ...
      removing the 'todate' parameter and bt is OK, but with the parameter bt loads no values for any .csv file
      any idea how to fix this ?
      Thank you

      A 1 Reply Last reply Reply Quote 1
      • A
        ab_trader @Trade Prophet last edited by

        @trade-prophet probably it happens cause your data is reversed in the .csv. but it is just a guess.

        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        1 Reply Last reply Reply Quote 0
        • T
          Trade Prophet last edited by Trade Prophet

          You are absolutely right, I see my mistake, GenericCSVData does not support reverse parameter.
          Is there a way to reverse data in CSV file?

          A 1 Reply Last reply Reply Quote 0
          • A
            ab_trader @Trade Prophet last edited by ab_trader

            @trade-prophet it is a lot of different ways depending on your needs and situation. Couple examples: read into Excel, sort as required, save as .csv. Using pandas read as data frame, sort as required, save as .csv. Open in the text editor, copy - paste in necessary order, save.

            • If my answer helped, hit reputation up arrow at lower right corner of the post.
            • Python Debugging With Pdb
            • New to python and bt - check this out
            1 Reply Last reply Reply Quote 0
            • T
              Trade Prophet last edited by

              OK,
              thank you

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