"buy/sell difference"

one question. I have created a live strategy, and in the rebalance tab, once I get recommendations, I can see that some transactions have in “note” column “buy/sell difference”. what does it mean? and why is this a reason to buy/sell a stock?

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.

  1. 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.

  1. 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.



What Jim said.

It is a rebalance trade. You can adjust your weight constraint % in the rebalance tab.

You can also just put a checkmark by it when it comes up as a recommendation to reject it.

1 Like

Ok, thanks a lot for the answers. Now I understand. I want to keep the stocks so I will reject the recommendation each time it happens again for each rebalance.
But what about the backtests? If I go to recent transactions I see it is happening each rebalance and is selling the stock just to buy it again, so the transaction costs are decreasing my returns.
So I guess that the only solution is to change the buy and sell rules to make them exclusive… or no buyback…

No, you don’t get dinged on selling and buying back. That is just an internal process. But what can happen if your % weight rebalance is too low is that it will trade a couple shares and you have to pay transaction fees on that. If you want, crank up the % optimal weight to 50% in the backtest. If an optimal position is 10%, it will allow it to vary by 50% (or up to 15% weight) before trimming. At least that’s my understanding.