Stock Cost Basis Calculator

Work out the cost basis of shares you sell from multiple purchase lots, using FIFO, LIFO, or average cost, including fees.

Results

Enter your details and click Calculate to see your results.
About This Calculator

Enter up to three purchase lots from oldest to newest — shares, price per share, and the fees you paid — then the number of shares you sold, the sale price, and the sale fees. Choose which shares count as sold: FIFO uses the oldest first, LIFO uses the newest first, and Average Cost uses the average of all lots. Leave unused lots at 0.

Example

Example: with lots of 100 shares at $40, 50 at $55, and 50 at $48 ($5 fees each), selling 120 shares at $60 has a cost basis of $5,107 under FIFO (a $2,088 gain), $5,961 under LIFO (a $1,234 gain), or $5,499 under Average Cost (a $1,696 gain).

Assumptions

Fees are added to each lot's cost, and sale fees are subtracted from proceeds. This tool calculates cost basis and gain only — it doesn't calculate tax. Which methods you're allowed to use depends on your country and account type; for example, average cost is usually only allowed for mutual funds in the US. For the tax on the gain, see the Capital Gains Cost Basis Calculator under Tax Calculators. This tool provides general estimates for informational purposes only and isn't financial or investment advice. Past returns don't guarantee future results — consider speaking with a licensed financial professional about your own situation.

Frequently Asked Questions

Which method gives the lowest tax?

Whichever method matches your highest-cost shares to the sale produces the smallest gain. In this example LIFO does, because the newer lots were bought at higher prices — but short-term gains are often taxed more heavily, so the lowest gain isn't always the lowest tax.

Related Calculators

About the Author

Imran Hossain
Imran Hossain

Professional SEO, Digital Marketer Specialist

I am a Certified Google Ads Expert And Professional SEO, Digital Marketing Specialist

View full profile