There is no obvious way to do this since it’s not clear what transactions belong together. In you example, had you bought DAL in two different occasions, it’s not clear which one was sold. There has been a helpful piece of code posted recently that determines the profit when you sold the last stock: Easy way to calculate Profit per trade in python