Recognizing transactions that trigger built-in gains or losses