Backtrader Community

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

    Calculate expected optimization memory usage

    General Discussion
    1
    1
    272
    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.
    • C
      CooleRnax last edited by CooleRnax

      Hello.

      I'm having troubles with calculating the expected optimization memory usage.
      I need it to split big parameters dict during optimization into chunks if memory usage is too high.

      I came up with this function.
      But it doesn't work always.
      Please help!

      inputs:
      params - dict | with strategy parameters for the optimization
      start, end - datetime | start and end of the ticker data
      freq - str | ticker data freq (15Min, 1H, etc)

      def memory_gen(params, start, end, freq, threads=8, log=False):
          period_len = len(pd.PeriodIndex(freq=freq, start=start, end=end))
          params_len = 1
          for param in params:
              if type(params[param]) == list:
                  if not params_len == 1:
                      params_len *= len(params[param])
                  elif params_len == 1 and len(params[param]) > 1:
                      params_len = len(params[param])
      
              n = 20.0
      
          memory = round((period_len * params_len) * n / 1000000 + 0.200 * threads, 2)
          if log:
              logger.info(freq, memory)
          return memory
      
      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors