
Calculate weighted average cost, total invested, and potential profit/loss for multiple stock lots
No saved portfolios yet.

Founder & CEO, Toolraxy
Faiq Ur Rahman is a web designer, digital product developer, and founder of Toolraxy, a growing platform of web-based calculators and utility tools. He specializes in building structured, user-friendly tools focused on health, finance, productivity, and everyday problem-solving.
User Ratings:
ADVERTISEMENT
ADVERTISEMENT
If you’ve purchased shares of the same stock on different days—a strategy known as dollar-cost averaging—you know that your cost basis isn’t simply the average of those prices. The number of shares you bought each time matters.
This tool is designed for the practical investor who needs a clear, accurate picture of their position. By aggregating every purchase “lot,” including the broker fees that eat into your returns, it calculates your weighted average cost per share. This is the number that truly matters, as it represents your breakeven point and is the foundation for calculating your unrealized profit or loss. Whether you’re managing a long-term portfolio or tracking active trades, knowing this figure is essential for rational decision-making.
Using this tool is straightforward and built around your actual trade confirmations. Follow these steps:
Enter Your Purchase Lots: For every time you bought the stock, input the Shares, the Price per Share, and the Broker Fee for that specific transaction. Click “Add Another Lot” to include all your purchase history.
Set the Current Market Price: Enter the stock’s current price to see the live value of your position.
Review Your Core Metrics: The main results panel immediately displays your Total Invested, Average Cost per Share, and Unrealized Profit/Loss.
(Optional) Run a What-If Scenario: Switch to the “What-If” tab. Enter a Target Sell Price and the number of shares you’re considering selling to estimate the net profit or loss from a partial or full sale.
This calculator uses a standard weighted average formula to determine your cost basis, which is the industry norm for calculating the cost of identical assets purchased at different times.
The Formula:
Weighted Average Cost Per Share = (Total Cost of All Shares) / (Total Number of Shares)
Where:
Total Cost of All Shares = Σ (Number of Shares in Lot * Purchase Price per Share + Broker Fee for Lot)
Total Number of Shares = Σ (Number of Shares in All Lots)
Understanding the Logic:
Weighting by Shares: The formula ensures that a purchase of 100 shares at $50 has ten times the impact on your average cost as a purchase of 10 shares at $50. This provides a mathematically accurate representation of your total investment.
Inclusion of Fees: By adding the broker fee to each lot’s total cost, the calculator factors in the real-world friction of trading. This provides a “true” average cost that reflects your total capital at risk, not just the notional share price.
Unrealized P&L: The profit or loss is calculated by comparing the current market value of your total shares against your total invested capital. A positive number means your position is worth more than you paid; a negative number means it’s worth less.
Scenario: An investor, Alex, has been accumulating shares of a tech company. He wants to understand his position before deciding whether to hold or sell some shares.
Lot 1 (3 months ago): Bought 20 shares at $140. Fee: $5.
Lot 2 (1 month ago): Bought 15 shares at $155. Fee: $5.
Lot 3 (Today): Bought 10 shares at $145. Fee: $5.
Inputs into Calculator:
Current Market Price: $150 (today’s price)
Step-by-Step Calculation:
Lot 1 Total Cost: (20 * $140) + $5 = $2,800 + $5 = $2,805
Lot 2 Total Cost: (15 * $155) + $5 = $2,325 + $5 = $2,330
Lot 3 Total Cost: (10 * $145) + $5 = $1,450 + $5 = $1,455
Total Invested Capital: $2,805 + $2,330 + $1,455 = $6,590
Total Shares Owned: 20 + 15 + 10 = 45 shares
Weighted Average Cost: $6,590 / 45 = $146.44 per share
Current Portfolio Value: 45 shares * $150 = $6,750
Unrealized Profit: $6,750 – $6,590 = +$160
Practical Interpretation:
Alex’s average cost is $146.44, which is higher than a simple average of his purchase prices ($146.67) but lower after accounting for the exact fee structure. At the current price of $150, he has a modest unrealized gain of $160. If he were to sell all shares now, his net profit after considering all historical costs would be $160. This clarity helps him decide if that return meets his threshold or if he should wait for a higher price.
Identical Shares: This model assumes all shares are identical and fungible. It does not account for different share classes or tax lots with specific identification methods used for tax reporting.
Static Market Price: The unrealized P&L is a snapshot based on a single current market price. It does not account for intraday price fluctuations.
Simplified Fee Structure: Broker fees are applied per lot. The “What-If” analysis applies a single sell fee to the entire simulated sale, which may differ from some brokers’ actual per-share fee structures.
No Dividends or Splits: The calculator does not factor in the impact of stock dividends, splits, or spin-offs, which can alter your cost basis.
For an investor, the cost basis is the original value of an asset, typically the purchase price adjusted for stock splits, dividends, and return of capital. When you buy an asset multiple times, you need to calculate an average cost basis. This is the figure used to determine your capital gain or loss when you eventually sell the asset. Using a simple average of prices is incorrect because it ignores the number of shares purchased at each price. A weighted average cost correctly reflects the total amount of capital you have deployed to acquire your current position.
The most common mistake is taking a simple average of the share prices. For example, with purchase prices of $100, $110, and $120, the simple average is $110. However, if you bought 10 shares at $100 and 100 shares at $120, your true average cost is much closer to $120 because most of your money was invested at that higher price. Ignoring trading commissions and fees is another frequent error, as these costs are a direct part of your investment and lower your net return.
Purchase Price & Share Quantity: These are the primary drivers. A large purchase (high quantity) will have a significantly greater influence on your average cost than a small one. This is the “weighting” effect.
Broker Fees: While seemingly small, fees add up. Over many lots, they can noticeably increase your average cost per share, effectively raising your breakeven point and reducing any potential profit.
Current Market Price: This variable does not affect your historical average cost. It is used exclusively to calculate your unrealized profit or loss, providing a real-time health check on your investment.
Personal Portfolio Management: Individual investors use it to track the performance of stocks, ETFs, and mutual funds they purchase regularly.
Tax Planning: Knowing your cost basis is crucial for estimating potential capital gains taxes before you decide to sell a position.
Investment Performance Review: It allows for an objective comparison between different investments by establishing a clear baseline cost.
Market Risk: Your unrealized P&L will fluctuate with the market price. A stock trading above your average cost today could be below it tomorrow.
Concentration Risk: Repeatedly buying the same stock lowers your average cost if the price drops, but it also increases your concentration in a single asset, which can amplify losses.
Tax Implications: The calculator shows financial gain/loss, not tax liability. Realized gains may be subject to short-term or long-term capital gains tax rates, which is a critical factor in net return.
This model is a snapshot. It doesn’t predict future performance. It provides a clear view of the past—how much you’ve invested and what it’s worth now—which is the essential starting point for all forward-looking investment decisions.
Rely on this tool for a quick, accurate understanding of your position’s cost basis and current value. It is ideal for personal record-keeping and initial scenario planning. However, for formal tax reporting, portfolio optimization, or strategies involving complex tax-loss harvesting, you should consult a tax professional or financial advisor who can consider your entire financial situation.
Gain True Financial Clarity: Move beyond simple averages to understand your real cost basis and the actual performance of your investment.
Make Informed Decisions: Use the “What-If” analysis to model the financial outcome of a potential sale before you execute it.
Eliminate Manual Errors: Avoid the common mistakes of miscalculating weighted averages or forgetting to include trading fees.
Save Valuable Time: Instantly aggregate years of purchase history into a single, clear financial summary.
Improve Portfolio Tracking: Monitor your unrealized gains and losses to make more strategic decisions about holding or selling.
It’s calculated as a weighted average. The total cost of all your purchases (including fees) is divided by the total number of shares you own. This gives more weight to larger purchases, providing a true representation of your average cost per share.
Yes. When you enter a broker fee for each purchase lot, it is added to the total cost of that transaction. This ensures your average cost per share and total invested capital accurately reflect your total cash outlay.
The primary assumption is that all shares are identical and interchangeable. It uses a simple weighted average of your purchase costs, which is the standard method for calculating cost basis when specific shares aren’t identified at the time of sale.
Because of the “weighted” nature of the calculation. If you bought a large number of shares at a high price and a small number at a low price, your average cost will be closer to that high price. The simple midpoint ignores the quantities, making it inaccurate.
It takes the number of shares you plan to sell, multiplies it by your average cost per share to get the cost basis for those shares. It then calculates the net proceeds from the sale (shares × target price minus the broker fee). The difference between the net proceeds and the cost basis is the estimated profit or loss.
This calculator provides estimates based on the inputs entered and the assumptions described. It is designed for informational and educational purposes only and does not constitute financial advice. The results are not a guarantee of future performance or a substitute for professional financial guidance. For decisions involving significant financial commitments or tax implications, consult a qualified financial professional.
ADVERTISEMENT
ADVERTISEMENT