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/

    Unexpected result on strategy with order_target_percent

    General Code/Help
    1
    1
    34
    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.
    • W
      willmusing last edited by

      Hi, I am new to bt and learning through the sample codes. I have questions on using order_target_percent where target=1 sometimes will set off unexpected results in the order like this https://community.backtrader.com/topic/1611/having-margin-problem-when-reversing-the-position-using-order_target_percent

      The link is a bit old and I have a related but different question. When placing an order like this:

      self.order = self.order_target_percent(data=self.spy, target=1)
      

      It resulted in a few order canceled/margin/rejected. So I changed target=0.9 and it does better but still has a couple of those results.

      How does order_target_percent calculate the units of share since "1" just means 100% of funds are used for the order? Please correct my understand here - I wonder how to use order_target_percent so that it figures out the cash limits and adjust itself to buy slightly lower number of units of shares rather than resulting in order canceled/margin/rejected?

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