Cost Basis Calculator
This calculator helps investors compute cost basis, proceeds, and realized gain or loss using common lot selection methods: FIFO, LIFO, Average Cost, and Specific Identification. It also supports illustrative wash-sale adjustments and a basic exchange (1031-like) illustration.
Enter up to three purchase lots and the sale details. Select the method that matches your accounting or tax reporting requirement. For Specific Identification, explicitly mark which lots were used for the sale.
Allocates sold shares to earliest purchase lots first. Purchase commissions are allocated per-share and added to the cost basis.
Inputs
Advanced inputs
1031-like exchange inputs
Results
Total cost basis (FIFO)
$0.00
Cost basis per share (FIFO)
$0.00
Proceeds (net)
$0.00
Gain / (Loss)
$0.00
| Output | Value | Unit |
|---|---|---|
| Total cost basis (FIFO) | $0.00 | USD |
| Cost basis per share (FIFO) | $0.00 | USD |
| Proceeds (net) | $0.00 | USD |
| Gain / (Loss) | $0.00 | USD |
Visualization
Methodology
Calculations allocate purchase costs and commissions to sold shares. Purchase commissions are added to basis; sale commissions reduce proceeds. The tool includes options to reflect user-provided wash-sale disallowed amounts and exchange replacement property cost when relevant.
This implementation follows best practices for numerical calculation (IEEE 754 floating point considerations) and uses clear per-share allocations to minimize rounding ambiguity. It is for informational purposes and does not replace professional tax advice.
Worked examples
Example 1 (FIFO): Buy 100 shares at $10 + $5 commission, then 100 shares at $12 + $5 commission. Sell 150 shares at $15 with $10 commission. FIFO allocates 100 shares at $10 and 50 shares at $12 when computing basis.
Example 2 (Average): Same purchases as above. Average cost method computes a weighted average across both lots and multiplies by shares sold.
Further resources
Expert Q&A
Should I rely on this calculator for filing taxes?
This tool is educational and intended to produce an accurate numeric result based on the inputs and chosen method, but it is not a substitute for tax filing software or a tax professional. Tax rules (including wash sale and exchange rules) have detailed conditions that may change the correct tax treatment.
How do I handle more than three lots?
This calculator accepts up to three purchase lots. For a larger history, aggregate older lots into a single lot (by computing weighted average for those lots) or use dedicated bookkeeping software that imports lot-level transaction history.
Why are commissions treated differently on buy vs sell?
By convention, purchase commissions are capitalized into the cost basis of the acquired shares. Sale commissions reduce the proceeds from the sale when computing gain or loss.
What is a wash sale and how is it handled here?
A wash sale occurs when substantially identical securities are bought within a specified timeframe around a loss sale, potentially disallowing the loss. This tool accepts a user-provided disallowed amount and shows the adjusted recognized gain/loss; it does not detect wash sales automatically.
Sources & citations
- NIST — Frameworks and guidance for secure and reliable calculation systems — https://www.nist.gov/
- ISO 8601 — Date and time format recommendation (used for date inputs) — https://www.iso.org/iso-8601-date-and-time-format.html
- IEEE 754 — Standard for binary floating-point arithmetic (relevant to numeric accuracy) — https://standards.ieee.org/standard/754-2019.html
- OSHA — Records retention and business continuity best practices (general guidance) — https://www.osha.gov/