Unexpected result on strategy with order_target_percent
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?