Agree
However rather than using a journal entry I use a multi-line receipt,
-
A line for each share lot being sold showing correct quantity and purchase unit price (& other capitalised costs)
-
Last line is realised capital gain (Loss) which is allocated to the above created account and balances the transaction / receipt.
For further details see Negative balance in investments - #9 by Patch