I am not sure of this is what you are asking, but whenever I do...

  1. 997 Posts.
    lightbulb Created with Sketch. 83
    I am not sure of this is what you are asking, but whenever I do a part sale, I split the original buy into two separate buys so my original recording for action 1 which was buy 100k shares, becomes split into two actions each of buys of 50K, with brokerage costs split between the two. I then match one of those buys against the action 2 sale of 50K to get my gain (or profit) on that sale. When action 4 occurs (the sale of 150K shares), I match that with the remaining 50K of action 1 and the 100k of action 3 to work out the gain (or profit) on that sale.
 
arrow-down-2 Created with Sketch. arrow-down-2 Created with Sketch.