Stock Average Calculator
Enter each purchase on its own line as shares @ price, such as 10 @ 50. You get the total shares, the total cost and the average cost per share. Add a flat fee for each purchase, and a current price to see the gain or loss. To lower the average, type a target and the price you would buy at, and the calculator gives the shares to buy and the new average. Everything runs in your browser.
You can also write 10 x 50, 10, 50 or 10 50. Fractional shares work, and a line that starts with # is skipped.
Bring the average down to a target (optional)
The average cost per share is the total spent divided by the total shares: the shares of each purchase times its price, added up, plus any fees, over all the shares. The fee box is a flat amount charged on each purchase. To lower the average with a new purchase at a price p, you need a target t between p and the current average A, and with S shares held the shares to buy are S times (A minus t), plus any fee, all over (t minus p). The gain or loss compares the value at the current price with the total cost. Brokers and tax rules may use other methods, such as first in first out or specific shares, so the figure on your tax form can differ. This is arithmetic on the numbers you enter, not advice about what to buy or sell. Everything runs in your browser.
Related Tools
[5 suggestions]Weighted Average Calculator
Find a weighted average from values and weights, see how much each adds, and work out the score you need on the rest to hit a target.
Student ToolsROI Calculator
Work out return on investment as a percentage, with income received, the return multiple and the annualized rate over the time you held it.
Math & MoneyCAGR Calculator
Find the compound annual growth rate between two values, the value after growing at a rate, or the time to reach a target, with the doubling time and rule of 72.
Math & MoneyCapital Gains Tax Calculator
Estimate US federal tax on long-term and short-term capital gains for 2025 and 2026, with the 0%, 15% and 20% rates and the 3.8% investment income tax.
Math & MoneyPercentage Calculator
Find a percentage of a number, what percent one number is of another, a percentage increase or decrease, or a number raised or lowered by a percentage.
Math & MoneyAbout the Stock Average Calculator
The average cost per share is the total spent divided by the total shares. Buy 10 shares at 50 and 20 at 40: that is 500 plus 800, which is 1,300 for 30 shares, an average of 43.33. A flat fee of 5 on each purchase adds 10 and makes it 43.67. At a current price of 45 the 30 shares are worth 1,350, a gain of 50 against the cost, which is 3.85 percent. To bring the average down to a target t by buying at a price p, with S shares held at an average A, you need S times (A minus t), plus any fee, all over (t minus p) more shares. From 30 shares at 43.33, buying at 35 to reach 40 takes 20 shares, which cost 700, and 50 shares then average exactly 40. The target must be below the current average and the buying price below the target, or no number of shares can reach it. Brokers and tax rules may use other methods, such as first in first out or specific lots, so the cost basis on a tax form can differ. This is arithmetic on the numbers you enter and not advice about what to buy or sell.
How do you calculate the average cost per share?▾
Add up the cost of each purchase, which is its shares times its price, and divide by the total shares. 10 shares at 50 and 20 at 40 cost 1,300 for 30 shares, an average of 43.33. Fees can be added to the cost.
How many shares do I need to buy to lower my average?▾
Use the target box. The shares are S times (A minus t) over (t minus p), where S is the shares held, A the average, t the target and p the buying price. From 30 at 43.33, 20 shares at 35 bring it to 40.
Are fees included?▾
Yes, as a flat fee for each purchase that you enter once. It is added to the total cost, which raises the average, and it is also added to the new purchase when you look for the shares to reach a target.
Does this match the cost basis on my tax form?▾
Not always. Brokers may use the average cost, first in first out or specific shares, and tax rules differ by country. Use this for your own tracking and check the method your broker and tax authority use.
Is my data uploaded?▾
No. The calculation runs in your browser and nothing you enter is sent anywhere.