IRS Publication 550 bears close reading. I'm going to know this backwards and forwards, especially in conjunction with US Code Title 26, Section 1274.