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/

    Optstrategy, preload and runonce relation

    General Code/Help
    1
    1
    105
    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.
    • M
      momentum last edited by momentum

      Hi,

      I wonder why when runonce is False, then the data are not preloaded in optimization. I also wonder what happens when someone is using _nextforce = True instead. It seems to me that preloading will take place as the indicators that will call _disable_runonce are added afterwards.

      Thanks

              iterstrats = itertools.product(*self.strats)
              if not self._dooptimize or self.p.maxcpus == 1:
                  # If no optimmization is wished ... or 1 core is to be used
                  # let's skip process "spawning"
                  for iterstrat in iterstrats:
                      runstrat = self.runstrategies(iterstrat)
                      self.runstrats.append(runstrat)
                      if self._dooptimize:
                          for cb in self.optcbs:
                              cb(runstrat)  # callback receives finished strategy
              else:
                  if self.p.optdatas and self._dopreload and self._dorunonce:
                      for data in self.datas:
                          data.reset()
                          if self._exactbars < 1:  # datas can be full length
                              data.extend(size=self.params.lookahead)
                          data._start()
                          if self._dopreload:
                              data.preload()
      
                  pool = multiprocessing.Pool(self.p.maxcpus or None)
                  for r in pool.imap(self, iterstrats):
                      self.runstrats.append(r)
                      for cb in self.optcbs:
                          cb(r)  # callback receives finished strategy
      
                  pool.close()
      
      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(); }); }