How to reproduce:
Ssell X amount of stock and, then buy back the same amount of stock. In this case, the securities tab filter of “Do not show 0 positions” does not work and the position size is shown as X, but the value is 0.
This is relevant in case someone does short selling.
It used to work, but a few weeks ago after an update the position showed up all of a sudden.
I’d say the filter works correctly, it’s just that the number on which it operates is wrong. But the general answer is: Short selling is not supported.
Is there any reason why not to make this change?
As much as I can think there should be no impact to movingRelativeCost and movingRelativeNetCost, but heldShares value would stop lying.
Your reply would have merit if the fix was complicated or required sacrifices from the non-short-selling use case, which as much as I can see is not the case.
There will be, on the next iteration (when visit() is called on the next transaction). Still, it might make more sense to have the correct number of shares (even if negative) and mark the other data as invalid in some other way.
@chirlu that is my understanding as well.
I mean movingRelative(Net)Cost will anyway show a wrong value in this case, but at least we can make sure that sharesHeld will be correct.
I would also argue that sharesHeld is far more important, than movingRelative(Net)Cost, because almost every user will choose to display it and one of the core filters (user not wanting to see positions he does not own anymore) depends on it, it seems.
I guess the proper solution is to not take the value of sharesHeld from CostCalculation, but have an independent aggregator. That most likely is a large refactor, so this almost one liner seems like a good enough fix until then.