csv with custom columns



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


  • administrators

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



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


  • administrators

    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.


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.