HomeToolsCost Basis Calculator

Free tool · No signup · Results update instantly

Stock Average & Cost Basis Calculator

Bought shares at different prices? Enter each purchase lot to calculate your weighted average cost per share, total position size, and unrealized profit or loss against the live market price. No signup required.

Purchase lots

Enter your purchase lots above

Add the number of shares and price per share for each purchase. Search a ticker to auto-fill the current market price and see your unrealized gain or loss.

Cost basis methods: FIFO vs LIFO vs specific identification

FIFO (first in, first out)

FIFO is the IRS default method. When you sell shares, the oldest lots are sold first. In a stock that has risen over time, FIFO produces the largest capital gain because your oldest (cheapest) shares are the ones being sold. FIFO is simple and automatic — your broker uses it unless you specify otherwise.

FIFO works best when your earliest purchases were at higher prices than recent ones, or when you want simplicity and don't need to optimize for taxes.

LIFO (last in, first out)

LIFO sells your most recently purchased shares first. If the stock price has been rising, LIFO can reduce your taxable gain because the shares you sell have a higher cost basis (you paid more for them recently). Note that LIFO is not available for mutual funds — it's primarily used for individual stocks.

LIFO is useful when you've been adding to a position at progressively higher prices and want to minimize the tax hit on a partial sale.

Specific identification

Specific identification gives you the most control. You tell your broker exactly which lot of shares to sell. This lets you cherry-pick high-cost lots to minimize capital gains, or low-cost lots to harvest gains if you have losses elsewhere to offset. The IRS requires you to identify the specific shares at the time of sale and your broker must confirm.

This is the preferred method for tax-conscious investors with multiple lots at different prices. It requires more record-keeping but offers the greatest tax flexibility.

IRS reporting: what you need to know

Your broker reports your cost basis to the IRS on Form 1099-B for all “covered” securities (stocks acquired after January 1, 2011). For covered securities, the cost basis on your 1099-B must match what you report on Schedule D. If you use specific identification, make sure you notify your broker before the settlement date.

For “noncovered” securities (acquired before 2011), the broker does not report cost basis — you're responsible for tracking it yourself. Keep records of all purchase dates, prices, and commissions.

Frequently asked questions

How do I calculate average cost per share?

To calculate your average cost per share, add up the total amount you paid across all purchases (shares x price per share for each lot, plus any commissions), then divide by the total number of shares you own. For example, if you bought 50 shares at $100 and 50 shares at $120, your average cost is ($5,000 + $6,000) / 100 = $110 per share. This is also called the weighted average cost basis.

What is cost basis?

Cost basis is the original purchase price of an investment, adjusted for commissions and fees. The IRS uses your cost basis to calculate capital gains or losses when you sell. If you bought a stock for $50 and sell it for $75, your cost basis is $50 and your taxable gain is $25 per share. For stocks purchased in multiple lots at different prices, you need to determine which cost basis method to use: average cost, FIFO (first in, first out), LIFO (last in, first out), or specific identification.

What is the best cost basis method for taxes?

The best cost basis method depends on your tax situation. FIFO (first in, first out) is the IRS default and sells your oldest shares first — this usually produces the largest capital gain in a rising market. Specific identification lets you cherry-pick which shares to sell, giving you the most tax control — you can sell high-cost lots first to minimize taxable gains. LIFO (last in, first out) sells your newest shares first, which can reduce gains if you bought recently at higher prices. For mutual funds, the average cost method is simplest. Consult a tax advisor for your specific situation.