Stock Cost Basis Calculator
A stock cost basis calculator computes your weighted average cost per share across multiple stock purchases at different prices. Enter each buy lot to instantly calculate your overall average cost basis for tax reporting and investment tracking.
What Is Stock Cost Basis?
Stock cost basis is the original price you paid for shares of a stock, including any commissions or fees. It is the starting point for calculating capital gains or losses when you sell. If you bought 100 shares at $40 each, your cost basis is $4,000. If those shares later sell for $5,000, your taxable capital gain is $1,000.
When you purchase the same stock in multiple transactions at different prices — a common strategy known as dollar cost averaging — you have multiple tax lots, each with its own cost basis. To report accurately on your taxes and track your investment performance, you need to know your weighted average cost per share across all lots. That is exactly what this calculator computes.
Cost basis is also called adjusted cost base (ACB) in Canada, or cost basis in the United States. The IRS and most brokers track this number for shares purchased since 2011 and report it on Form 1099-B.
How to Calculate Average Cost Basis
The Weighted Average Formula
The weighted average cost basis formula is:
Total amount invested is the sum of each lot's cost (shares × price per share). Total shares purchased is the sum of all shares across every lot. The result gives you a single average price per share that represents your blended cost basis.
Step-by-Step Example
Suppose you bought stock in three separate transactions:
| Lot | Shares | Price | Total Cost |
|---|---|---|---|
| 1 | 50 | $40.00 | $2,000.00 |
| 2 | 75 | $35.00 | $2,625.00 |
| 3 | 100 | $42.00 | $4,200.00 |
| Total | 225 | — | $8,825.00 |
Average cost per share = $8,825.00 ÷ 225 = $39.22 per share. This is your weighted average cost basis. If you sell all 225 shares at $50, your capital gain is (225 × $50) − $8,825 = $11,250 − $8,825 = $2,425.
Cost Basis Methods
Average Cost Method
The average cost method uses a single blended price per share calculated by dividing total invested by total shares. This is the simplest method for investors who regularly buy the same stock over time, such as through a dividend reinvestment plan (DRIP) or dollar cost averaging strategy. The IRS allows the average cost method for mutual fund shares and, in some cases, individual stocks. Once you elect to use average cost for a particular security, you cannot switch methods without IRS approval.
FIFO (First In, First Out)
Under the FIFO method, the IRS treats the shares you bought first as the shares you sell first. This is the default method used by most brokers unless you specify otherwise. In a rising market, FIFO typically results in a higher capital gain because the oldest shares (bought at the lowest price) are sold first. In a falling market, FIFO may produce smaller losses or even gains on older lots purchased at lower prices. You can learn more about FIFO's tax impact from Investopedia's explanation of cost basis methods.
Specific Identification
Specific identification lets you choose exactly which shares to sell, giving you the most control over your tax outcome. For example, if you want to harvest a tax loss, you can select the shares with the highest cost basis. If you want to minimize taxes, you can sell the oldest shares (held more than one year) to qualify for long-term capital gains rates. Specific identification requires you to instruct your broker at the time of sale and maintain adequate records. It is the most complex method but offers the greatest tax flexibility.
Cost Basis for Tax Reporting
Capital Gains Tax and Cost Basis
When you sell a stock, your capital gain or loss equals the sale proceeds minus your cost basis. A capital gain occurs when the sale price exceeds your cost basis. A capital loss occurs when your cost basis exceeds the sale price. The tax rate on capital gains depends on how long you held the shares:
- Short-term capital gains — Shares held for one year or less are taxed at your ordinary income tax rate, which can be as high as 37% for the highest earners.
- Long-term capital gains — Shares held for more than one year are taxed at preferential rates of 0%, 15%, or 20% depending on your taxable income. Most middle-income investors pay 15%.
- Net investment income tax — High earners may also owe an additional 3.8% net investment income tax on capital gains, bringing the top effective rate to 23.8%.
IRS Requirements
The IRS requires brokers to report cost basis on Form 1099-B for "covered securities," which generally means shares purchased on or after January 1, 2011. For older shares ("noncovered securities"), brokers may report a cost basis of zero or unknown, and you are responsible for determining the correct basis from your own records. The IRS provides detailed guidance in IRS Publication 550 on cost basis. You must report capital gains and losses on Schedule D of your federal tax return, with supporting details on Form 8949.
Dollar Cost Averaging and Cost Basis
Dollar cost averaging (DCA) is an investment strategy where you invest a fixed dollar amount in the same stock or fund at regular intervals — weekly, monthly, or quarterly — regardless of price. Because you buy more shares when prices are low and fewer shares when prices are high, DCA naturally produces a weighted average cost basis that is often lower than the arithmetic mean of the prices paid.
For DCA investors, tracking your cost basis across many small purchases can become complex. This calculator handles any number of lots, so you can enter every purchase you have made and get your current average cost basis in seconds. Many investors using DCA through employer-sponsored 401(k) plans or automatic investment plans will accumulate dozens of lots over time. Your brokerage typically tracks these automatically, but calculating average cost yourself helps you stay informed about your true investment performance.
For a deeper comparison of investment strategies, see our stock price calculator to evaluate individual purchase decisions.
Stock Cost Basis Examples
Example - Three Purchases at Different Prices
An investor buys shares of the same ETF over three months:
- January: 200 shares at $50.00 = $10,000 invested
- February: 300 shares at $45.00 = $13,500 invested
- March: 250 shares at $52.00 = $13,000 invested
Total: 750 shares, $36,500 invested. Average cost per share = $36,500 ÷ 750 = $48.67. If the investor sells all 750 shares at $60, the capital gain is (750 × $60) − $36,500 = $45,000 − $36,500 = $8,500. If the shares were held for more than one year, this gain would be taxed at the long-term capital gains rate.
Note that the average cost of $48.67 is not the simple average of the three prices ($50, $45, $52 → average $49.00). Because different quantities were purchased at each price, the weighted average differs from the simple average. This is why the correct formula uses total invested ÷ total shares rather than averaging the prices directly.
Frequently Asked Questions
What is cost basis?
Cost basis is the original purchase price of an investment, used to calculate capital gains or losses when you sell. For stocks, it includes the price paid per share plus any commissions. If you bought shares in multiple transactions, your cost basis is typically the weighted average of all purchases under the average cost method.
How do I calculate average cost per share?
Average cost per share = Total amount invested ÷ Total shares purchased. Add up the total dollar amount spent across all purchase lots, divide by the total number of shares purchased, and the result is your weighted average cost per share. This is the number used as your cost basis for tax reporting under the average cost method.
What cost basis method should I use?
For mutual funds and ETFs held in taxable accounts, the average cost method is simple and widely accepted. For individual stocks, FIFO is the IRS default but specific identification gives you more control over your tax outcome. Consult a tax advisor for your specific situation, especially if you have large unrealized gains or losses across different lots.
How does cost basis affect taxes?
Your cost basis reduces the taxable portion of a stock sale. Capital gain = Sale proceeds − Cost basis. A higher cost basis means a smaller taxable gain. If your cost basis equals the sale price, you have no gain and owe no capital gains tax. If cost basis exceeds the sale price, you have a capital loss, which can offset other capital gains or up to $3,000 of ordinary income per year.
Where do I find my cost basis?
Your broker reports cost basis on Form 1099-B for shares purchased after 2011. You can also find it in your brokerage account under transaction history or tax lots. For older shares or shares transferred between brokers, reconstruct your basis from historical trade confirmations, account statements, or dividend reinvestment records. The SEC provides guidance on understanding your cost basis at the SEC investor education center.