CalcOpenly
English

Stock average cost calculator (P&L and position size)

Calculate your average cost per share across several buys, unrealized profit and return, and the position size for your risk and stop loss.

Drafted with AI writing toolsUpdated Checked examples: 4

For example 100 42.50 or 100 @ 42.50.
$
$
$
%
$
$
$
Try
Unrealized profit or loss
$
Unrealized profit or loss: $957.50
Decimal places: 2; Nearest, ties to even
Return on cost
13.14%
Average cost per share (with fees)
$41.63
Shares held
175
Total cost
$7,285.00
Market value
$8,242.50
Amount at risk
$250.00
Shares to buy for this risk
96
Position cost at entry
$4,521.60
Reward-to-risk ratio
2.65: 1

You hold 175 shares at an average $41.63; at $47.10 that is a gain of $957.50 (13.14%). Risking $250.00 with a stop at $44.50 allows 96 shares, and the target pays 2.65 times that risk.

What you paid and what it's worth

Total cost: $7,285.00$7,285.00Total costMarket value: $8,242.50$8,242.50Market value

Trade plan

Loss zoneProfit zone44.547.154StopTargetEntry 47.10

Sized position: loss at stop and gain at target

Loss at stop$249.60Gain at target$662.40
Buys Rows: 3
BuyShares boughtPriceCostShares heldAverage price so far
1100$42.50$4,250.00100$42.50
250$38.20$1,910.00150$41.07
325$45.00$1,125.00175$41.63
How it's calculated S
  1. Average cost

    pˉ=7,285.00+0.00175=41.6286\bar p = \frac{7{,}285.00 + 0.00}{175} = 41.6286
  2. Profit or loss

    175×47.1−7,285.00=957.50(13.14%)175 \times 47.1 - 7{,}285.00 = 957.50\quad (13.14\%)
  3. Risk budget

    25,000×1%=250.0025{,}000 \times 1\% = 250.00
  4. Shares for this risk

    ⌊250.00∣47.1−44.5∣⌋=⌊96.1538⌋=96\left\lfloor \frac{250.00}{|47.1 - 44.5|} \right\rfloor = \left\lfloor 96.1538 \right\rfloor = 96

    Rounded down so the loss at the stop stays within the budget. Gaps through the stop can lose more.

  5. Reward to risk

    6.92.6=2.6538\frac{6.9}{2.6} = 2.6538

About the stock average cost calculator

Average cost is the total paid for all your buys, fees included, divided by the number of shares held. Unrealized profit or loss is the shares times the current price minus that total cost. For a new trade, position sizing starts from risk: the amount you are willing to lose (account size × risk per trade) divided by the gap between entry and stop loss gives the number of shares, rounded down.

With the defaults, buys of 100 shares at 42.50, 50 at 38.20 and 25 at 45.00 cost 7,285, an average of 41.63 a share. At 47.10 the 175 shares are worth 8,242.50, a gain of 957.50 or 13.14%. Risking 1% of a 25,000 account, 250, with an entry at 47.10 and a stop at 44.50 allows 96 shares, and a target of 54.00 offers 2.65 times the risk.

The stop is assumed to fill at its price; a gap through the stop makes the loss larger. Taxes are not included.

How to calculate the average price of a stock

Multiply each purchase's shares by its price, add the results and any fees, then divide by the total number of shares. Buying 10 shares at 100 and 20 at 110 costs 1,000 + 2,200 = 3,200 for 30 shares, an average of 106.67 a share. That average is your break-even price, before selling costs.

The same totals give the profit or loss on the position:

  • Total cost = Σ(shares × purchase price) + fees.
  • Average cost = total cost ÷ total shares.
  • Market value = shares × current price.
  • Unrealized gain or loss = market value − total cost. Divided by total cost and multiplied by 100, it is the return on cost. That return is not annualized and leaves out dividends and selling costs.

Stock average examples

Each row uses one currency and a current price of 110, except the first row (47.10) and the last (90). The first row is three buys: 100 shares at 42.50, 50 at 38.20 and 25 at 45.00, a total cost of 7,285.

ExampleShares heldFeesAverage costUnrealized gain/loss
Default holding and risk plan175041.63957.50
Stock purchases before fees300106.67100.00
Buying a lower price30093.33500.00
Buying a higher price300113.33-100.00
Equal share quantities200105.00100.00
Fractional share quantities20107.505.00
Total purchase fees3030107.6770.00
Three purchase lots300108.3350.00
Single purchase with fee1010101.00-110.00

