Hi Miguel,
Some of your stocks fit at least one of your sell rules but also fits all of your buy rules. So you are actually selling and buying at the same time. Or technically, selling first then buying a slightly different number of shares. That difference in the number of shares sold and the number of shares purchased being the “buy/sell difference.”
I think there are 2 ways to fix this. The first being the best guarantee that the port is doing what you want.
- Make sure your buy and sell rules are exclusive.
By that I mean if you write a sell rule RankPos > 15 then write this corresponding buy rule: RankPos <= 15. Go through all of your rules until you are sure that for each sell rule there is a corresponding buy rule that guarantees there are no stocks being bought that fit any of the sell rules.
- The second method was discussed in a similar context in this post: What does sell = 1 mean?
It will take some thought as to what the program is actually doing if you use this but it will stop the behavior. You can set “Allow Immediate Buyback” to No as done here under “Rebalance”:
With this last method you have sold a stock and you are preventing the program from buying the same stock back no matter what the buy-rules say. But keep in mind that the stock may fit all of your buy rules and the repurchase is being blocked only because of this setting. That is fine, of course, as long as this behavior you want.
Hope that helps. I am sure others will be happy to explain this in a different way if that is helpful. I don’t think this is an easy concept the first time you encounter it.
Best,
Jim