The cost basis of a stock is essentially your investment in that stock. It's used to determine your capital gain or loss when you sell your shares. For tax purposes, it's crucial to accurately calculate your cost basis. It typically includes the original price you paid for the stock, plus any commissions or fees associated with the purchase.
How to Calculate Cost Basis
The fundamental formula for calculating the cost basis of a stock purchase is:
Total Cost Basis = (Purchase Price Per Share * Number of Shares) + Commissions & Fees
The calculator above uses this exact formula to provide your total cost basis. It's important to note that the cost basis might need adjustments for certain situations, such as stock splits, dividend reinvestments, or wash sales. For these more complex scenarios, consulting a tax professional is highly recommended.
Why is Cost Basis Important?
When you sell stock, you'll owe capital gains tax on the profit you made. The profit is calculated as your selling price minus your cost basis. If your cost basis is higher, your taxable gain will be lower, and vice-versa. Accurate record-keeping of your cost basis is essential for precise tax reporting and can potentially reduce your tax liability.
Example Calculation:
Let's say you purchased 100 shares of XYZ Corp at $50 per share. You also paid a $10 commission to your broker for this transaction.
Purchase Price Per Share: $50.00
Number of Shares: 100
Commissions & Fees: $10.00
Using the formula:
Total Cost Basis = ($50.00 * 100) + $10.00
Total Cost Basis = $5000.00 + $10.00
Total Cost Basis = $5010.00
This $5010.00 would be your cost basis for this particular stock purchase. If you later sold all 100 shares for $60 per share, your capital gain would be ($60 * 100) – $5010.00 = $6000 – $5010.00 = $990.00.
function calculateCostBasis() {
var purchasePrice = parseFloat(document.getElementById("purchasePrice").value);
var numberOfShares = parseFloat(document.getElementById("numberOfShares").value);
var commissionFees = parseFloat(document.getElementById("commissionFees").value);
var resultElement = document.getElementById("result");
resultElement.textContent = ""; // Clear previous results
if (isNaN(purchasePrice) || isNaN(numberOfShares) || isNaN(commissionFees)) {
resultElement.textContent = "Please enter valid numbers for all fields.";
resultElement.style.backgroundColor = "#dc3545"; // Red for error
return;
}
if (purchasePrice < 0 || numberOfShares < 0 || commissionFees < 0) {
resultElement.textContent = "Values cannot be negative.";
resultElement.style.backgroundColor = "#dc3545"; // Red for error
return;
}
var totalCostBasis = (purchasePrice * numberOfShares) + commissionFees;
resultElement.textContent = "Total Cost Basis: $" + totalCostBasis.toFixed(2);
resultElement.style.backgroundColor = "#28a745"; // Green for success
}