I am working on the capital gains taxes that the United States IRS demands (Form 8949 and Schedule D). Choosing a good algorithm for picking a cost basis for a sale seems to not be easy in the following situation:
- The items you are buying and selling are indistinguishable.
- You can buy arbitrary quantities of them for an arbitrary price.
- You care about rounding errors.
- You care about making future tax returns consistent with past ones.
- No one provides a Form 1099-B to you.
For example, suppose I bought 6 items for $0.17. (I am picking small numbers in this example to make it easy to see my point.) Then I sold each item individually, for various prices. I will need to report 6 cost bases to the IRS, and I think they need to add up to $0.17. The true cost basis of each item is 0.17/6, but I can't put that on a tax form because its decimal representation is infinitely long (0.02833333333...). Let's assume I want cost bases that do not have fractional pennies. Then a reasonable algorithm for this situation might assign the items to have these cost bases: 0.03, 0.03, 0.03, 0.03, 0.03, 0.02.
Another important thing to note is that I will be running this algorithm over multiple tax years. So I don't want a sale in 2016 to affect the cost basis of a sale I already reported on my 2015 tax return.
What is a good algorithm/method to pick each cost basis in situations like this?