INVESTING
Cost Basis Calculator — Calculate Your Investment Cost Basis
By Worldtickers ·
Use our free cost basis calculator to determine the total cost of acquiring an investment across multiple purchases. Supports average cost, specific lot identification, and wash sale adjustments.
This cost basis calculator — calculate your investment cost basis tool focuses on use our free cost basis calculator to determine the total cost of acquiring an investment across multiple purchases. Supports average cost, specific lot identification, and wash sale adjustments. Use it to compare investment returns, income, risk, compounding, and portfolio assumptions while changing price, yield, time, allocation, or contribution inputs.
Cost Basis Calculator
Cost Basis Calculator
Add every purchase lot for a position — shares, price per share, and any commission or fee paid. We total the full dollar cost basis and the average cost basis per share, including fees.
What Is Cost Basis?
Cost basis is the original value of an investment for tax purposes — essentially, the total amount you paid to acquire it. This includes the purchase price of each share or unit plus any costs directly tied to the acquisition, such as brokerage commissions, transaction fees, or other acquisition expenses. When you eventually sell, trade, or otherwise dispose of the investment, your capital gain or loss is measured as the difference between what you received and your cost basis.
Tracking cost basis accurately is not optional — it is a requirement for correct tax reporting. The IRS requires you to report capital gains and losses on your tax return, and the cost basis figure is what determines whether you have a gain or a loss and how much it is. Brokerages are now required to report cost basis to the IRS for most securities purchased after 2011, but the responsibility for choosing the correct method and ensuring accuracy still rests with you as the taxpayer.
The concept is straightforward for a single purchase: you bought 100 shares at $50 each plus a $10 commission, your cost basis is $5,010. But most real-world investors buy shares at different times and prices over months or years, which is where cost basis calculation becomes more nuanced. Each separate purchase is called a "lot," and you need a method to account for all of them together. Our stock data platform lets you look up historical prices so you can reconstruct your purchase lots accurately.
Cost basis also applies to investments beyond stocks — it covers mutual funds, ETFs, bonds, real estate (with additional adjustments for improvements and depreciation), cryptocurrency, and any other asset you might buy and later sell at a gain or loss. The core idea is the same across all asset types: the cost basis is your reference point for measuring what you gained or lost.
How to Use This Calculator
This calculator lets you add multiple purchase lots and computes your total cost basis and average cost per share. You can choose between the average cost method and specific lot tracking.
Step 1: Add Your Purchase Lots
For each purchase, enter the number of shares and the price per share. Include any commission or fee by adding it to the total cost of that lot. Click "Add Lot" to add more purchases. You can add as many lots as you need.
Step 2: Choose Your Method
Average Cost: The calculator divides your total cost across all lots by the total number of shares to give you a single average cost per share. This is the simplest method and is the default for mutual funds.
Specific Lot: If you want to track individual lots separately, use this mode. It shows the cost basis for each lot individually, which is useful if you plan to use specific identification when selling to optimize your tax outcome.
Step 3: Review Your Results
The calculator displays your total cost basis (the sum you paid for all lots), your total number of shares, and your average cost per share. If using specific lot mode, you also see each lot's contribution to the total.
Formula Explained
The core cost basis formula is simple: Total Cost Basis = Σ (Shares × Price per Share + Commission) for each lot. For each purchase you make, multiply the number of shares by the per-share price, add the commission, and that is the cost basis for that lot. Sum all the lots to get your total cost basis.
To find the average cost per share: Average Cost per Share = Total Cost Basis ÷ Total Number of Shares. This is the number you would use if selling shares under the average cost method, which is common for mutual funds and some brokerages's default method for stocks.
For example, suppose you made three purchases: 100 shares at $40 ($4,000 + $5 commission = $4,005), 50 shares at $60 ($3,000 + $5 = $3,005), and 25 shares at $80 ($2,000 + $5 = $2,005). Your total cost basis is $4,005 + $3,005 + $2,005 = $9,015 for 175 shares. Your average cost per share is $9,015 ÷ 175 = $51.51. If you then sell 100 shares, your gain or loss depends on the sale price relative to $51.51 per share under the average cost method.
When wash sales are involved, the disallowed loss is added to the cost basis of the replacement shares. So if you sell at a $500 loss and the wash sale rule applies, the cost basis of your new shares increases by $500, effectively deferring the loss recognition to a future sale.
Examples
Example 1: Simple Two-Purchase Scenario
You buy 200 shares of Apple at $150 each ($30,000) with a $10 commission, then later buy 100 more shares at $175 each ($17,500) with a $10 commission. Your total cost basis is $30,010 + $17,510 = $47,520 for 300 shares. Average cost per share: $47,520 ÷ 300 = $158.40. If you sell all 300 shares at $200 each, your gain is ($200 − $158.40) × 300 = $12,480 under the average cost method.
Example 2: Specific Lot Identification
Using the same purchases above, suppose you want to sell only 100 shares. Under specific lot identification, you choose which lot to sell from. If you sell 100 shares from the first lot (bought at $150), your cost basis for those shares is $150.05 each (including proportional commission), and your gain per share at $200 is $49.95. If instead you sell from the second lot (bought at $175), the cost basis is $175.10 each, and your gain per share is only $24.90. By choosing the higher-cost lot, you reduce your taxable gain — this is the primary advantage of specific lot identification.
Example 3: Wash Sale Adjustment
You buy 100 shares at $50 ($5,000 + $5 commission = $5,005). The stock drops to $40 and you sell all 100 shares, realizing a $1,005 loss. Ten days later, you buy 100 shares at $42 ($4,200 + $5 = $4,205). Because you repurchased within 30 days, this is a wash sale. The $1,005 disallowed loss is added to the cost basis of your new shares: $4,205 + $1,005 = $5,210. Your new cost basis per share is $52.10. The loss is not gone — it is embedded in the higher cost basis and will be recognized when you eventually sell these replacement shares.
Example 4: Stock Split Adjustment
You buy 50 shares at $200 each ($10,000 + $10 commission = $10,010). The stock then does a 4-for-1 split. You now have 200 shares, but your total cost basis remains $10,010, making your per-share basis $50.05. The split did not create or destroy value — it just changed the number of shares and the per-share price. Your gain or loss when you sell is still measured against the same total cost basis.
Tips
Keep Records of Every Purchase
The single most important thing you can do is keep records of every purchase: date, number of shares, price per share, and commission. Brokerages typically maintain this for you, but if you transfer accounts, use multiple brokerages, or have older holdings from before the basis-reporting rules, you may need to reconstruct your records. Tax software can help, but the source data needs to be accurate.
Consider Your Tax Situation When Choosing Lots
If your brokerage supports specific lot identification, think about whether you should sell lots with the highest cost basis (to minimize gains) or lots held for more than a year (to qualify for long-term rates). Sometimes selling a higher-gain long-term lot results in a lower tax bill than selling a lower-gain short-term lot. Run the numbers both ways.
Don't Forget Reinvested Dividends
When you have dividend reinvestment turned on, each reinvested dividend is a new purchase that creates its own cost basis. These small, frequent lots add up over years and significantly increase your total cost basis, which reduces your taxable gain when you eventually sell. Make sure your records include all reinvested dividend purchases.
Understand Your Brokerage's Default Method
Most brokerages default to FIFO (first in, first out) when selling, which means the first shares you bought are considered the first ones sold. If you want to use a different method like specific identification or HIFO (highest in, first out), you typically need to specify this at the time of the sale — not after. Check your brokerage's policy and set your preference before you sell.
Use Tax-Loss Harvesting Strategically
If you have investments with a cost basis higher than their current value, you may have an opportunity to sell at a loss and use that loss to offset gains elsewhere in your portfolio. You can deduct up to $3,000 in net capital losses against ordinary income per year, with the remainder carrying forward to future years. Just watch the wash sale rule — if you buy back a substantially identical security within 30 days, the loss is disallowed.
Frequently Asked Questions
What is cost basis?
Cost basis is the original value of an asset for tax purposes, typically the purchase price plus any costs to acquire it such as commissions or fees. It is the reference point used to calculate capital gains or losses when you sell the investment. When you sell, your taxable gain or loss is the sale price minus the cost basis. Accurate cost basis tracking is essential for correct tax reporting.
How do I calculate cost basis with multiple purchases?
To calculate cost basis with multiple purchases, add up the total amount paid across all lots (each separate purchase) including commissions and fees. For example, if you bought 50 shares at $40 and 50 shares at $60, each with a $5 commission, your total cost basis is (50 × $40 + $5) + (50 × $60 + $5) = $2,005 + $3,005 = $5,010 for 100 shares. The calculator above lets you enter each purchase lot and computes this automatically.
What is the average cost basis method?
The average cost method divides your total cost (across all purchases) by the total number of shares to find a single average cost per share. Using the example above, $5,010 ÷ 100 shares = $50.10 per share. This method is commonly used for mutual funds and is also available for stock holdings at most brokerages. It simplifies tracking because you only need one number instead of tracking each individual lot separately.
What is specific lot identification?
Specific lot identification (also called specific identification or HIFO — highest in, first out) lets you choose which particular shares you are selling rather than using an average. When you sell, you match the sale to a specific purchase lot. This gives you more control over your tax outcome — for example, you can choose to sell the lots with the highest cost basis first to minimize your capital gain, or sell lots held longer than a year to qualify for long-term capital gains rates. Your brokerage may track lots for you, but you need to confirm they support the method you want.
How do stock splits affect cost basis?
A stock split does not change your total cost basis — it only changes the number of shares you hold and the per-share cost. For example, if you bought 100 shares at $50 (total cost $5,000) and the stock does a 2-for-1 split, you now have 200 shares but your total cost basis is still $5,000, making the per-share basis $25. Reverse splits work the same way in reverse. The calculator handles splits automatically when you adjust the number of shares and per-share price for post-split holdings.
What are wash sales and how do they affect cost basis?
A wash sale occurs when you sell a stock or security at a loss and then buy substantially identical shares within 30 days before or after the sale. When a wash sale happens, the IRS disallows the loss deduction for that sale. Instead, the disallowed loss is added to the cost basis of the replacement shares. For example, if you sell 100 shares at a $500 loss and repurchase 100 shares within 30 days, the $500 loss is added to the cost basis of your new shares. The calculator above includes a wash sale adjustment option so you can factor this in.
How does cost basis affect taxes?
Cost basis directly determines your capital gain or loss when you sell. If you sell for more than your cost basis, you have a capital gain; if you sell for less, you have a capital loss. Short-term gains (from assets held one year or less) are taxed as ordinary income, while long-term gains (held more than one year) receive preferential tax rates. Accurate cost basis tracking lets you optimize which lots to sell to minimize your tax bill. You can also use capital losses to offset gains, with up to $3,000 in excess losses deductible against ordinary income each year.
Can I use cost basis for crypto?
Yes. The concept of cost basis applies identically to cryptocurrency. Each time you buy crypto, your purchase price (plus fees) becomes your cost basis for those units. When you sell, trade, or spend crypto, you calculate your gain or loss using the cost basis of the specific units you disposed of. Most crypto tax software uses either FIFO, LIFO, or specific identification to match dispositions to acquisitions. The calculator above works for crypto holdings — just enter your purchase lots as you would for stocks.
What happens to cost basis when I receive dividends?
Regular cash dividends do not affect your cost basis — they are treated as income, not a return of capital. However, return of capital distributions do reduce your cost basis by the amount of the distribution, because the IRS considers that portion of your investment to have been returned to you. When your cost basis is reduced to zero through return of capital distributions, any further distributions are treated as capital gains. Reinvested dividends increase your cost basis because each reinvestment is treated as a new purchase at the reinvestment price.