Based on your financial expertise, provide your response or viewpoint on the given financial question or topic. The response format is open.

How does the U.S. wash sale replacement stock rule work?
Edited: Pub 550 says 30 days before or after so the example is ok - but still a gain by average share basis.  On sale your basis is likely defaulted to "average price" (in the example 9.67 so there was a gain selling at 10), but can be named shares at your election to your brokerage,  and supported by record keeping. A Pub 550 wash might be buy 2000 @ 10 with basis 20000, sell 1000 @9 (nominally a loss of 1000 for now and remaining basis 10000), buy 1000 @ 8 within 30 days.   Because of the wash sale rule the basis is 10000+8000 paid + 1000 disallowed loss from wash sale with a final position of 2000 shares at 19000 basis.  I think I have the link at the example:  http://www.irs.gov/publications/p550/ch04.html#en_US_2014_publink100010601