For my rakutentrade its like this
I use back your example
so you only have 2k units, cost price 6.70
you sold all at 6.83
then you bought back 2k units at 6.65
in your portfolio, the average unit price calculation considers all 4k units, so it will be.
(2000*6.70)+(2000*6.65)
13400+13300 =26700
26700/4000 = 6.675 per unit
so at the end day you will have 2k units at 6.675
your realized profit will be 6.83-6.675 =0.155
0.155*2000 = RM310
Rakutentrade provides day trade rebate for contra account. means if you buy and sell the same share on the same day, you only pay one side of the brokerage fee
How is this profit when I'm seeing loss at my portfolio? Even though I bought at a lower price and sold earlier im still at a lost