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/

    GenericCSVData loading: alternative way to load partial data?

    General Code/Help
    2
    3
    1060
    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.
    • Андрей Музыкин
      Андрей Музыкин last edited by Андрей Музыкин

      HEllo!
      My CSV data files are ~300K points length, e.g. full-year 1 minute bar EURUSD pair.
      For multiply backtest runs of a single strategy I need to randomly draw 2-4 days long ( ~3000 - 6000 points) sub-series from these files.
      One method to do it is use documented <fromdate> - <todate> method which gives only about 360 random entry points.
      Is there a method to define arbitrary start/stop datafeed points by array-like indexing?

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

        fromdate and todate can be actual datetime.datetime instances, which allows you to have a fine grained resolution down to microseconds to select where the actual management of the stream starts and stops. This should allow you to select the exact points you want to test. It may be slow in any case.

        @Андрей-Музыкин said in GenericCSVData loading: alternative way to load partial data?:

        Is there a method to define arbitrary start/stop datafeed points by array-like indexing?

        No. This is something that people look for because they are expecting a pandas like approach. That would actually prevent having data sources with unknown length (and therefore live data feeds). And that's why the indexing of 0 and -1 was chosen as it was chosen (See Docs - Platform Concepts)

        If you are purely backtesting you can do the following:

        • Load your data into a pandas.Dataframe
        • Use pandas indexing and slicing techniques to reduce the dataset to your desired values
        • Load the data stream into backtrader using PandasData
        Андрей Музыкин 1 Reply Last reply Reply Quote 0
        • Андрей Музыкин
          Андрей Музыкин @backtrader last edited by

          @backtrader - got it, 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