True, but for tax purposes they expect you to treat it as two separate transactions. There might be a lawsuit, but they probably won't win.
purchase of stock (any securities) is not taxed. Profits are. Loss is deductible from profits. Get yourself a CPA. Every honest citizen must pay as little taxes as possible.
Who helps your gov to write the tax law? The Big 4 and CPA lobby groups. Now you know, why it's so complicated. Did few trades cap gain/loss is nothing complicated if you can read