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/

    csv with custom columns

    General Code/Help
    2
    4
    1846
    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.
    • G
      Gil Keren last edited by

      Hello,

      I have a csv with additional custom columns, other than the usual open, low, high, close, volume, openinterest. I would like to load this csv as a data feed, such that I have the additional columns as additional lines that I can use in the 'next()' function.

      Is there a way to do that? I failed to do so using the 'GenericCSVData' class.

      Thanks!

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

        All elements are extensible. See here for GenericCSVData: Docs - Extending a Datafeed

        1 Reply Last reply Reply Quote 0
        • G
          Gil Keren last edited by

          Thanks!

          I tend to change my csv format quite often, so is there a way to automatically detect all the extra columns in the csv and add them as lines?
          Accessing 'self.lines' in the derived class' init method does not seem to be the way to do it.

          Thanks!

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

            The data feed is not artificial intelligence, it cannot know if you want to use the columns and which columns will be used for which purpose.

            Furthermore, the csv may have no headers and therefore there would be no name available.

            For each format you can have your custom class. That's the beauty of oop and subclassing, once done it will be there for you to be used.

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