CalcOpenly

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.

Updated Checked against 4 worked examples

For example 100 42.50 or 100 @ 42.50.
$
$
$
%
$
$
$
Try
Unrealized profit or loss
$
Unrealized profit or loss: $957.50
Shown to 2 decimal places, half-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 (3 rows)
BuySharesPriceCostShares 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.

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: Python decimal 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% (hand calculation, Python decimal)

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 (Python decimal)

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.

How accurate is the stock average cost calculator?

Accuracy depends on your inputs and the method's assumptions. Decimal arithmetic uses 50 significant digits, but estimates, numerical methods and source data can be less precise; the displayed rounding does not remove those limits. It is checked against 4 worked examples whose answers come from independent sources; for example, “Three buys and a 1% risk plan” is checked against Python decimal script: 7285/175 = 41.628571; 175 × 47.10 − 7285 = 957.50; floor(250/2.60) = 96; 6.90/2.60 = 2.653846.

Where does the method come from?

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

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

4 worked examples with independently sourced answers ship with this calculator. They run in the test suite; you can run them here too.

Related calculators

Allow optional Google Analytics to measure page visits? Calculators work either way. Privacy and choices

Optional analytics: off.