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/

    optimization with percentrank

    Indicators/Strategies/Analyzers
    2
    3
    177
    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.
    • L
      lampalork last edited by

      Dear Backtrader community,
      I have implemented a strategy that uses the indicator bt.indicators.PercentRank(). When running optimization on this strategy, I get the following error message? Any idea/suggestions on how to go around this issue?

      Thanks and regards,
      Lamp'

      multiprocessing.pool.MaybeEncodingError: Error sending result: '[<strategies.XXXStrategy object at 0x000002D1A61754A8>]'. Reason: 'PicklingError("Can't pickle <function PercentRank.<lambda> at 0x000002D1A716A510>: attribute lookup PercentRank.<lambda> on backtrader.indicators.percentrank failed")'
      
      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        Pickling fails sometimes depending on the ordering of things in a module (there is a long list of things why pickling can fail).

        It seems the default lambda definition is not compatible with pickling. Define another func as the parameter to PercentRank and it may work.

        This is the default definition: lambda d: fsum(x < d[-1] for x in d) / len(d))

        1 Reply Last reply Reply Quote 0
        • L
          lampalork last edited by

          Hi, this is what I have done and indeed it works. Mysteries of pickle! thanks a lot

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