Stock Cost Basis Calculator

Track your cost basis of a stock with Calcopolis

The Stock Cost Basis Calculator is designed to help you organize purchases of the same stock and compare your average buy price with the current share price. Your stock cost basis starts with what you paid, but it is important to distinguish your total investment from your average cost per share.

Calculation limitation: The current calculation rule fixes the Cost Basis result at $0 and does not specify formulas for Total Profit or Return rate. Do not rely on these outputs for investment or tax decisions. The formulas and examples below explain the standard calculations so you can check your figures independently.

stocks costs

How to enter your stock purchases

The form includes purchase sections for up to five purchases and a Current Price field. Use purchases of one stock in the same currency, not purchases from different companies.

  1. Enter the Purchase Price: Use the price paid per share, not the total transaction amount. The form labels prices in dollars.
  2. Enter Stocks Purchased: Enter the number of shares bought at that price. The quantity fields use increments of one share.
  3. Add your other purchases: Use the additional purchase sections as they appear. Leave unused purchase quantities at zero so they contribute no cost or shares.
  4. Enter the Current Price: Use the current market price per share to compare market value with purchase cost. This price does not change your historical average purchase price.

Use positive purchase quantities and at least one purchased share. The form has no dedicated inputs for sales, dividends, transaction fees, purchase dates, or tax adjustments. If you have already sold some shares, entering every historical purchase will not necessarily describe your remaining position.

What does stock cost basis mean?

Two related figures are useful when tracking a position:

  • Total purchase cost: The sum of the amounts spent buying the shares.
  • Average cost per share: Total purchase cost divided by the total number of shares. This is a quantity-weighted average, not a simple average of purchase prices.

For example, a purchase of 100 shares has ten times the influence on your average price as a purchase of 10 shares. Simply adding the two prices and dividing by two would give the wrong answer.

Tax cost basis is a separate consideration. It can include acquisition costs and other adjustments, and a blended average is not necessarily the permitted basis for reporting a particular stock sale.

Stock cost basis formula and worked example

The standard weighted-average stock cost basis formula is:

Average cost per share = [(P1 × Q1) + (P2 × Q2) + … + (Pk × Qk)] ÷ (Q1 + Q2 + … + Qk)

Here, P is the purchase price per share, Q is the number of shares in that purchase, and k is the number of purchases. The numerator is total purchase cost; the denominator is total shares.

Suppose you make these four purchases of the same stock:

Purchase Price per share Shares purchased Purchase cost
1 $48.00 3 $144.00
2 $49.00 1 $49.00
3 $43.00 1 $43.00
4 $45.00 1 $45.00
Total — 6 $281.00

Average cost per share = $281 ÷ 6 = $46.8333…, or $46.83 rounded.

Keep the unrounded average when performing further calculations, or use the original $281 total. Multiplying the rounded $46.83 by six produces $280.98, introducing a small rounding error.

How to calculate stock profit, loss, and return

For an unsold position, the standard price-only calculations are:

  • Current market value = Current price per share × Total shares
  • Unrealized profit or loss = Current market value − Total purchase cost
  • Return rate (%) = (Unrealized profit or loss ÷ Total purchase cost) × 100

Equivalently, profit or loss equals the difference between current price and average cost per share multiplied by total shares—not divided by shares.

Using the six shares purchased for $281:

Current share price Market value Unrealized profit or loss Price-only return
$65.00 $390.00 $109.00 38.79%
$25.00 $150.00 −$131.00 −46.62%

A negative result means the position is worth less than its purchase cost. It does not mean the investment has lost all its value. These gains and losses remain unrealized until shares are sold.

This return is not annualized and excludes dividends, fees, and taxes. A return percentage is undefined when total purchase cost is zero.

Using your average purchase price in investment decisions

Your average price provides a reference point for comparing purchases or estimating a price-only break-even level. It does not tell you whether the stock is fairly valued or whether buying more is appropriate.

Does buying more shares lower your cost basis?

decreasing costs basis

Buying below your existing average lowers your average cost per share, while increasing your total dollars invested. Buying above your average raises it. For the example above, buying another six shares at $40 would bring total cost to $521 for 12 shares, giving an average of approximately $43.42.

Averaging down does not erase an existing dollar loss at an unchanged market price; it adds exposure to the stock. Evaluate the additional purchase on its own merits rather than buying solely to lower the displayed average.

Keep records that explain the numbers

Retain each purchase date, share quantity, execution price, and applicable fee. Reinvested dividends create additional purchases. Stock splits and other corporate actions may require adjustments to quantities or basis.

For a purchase-cost calculation that includes an acquisition fee, divide that lot’s total acquisition cost by its shares to obtain a fee-adjusted price per share. Keep the underlying records, since the form does not provide a separate fee field.

Average purchase price is not always tax basis

Although stock cost basis is central to calculating taxable gains, a portfolio’s weighted-average purchase price is not automatically the basis of shares you sell. Tax treatment depends on your jurisdiction, the security, applicable adjustments, and which purchase lots are treated as sold.

For U.S. individual stocks, FIFO generally applies when shares are not adequately identified. Specific identification can allow particular lots to be selected when the requirements are met. Average-basis treatment is available for certain eligible holdings, such as some mutual fund shares, but is not a universal stock-sale method.

The FIFO Inventory Calculator and LIFO Inventory Calculator illustrate inventory cost-flow methods. They are not securities tax calculators, and their methods should not be assumed to be valid elections for your stock sales.

Use your broker’s lot records and applicable tax guidance when reporting a sale. Purchase dates also matter for holding periods, which this form does not calculate.

Related tools for evaluating stock returns

track return rates

To investigate the company rather than your purchase history, explore the Price to Earnings ratio, Earnings Per Share ratio, and Earnings Per Share Growth. These address valuation and profitability, not your personal cost basis. More tools are available in our investing calculators category.

Create a calculator for your investing audience

An investing education website could help readers compare purchase scenarios and understand the effect of fees. With Calcopolis, you can build a custom investment ROI calculator tailored to the assumptions and examples you teach.