Calculation of total profit/loss