Hi Hadi,
This is similar to this post => Weird calculation of the average price
The closed position is based on average price instead of LIFO (i.e. last in first out).
Therefore P&L for the closed position is sell price - average price = (0.52 - 0.744) x 10,000 = -2240
Again, I am skipping fees in the computation for simplicity.
Cheers,
Evan