The cost basis of a stock is essentially its original value for tax purposes. It's a crucial figure for investors because it determines the amount of capital gain or loss when you sell shares. Calculating your cost basis accurately is essential for proper tax reporting.
What is Included in Cost Basis?
The most straightforward way to calculate cost basis is to sum up the purchase price of your shares and any directly related transaction costs. These costs typically include:
Purchase Price: The amount you paid for each share.
Commissions and Fees: Any brokerage fees, transaction fees, or other charges associated with buying the stock.
Other Adjustments: While this calculator focuses on the basic purchase, in more complex scenarios, cost basis can be adjusted for stock splits, reinvested dividends, rights offerings, and corporate reorganizations.
The Formula for Basic Cost Basis:
The formula used in this calculator is:
Total Cost Basis = (Purchase Price Per Share × Number of Shares) + Total Commission and Fees
To find the cost basis per share, you divide the Total Cost Basis by the Number of Shares.
Why is Cost Basis Important?
When you sell shares, the difference between the selling price and your cost basis is your capital gain or loss.
If you sell for more than your cost basis, you have a capital gain.
If you sell for less than your cost basis, you have a capital loss.
Both capital gains and losses have tax implications. Knowing your accurate cost basis helps you report these gains or losses correctly to tax authorities, potentially reducing your tax liability by accurately accounting for losses or using appropriate tax strategies for gains (like holding for long-term capital gains rates).
Example Calculation:
Let's say you purchase 100 shares of XYZ Corp at $50 per share. You also paid a $10 commission fee to your broker.
Purchase Price for all shares: $50/share * 100 shares = $5,000
Total Cost Basis: $5,000 + $10 (commission) = $5,010
Cost Basis Per Share: $5,010 / 100 shares = $50.10 per share
If you later sell these 100 shares for $60 per share, your capital gain would be ($60 – $50.10) * 100 shares = $990.
Disclaimer: This calculator provides a basic calculation for stock cost basis. For complex transactions, consult with a qualified tax professional or financial advisor.
function calculateCostBasis() {
var purchasePrice = parseFloat(document.getElementById("purchasePrice").value);
var numberOfShares = parseFloat(document.getElementById("numberOfShares").value);
var commissionFees = parseFloat(document.getElementById("commissionFees").value);
var errorMessageElement = document.getElementById("errorMessage");
errorMessageElement.textContent = ""; // Clear previous errors
// Input validation
if (isNaN(purchasePrice) || purchasePrice < 0) {
errorMessageElement.textContent = "Please enter a valid positive Purchase Price Per Share.";
return;
}
if (isNaN(numberOfShares) || numberOfShares <= 0) { // Shares must be positive for basis per share calculation
errorMessageElement.textContent = "Please enter a valid Number of Shares greater than zero.";
return;
}
if (isNaN(commissionFees) || commissionFees < 0) {
errorMessageElement.textContent = "Please enter a valid positive Commission/Fees amount.";
return;
}
var totalPurchaseCost = purchasePrice * numberOfShares;
var totalCostBasis = totalPurchaseCost + commissionFees;
var costBasisPerShare = totalCostBasis / numberOfShares;
document.getElementById("costBasisResult").textContent = "$" + totalCostBasis.toFixed(2);
document.getElementById("costBasisPerShare").textContent = "$" + costBasisPerShare.toFixed(2);
}