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/

    Are there any simple portfolio rebalancing strategies for reference?

    General Code/Help
    2
    2
    802
    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.
    • T
      tommark last edited by

      per title

      1 Reply Last reply Reply Quote 0
      • P
        Paska Houso last edited by Paska Houso

        Don't know but it should be fairly easy (a couple of free hours during the Christmas break ... )

        def next(self):
            rebalanced_datas = sorted(self.criteria.items(), lambda data, criterion: criterion)
        
            l = len(rebalanced_datas)
            upper = 90
            lower = 10
            # simple weight allocation
            percents = [(upper - x * (upper - lower) / (l - 1)) / 100.0 for x in range(l)]
        
            # normalize the percentages
            sperc = sum(percents)
            percents = [p / sperc for p in percents]
        
            for data, percent in zip(rebalanced_datas, percents):
                self.order_target_percent(data, target=percent)
        

        The sauce is obviously in the values of the self.criteria dictionary which will probably be custom indicators which decide what the most attractive asset is.

        1 Reply Last reply Reply Quote 1
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors