Stock Market Average Calculator

Stock Market Average Cost Calculator

Use this calculator to determine your average cost per share for a stock you've purchased multiple times at different prices. This is crucial for understanding your investment's performance and for tax purposes.

Enter the price you paid for each purchase, separated by commas.
Enter the number of shares bought for each corresponding price, separated by commas.

Understanding Your Average Stock Cost

When you invest in the stock market, it's common to buy shares of the same company at different times and at different prices. This strategy, often part of dollar-cost averaging, helps mitigate risk by not putting all your capital into a single purchase.

What is Average Cost Per Share?

Your average cost per share is the total amount of money you've invested in a particular stock divided by the total number of shares you own. It provides a single, blended price that represents your overall investment in that security. This figure is critical for several reasons:

  • Performance Tracking: It helps you quickly see if your investment is currently profitable (current price > average cost) or at a loss (current price < average cost).
  • Tax Implications: For tax purposes, especially when selling shares, your cost basis (which is often your average cost) determines your capital gains or losses.
  • Investment Decisions: Knowing your average cost can influence decisions about whether to buy more, hold, or sell shares.

How to Use the Calculator

  1. Prices per Share: In the first input field, enter the price you paid for each individual purchase of the stock. Separate each price with a comma. For example, if you bought shares at $100, then $95, and later $105, you would enter: 100, 95, 105.
  2. Number of Shares: In the second input field, enter the number of shares you bought corresponding to each price. Ensure the order matches the prices you entered. For the example above, if you bought 10 shares at $100, 15 shares at $95, and 5 shares at $105, you would enter: 10, 15, 5.
  3. Calculate: Click the "Calculate Average Cost" button. The calculator will then display your total investment, total shares owned, and your average cost per share.

Example Calculation

Let's say you made the following purchases for a stock:

  • Purchase 1: 10 shares at $100 per share
  • Purchase 2: 15 shares at $95 per share
  • Purchase 3: 5 shares at $105 per share

Input for Prices per Share: 100, 95, 105
Input for Number of Shares: 10, 15, 5

The calculator would perform the following steps:

  1. Calculate the cost of each purchase:
    • Purchase 1: 10 shares * $100/share = $1000
    • Purchase 2: 15 shares * $95/share = $1425
    • Purchase 3: 5 shares * $105/share = $525
  2. Calculate the total investment: $1000 + $1425 + $525 = $2950
  3. Calculate the total number of shares: 10 + 15 + 5 = 30 shares
  4. Calculate the average cost per share: $2950 / 30 shares = $98.33

Your average cost per share for this stock would be $98.33.

.stock-market-average-calculator { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; max-width: 700px; margin: 20px auto; padding: 25px; border: 1px solid #e0e0e0; border-radius: 8px; background-color: #ffffff; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); } .stock-market-average-calculator h2 { color: #2c3e50; text-align: center; margin-bottom: 25px; font-size: 26px; } .stock-market-average-calculator h3 { color: #34495e; margin-top: 30px; margin-bottom: 15px; font-size: 22px; } .stock-market-average-calculator h4 { color: #34495e; margin-top: 20px; margin-bottom: 10px; font-size: 18px; } .stock-market-average-calculator p { line-height: 1.6; color: #555; margin-bottom: 15px; } .stock-market-average-calculator .calculator-form { background-color: #f9f9f9; padding: 20px; border-radius: 6px; border: 1px solid #eee; margin-bottom: 25px; } .stock-market-average-calculator .form-group { margin-bottom: 18px; } .stock-market-average-calculator label { display: block; margin-bottom: 8px; font-weight: bold; color: #333; } .stock-market-average-calculator input[type="text"] { width: calc(100% – 22px); padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; box-sizing: border-box; } .stock-market-average-calculator input[type="text"]:focus { border-color: #007bff; outline: none; box-shadow: 0 0 5px rgba(0, 123, 255, 0.2); } .stock-market-average-calculator small { display: block; margin-top: 5px; color: #777; font-size: 13px; } .stock-market-average-calculator button { display: block; width: 100%; padding: 12px 20px; background-color: #28a745; color: white; border: none; border-radius: 4px; font-size: 18px; cursor: pointer; transition: background-color 0.3s ease; margin-top: 20px; } .stock-market-average-calculator button:hover { background-color: #218838; } .stock-market-average-calculator .calculator-result { margin-top: 25px; padding: 15px; border: 1px solid #d4edda; background-color: #e9f7ef; border-radius: 5px; font-size: 18px; color: #155724; text-align: center; font-weight: bold; display: none; /* Hidden by default */ } .stock-market-average-calculator .calculator-result p { margin: 5px 0; color: #155724; } .stock-market-average-calculator ul { list-style-type: disc; margin-left: 20px; margin-bottom: 15px; color: #555; } .stock-market-average-calculator ol { list-style-type: decimal; margin-left: 20px; margin-bottom: 15px; color: #555; } .stock-market-average-calculator li { margin-bottom: 8px; line-height: 1.5; } .stock-market-average-calculator a { color: #007bff; text-decoration: none; } .stock-market-average-calculator a:hover { text-decoration: underline; } function calculateAverageCost() { var pricesInput = document.getElementById('pricesInput').value; var sharesInput = document.getElementById('sharesInput').value; var resultDiv = document.getElementById('result'); resultDiv.style.display = 'none'; // Hide previous results var prices = pricesInput.split(',').map(function(item) { return parseFloat(item.trim()); }); var shares = sharesInput.split(',').map(function(item) { return parseFloat(item.trim()); }); // Input validation if (prices.length === 0 || shares.length === 0 || pricesInput.trim() === "" || sharesInput.trim() === "") { resultDiv.innerHTML = 'Please enter values for both prices and shares.'; resultDiv.style.display = 'block'; return; } if (prices.length !== shares.length) { resultDiv.innerHTML = 'The number of prices must match the number of share quantities.'; resultDiv.style.display = 'block'; return; } var totalInvestment = 0; var totalShares = 0; var isValid = true; for (var i = 0; i < prices.length; i++) { var price = prices[i]; var share = shares[i]; if (isNaN(price) || isNaN(share) || price <= 0 || share <= 0) { isValid = false; break; } totalInvestment += price * share; totalShares += share; } if (!isValid) { resultDiv.innerHTML = 'Please enter valid positive numbers for all prices and shares.'; resultDiv.style.display = 'block'; return; } if (totalShares === 0) { resultDiv.innerHTML = 'Total shares cannot be zero. Please enter valid share quantities.'; resultDiv.style.display = 'block'; return; } var averageCostPerShare = totalInvestment / totalShares; resultDiv.innerHTML = 'Total Investment: $' + totalInvestment.toFixed(2) + " + 'Total Shares Owned: ' + totalShares.toFixed(0) + " + 'Average Cost Per Share: $' + averageCostPerShare.toFixed(2) + "; resultDiv.style.display = 'block'; }

Leave a Comment