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/

    Fund UCITS constraints: 5/10/40 rule

    General Discussion
    3
    6
    2092
    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.
    • spyamine
      spyamine last edited by

      Hi,

      I really enjoy the platform. Though I'd like to know if it's possible to implement the UCITS rule of 5/10/40 rule. A rule that should be enforced during the backtest and the live trading of the portfolio. The rule is that every stock in the portfolio should not exceed 5% of the NAV and for those that are bigger than 5% the sum of those stock should not exceed 40% of the total portfolio. Can you please help with ideas to implement this constraint or better provide a code for that.

      Thank you

      A 1 Reply Last reply Reply Quote 0
      • A
        ab_trader @spyamine last edited by ab_trader

        @spyamine

        At every next() you need to:

        • get broker value
        • loop thru all positions currently held and for every position:
          • get position price
          • if position price larger than 5% of broker value then save it to dictionary bad_positions
        • calculate value of all positions in the bad_positions dictionary
        • if this value larger then 40% of broker value then do what need to be done and what was skipped in your post
        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        spyamine 1 Reply Last reply Reply Quote 1
        • spyamine
          spyamine @ab_trader last edited by

          @ab_trader Perfect thank you for this insight. I'm new to this platform!!

          1 Reply Last reply Reply Quote 0
          • spyamine
            spyamine last edited by

            Is it possible to imagine a seperate function that would do that for the portfolio? so we can activate it or copy paste it to every algorythm easily?

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

              @spyamine said in Fund UCITS constraints: 5/10/40 rule:

              Is it possible to imagine a seperate function that would do that for the portfolio?

              Of course you can imagine such a function: you can define an additional method in your strategy and invoke it from next

              1 Reply Last reply Reply Quote 0
              • spyamine
                spyamine last edited by

                @backtrader said in Fund UCITS constraints: 5/10/40 rule:

                Of course you can imagine such a function: you can define an additional method in your strategy and invoke it from next

                will try to do this. just a normal function ??
                thanks

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