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/

    Dynamically extending the dataframe

    General Code/Help
    2
    2
    21
    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.
    • B
      btr last edited by

      Hello,

      I am currently extending the data feeds using PandasData feeds and have multiple data feeds going into cerebro.

      class PandasData(bt.feeds.PandasData):
          lines = ('abc','xyz')
          params = (
              ('abc', 'abc'),
              ('xyz','xyz'),    
          )
      
      for df in datas:
            data=PandasData(dataname=df)
            cerebro.adddata(data, name='example')
      

      and using these lines in init function as:

      for i, d in enumerate(self.datas):
             self.inds[d] = dict()
             self.inds[d]['abc'] = d.abc
             self.inds[d]['xyz'] = d.xyz
      

      Now, what if I don't know the name of extra columns 'abc' and 'xyz' that the pandas dataframe would have and would like to extend the dataframe for those data feeds dynamically.

      I saw this topic, what I don't understand here is that they already know these 'optix_close', 'optix_pess', 'optix_opt' column names. How is this programatically extending datafeed?

      Thanks in advance

      run-out 1 Reply Last reply Reply Quote 0
      • run-out
        run-out @btr last edited by

        @btr I just asked where your misunderstanding was in the other topic. Thanks for clarifying.

        In the other topic the OP knew the optix lines. In your case, you would simlply add in the column names of your dataframe.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
        $(document).ready(function () { app.coldLoad(); }); }