How is realized profit/loss calculated?

How is realized profit/loss calculated?

Realized profit/loss is simply the difference between the sale proceeds (sell price * quantity sold) and the cost basis for the position, calculated based on the FIFO methodology discussed in the previous section.