The other rows use these buys:

  • Before fees, lower, higher and equal: 10 at 100, plus 20 at 110, 20 at 90, 20 at 120 or 10 at 110.
  • Fractional: 0.5 at 100 and 1.5 at 110.
  • Total purchase fees: 10 at 100 and 20 at 110, with 30 of fees.
  • Three lots: 5 at 95, 10 at 105 and 15 at 115.
  • Single purchase: 10 at 100 with a 10 fee, now priced at 90.

Averaging down and averaging up

Buying below your average cost pulls it down: adding 20 shares at 90 to 10 at 100 lowers the average to 93.33, so the price only needs to recover to 93.33 to break even. Buying above the average, 20 at 120, raises it to 113.33.

Both moves add shares and money to the position. Averaging down also increases what you lose if the price keeps falling, and neither move says anything about where the price goes next.

Add fees once, to the total

Purchase fees and commissions belong in the total cost, once. With 30 of fees on the 10-at-100 and 20-at-110 buys, the total cost is 3,230 and the average is 107.67, against 106.67 before fees.

If you track a running average lot by lot, keep the fees out of each lot's price and add the fee total at the end. Adding a fee to every lot and to the total counts it twice.

Position size from risk per trade

For a new trade, sizing starts from the amount you are willing to lose:

  • Amount at risk = account size × risk per trade ÷ 100.
  • Shares to buy = amount at risk ÷ |entry price − stop-loss price|, rounded down to a whole share.
  • Reward-to-risk = |target − entry| ÷ |entry − stop|.

Risking 1% of a 25,000 account is 250. With an entry at 47.10 and a stop at 44.50 the gap is 2.60, so floor(250 ÷ 2.60) = 96 shares, and a target of 54.00 offers 2.65 times the risk.

Plan exampleAmount at riskEntry/stop gapPlanned sharesReward/risk
Default holding and risk plan2502.6962.65
Short risk plan20021003.00
Whole-share rounding1501.65902.79
Target equals entry25010250.00
Budget below one share51001.00
Planned position exceeds account100110010.00

A short plan has its stop above entry, so its reward is entry minus target: 2% of 10,000 with an entry at 50, a stop at 52 and a target at 44 gives 100 shares and 3.00. Whole-share rounding turns 150 ÷ 1.65 = 90.9 into 90 shares.

The last three rows are plans to rethink: a target at the entry price offers no reward, a 5 budget against a 10 gap buys no shares, and 100 shares at 100 would need 10,000 in a 1,000 account. These plans are example inputs, not a recommended allocation.

The arithmetic assumes the stop fills at its stated price. FINRA's stop-order guidance explains why execution prices can differ. A gap through the stop makes the loss larger, and trading costs and taxes change the realized result.

Entering buys

  • One buy per line, shares first, then price: 10 100, 10;100 or 10 @ 100. Blank lines are skipped.
  • A comma between the two numbers is not a separator, and labels or comments are not accepted on a line.
  • Fractional shares are fine for holdings; the position-size plan always uses whole shares.
  • The weighted-average calculator takes the reverse order, price then weight, and has no place for fees.

Average cost and tax basis

Average cost per share is plain arithmetic on your buys. The basis a tax authority accepts can differ: the IRS stock-basis FAQ distinguishes identified shares and FIFO from the limited cases where average basis applies.

That is US guidance, not a rule for every country. Keep transaction and adjustment records for the method that applies to you.

For annualized growth between two values, use the ROI/CAGR calculator. For grades and other general value-and-weight lists, use the weighted-average calculator.

Worked examples

Three buys and a 1% risk plan

Buys (shares and price, one per line)
100 42.50 50 38.20 25 45.00
Fees and commissions (total)
0
Current price
47.10
Account size
25,000
Risk per trade
1%
Planned entry price
47.10
Stop-loss price
44.50
Target price
54.00
Average cost per share (with fees)
41.63
Unrealized profit or loss
957.50
Return on cost
13.14%
Shares to buy for this risk
96
Amount at risk
250.00
Reward-to-risk ratio
2.65 : 1

Checked against: script: 7285/175 = 41.628571; 175 × 47.10 − 7285 = 957.50; floor(250/2.60) = 96; 6.90/2.60 = 2.653846

Fees raise the cost basis

