What Is Cost Basis of a Stock?
Cost basis is the original value of a stock investment for tax purposes. When you purchase shares of a company, the cost basis is typically the price you paid per share multiplied by the number of shares, plus any commissions or transaction fees. This figure is essential because it determines your capital gain or loss when you eventually sell the shares.
For investors who buy shares at different times and prices — through dollar-cost averaging, reinvested dividends, or scaling into positions — the cost basis becomes the weighted average price across all purchase lots. Our cost basis of stock calculator automates this by fetching real historical closing prices for each purchase date, eliminating manual lookups and arithmetic errors.
How to Use This Cost Basis of Stock Calculator
- 1
Search for the Stock
Type the ticker symbol (e.g., AAPL, TSLA, MSFT) in the search box and select the correct company from the dropdown results.
- 2
Add Your Purchase Lots
For each purchase, enter the number of shares and the date you bought them. The calculator fetches the actual closing price on that date. You can also enter a manual price if you know the exact price you paid.
- 3
Add More Lots as Needed
Click "Add Lot" to include additional purchases. There is no limit to the number of lots you can add.
- 4
Review Your Results
Click "Calculate Cost Basis" to see your weighted average cost per share, total investment, current market value, and unrealized profit or loss — all based on real market data.
Cost Basis Formula
The weighted average cost basis is calculated using this formula:
Total Cost = ∑ (Sharesi × Pricei)
Average Cost Basis = Total Cost / Total Shares
Unrealized P&L = (Current Price − Average Cost) × Total Shares
For example, if you bought 50 shares of AAPL at $150 and later bought 30 more shares at $170, your total cost is (50 × $150) + (30 × $170) = $12,600 for 80 shares. Your average cost basis is $12,600 / 80 = $157.50 per share.
Why Cost Basis Matters for Investors
Tax Reporting
Your cost basis determines the capital gain or loss reported on your tax return. A higher cost basis means a smaller taxable gain (or larger deductible loss) when you sell. Accurate cost basis tracking is required by the IRS.
Break-Even Analysis
Your average cost basis is your break-even price. The stock must trade above this level for your position to be profitable. This is especially important when averaging down into a declining stock.
Dollar-Cost Averaging
If you invest a fixed amount regularly, your cost basis reflects the weighted average of all purchase prices. This strategy reduces the impact of volatility and is widely used in retirement accounts and index fund investing.
Portfolio Performance
Knowing your true cost basis for each holding lets you accurately measure portfolio performance. Without it, you cannot calculate your real return on investment or compare performance across different positions.
Cost Basis Accounting Methods
When you sell only part of your shares, the IRS allows several methods to determine which shares were sold and at what cost basis:
- Average Cost (this calculator) — Uses the weighted average price of all shares. This is the simplest method and the default for mutual funds.
- FIFO (First In, First Out) — Assumes the oldest shares are sold first. This is the IRS default method for stocks if you do not specify otherwise.
- LIFO (Last In, First Out) — Assumes the newest shares are sold first. This can minimize taxes if recent purchases were at higher prices.
- Specific Identification — You choose exactly which shares to sell. This gives the most control over tax outcomes but requires detailed record-keeping.
- HIFO (Highest In, First Out) — Sells the highest-cost shares first to minimize capital gains. Often used in tax-loss harvesting strategies.
Events That Adjust Your Cost Basis
Several corporate actions and events can change your cost basis beyond simple purchases:
- Stock Splits — A 2-for-1 split doubles your shares and halves your cost per share. The total cost basis remains the same. Our calculator uses split-adjusted prices automatically.
- Reinvested Dividends — Dividends reinvested to buy additional shares increase your total shares and total cost basis. Each reinvestment is a new purchase lot.
- Return of Capital — Distributions classified as return of capital reduce your cost basis rather than being taxed as income.
- Wash Sales — If you sell at a loss and repurchase substantially identical securities within 30 days, the disallowed loss is added to the cost basis of the new shares.
- Mergers & Acquisitions — When companies merge, your cost basis may be allocated across new shares or cash received based on the exchange ratio.