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/

    data class autoregister

    General Discussion
    2
    2
    612
    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.
    • tonny
      tonny last edited by

      hi
      I dont understand how DataCls is autoregistered in backtrader.stores.IBStore.
      The code in backtrader.stores.ibstore:

      class IBStore(with_metaclass(metasingleton,object)):
          #######
          DataCls = None # DataCls will autoregister?
          @classmethed
          def getdata(##):
              return cls.DataCls(###)
      

      When I create a Singleton of class IBStore by

      store = backtrader.stores.IBStore(####)
      

      and then I can get a ibdata instance by calling the store's method as your doc explained:

      data = store.getdata(####)
      

      so how it is done?

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

        Because the data feed IBData registers itself in the store overwriting DataCls. This would allow anyone to write a different version of IBData (call it MyIBData), which would again overwrite the value of DataCls in the store.

        And consequently, getdata would return an instance of MyIBData

        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(); }); }