Buys (shares and price, one per line)
10 100
Fees and commissions (total)
10
Current price
90
Account size
25,000
Risk per trade
1%
Planned entry price
47.10
Stop-loss price
44.50
Target price
54.00
Average cost per share (with fees)
101.00
Unrealized profit or loss
-110.00
Return on cost
-10.89%

Checked against: (10 × 100 + 10)/10 = 101; 900 − 1010 = −110; −110/1010 = −10.891089%

Short trade with the stop above entry

Buys (shares and price, one per line)
100 42.50
Fees and commissions (total)
0
Current price
47.10
Account size
10,000
Risk per trade
2%
Planned entry price
50
Stop-loss price
52
Target price
44
Shares to buy for this risk
100
Reward-to-risk ratio
3.00 : 1
Position cost at entry
5,000.00

Checked against: Budget 200 / risk 2 per share = 100 shares; reward 6 / risk 2 = 3 (hand calculation)

Share count rounds down

Buys (shares and price, one per line)
100 42.50
Fees and commissions (total)
0
Current price
47.10
Account size
10,000
Risk per trade
1.5%
Planned entry price
23.40
Stop-loss price
21.75
Target price
28
Shares to buy for this risk
90
Reward-to-risk ratio
2.79 : 1
Position cost at entry
2,106.00

Checked against: 150 / 1.65 = 90.9 → 90 shares (floor); 4.60/1.65 = 2.787879

Questions

How do you calculate the average cost of a stock?

Add up what each buy cost, including fees, and divide by the total number of shares. For 100 shares at 42.50, 50 at 38.20 and 25 at 45.00, the cost is 4,250 + 1,910 + 1,125 = 7,285 for 175 shares, an average of 41.63. The position breaks even when the price returns to that average, plus any selling costs.

How does averaging down lower my break-even price?

Buying more shares below your average cost pulls the average down. Holding 100 shares bought at 42.50, adding 50 at 38.20 lowers the average to (4,250 + 1,910) ÷ 150 = 41.07, so the stock needs to recover only to 41.07 instead of 42.50. It also increases the amount you lose if the price keeps falling.

How many shares should I buy for my risk per trade?

Divide the amount you are willing to lose by the risk per share, the distance from entry to stop loss, and round down. Risking 1% of 25,000 is 250; with an entry at 47.10 and a stop at 44.50 the risk per share is 2.60, so 250 ÷ 2.60 = 96.15 gives 96 shares and a loss of 249.60 if the stop is hit.

What is a good reward-to-risk ratio?

It depends on how often your trades win. The ratio is (target − entry) ÷ (entry − stop): 6.90 ÷ 2.60 = 2.65 for the defaults. At 2.65 to 1, winning more than 1 ÷ (1 + 2.65) = 27.4% of trades covers the losses, before costs; at 1 to 1 you need to win more than half.

Is average cost the same as cost basis for US taxes?

Not for individual stocks. Under IRS Publication 550, if you do not identify which shares you sold, the first shares bought are treated as sold first (FIFO); the average-basis method is allowed for mutual fund shares and dividend reinvestment plans. Gains on shares held more than one year are long-term, and a loss is disallowed as a wash sale if you buy the same stock within 30 days before or after selling.

About this calculator

pˉ=∑sipi+fees∑si,shares=⌊account×risk%∣entry−stop∣⌋,RR=∣target−entry∣∣entry−stop∣\bar p = \frac{\sum s_i p_i + \text{fees}}{\sum s_i},\quad \text{shares} = \left\lfloor \frac{\text{account} \times \text{risk\%}}{|\text{entry} - \text{stop}|} \right\rfloor,\quad \frac{R}{R} = \frac{|\text{target} - \text{entry}|}{|\text{entry} - \text{stop}|}

Sources

  1. Van Tharp — Trade Your Way to Financial Freedom, ch. 14 (position sizing)
  2. FINRA — Understanding cost basis

For planning only. Lenders, tax authorities and markets apply their own rounding, fees and rules; confirm figures with them before you commit.

Checked against references

This calculator includes 4 worked examples with independently sourced answers. They run in the test suite, and you can run them here too.

Put this calculator on your site

Paste this where you want the calculator to appear. It is free to use, it stays in step with corrections made here, and the credit line below it links back so your readers can find the full version.

Height
Preview the embed

Keep the credit line. It is the only condition, and it is what keeps these calculators free.