About the Cost Basis Calculator
Cost basis and gain for shares sold using FIFO or average cost across several purchase lots.
Also known as: tax basis, fifo cost basis, average cost basis, capital gain basis.
How to use this calculator
- Enter purchase lots: shares, price per share (oldest first), shares sold, sale price per share, method.
- The result updates instantly as you type — press Calculate (or Enter) at any time.
- Review the breakdown shown under the main result.
- Use Copy result or Share to save the answer or send a link with your inputs.
Formula
FIFO: earliest lots are sold first
Worked example
Using the values pre-filled in the calculator above:
- Purchase lots: shares, price per share (oldest first): 40, 100 30, 115 30, 90
- Shares sold = 50
- Sale price per share = 125
- Method: FIFO
the calculator returns:
- Cost basis of shares sold: 5,150
- Capital gain: 1,100
- Proceeds: 6,250
- Basis per share: 103