calcuate profit from transactions