Average Buy Price Calculator
CRYPTO SPOT · BUYS AND SELLS · FEES INCLUDED
You bought and sold the same coin several times. What is the real entry price of what you still hold? Enter the trades in order with their fees.
Each line: buy or sell, coins, price, and the fee of that trade in percent (optional, 0 if left out).
Average buy price of what you hold
$53,453.4
1 coins held
Cost basis of the coins held
$53,453.40
Break-even sell price
$53,506.90691
Average before fees
$53,400
Total invested in buys
$64,864.80
Realized profit on sales
+$1,575.60
Fees paid so far
$77.80
A sale takes coins out at your current average, so it never changes the average of what is left; only a later buy does.
How to use the average buy price calculator
- Write your trades in the order they happened, one per line: buy or sell, the coins, the price.
- Add the fee of each trade in percent at the end of the line, or leave it out for no fee.
- Enter the sell fee you expect when you sell the coins you still hold.
- Read the average buy price of what you hold and the break-even sell price.
- Open Show the math to see how the cost basis moved.
Average buy price formula
- Buy: cost += quantity × price × (1 + fee); held += quantity
- Sell: cost basis removed = quantity × cost / held; held −= quantity
- Realized profit += quantity × price × (1 − fee) − cost basis removed
- Average buy price = cost / held
- Break-even sell price = average buy price / (1 − sell fee)
Where to go next
Equal buys at a list of prices? Use the Crypto DCA Calculator. Where should you sell to make a target return? Try the Target Sell Price Calculator, or see the result of a finished trade in the Crypto Profit Calculator.
Use via API or MCP
The same calculation is available as the MCP tool workflow.run_average_buy_price: a portfolio tracker, a tax-prep script or an AI agent gets the exact average price, with every step reproducible from the formulas above.
EMBED ON YOUR SITE
<!-- TradingCalc widget: please keep the link below exactly as given (address and words) --> <div class="tradingcalc-widget" data-widget="average-buy-price-calculator"><a href="https://tradingcalc.io/average-buy-price-calculator?utm_source=embed&utm_medium=backlink&utm_campaign=average-buy-price-calculator">Average Buy Price Calculator by TradingCalc.io</a></div> <script async src="https://tradingcalc.io/embed.js"></script>
Free, no signup. Keep the text link in the code exactly as given, with its address and its words: it is the attribution and it points visitors to the full calculator. Change colors, size and start values or read the installation guide and FAQ.
What assumptions and edge cases does this calculator use?
Trades are read in the order you list them, 1 to 1000 lines, each as buy or sell, coins, price and an optional fee in percent (0 if left out, at most 5%). The buy fee is part of the cost basis; a sale removes coins at the current average and never changes it. Selling everything resets the average, and the next buy starts a new one; with nothing held the average and break-even show as not available. A sale before any buy, or of more than you hold at that point, is an error naming the line. A sale within 1e-12 of the largest holding since the position was last flat counts as selling everything, which absorbs float noise such as 0.1 + 0.2 - 0.3. Realized profit can be negative. Prices can be in any currency and results come back in it. Not covered: taxes, FIFO or LIFO lots (this is a moving average cost only), slippage, withdrawal or network fees, currency conversion, leverage and funding.
How do I calculate my average buy price after selling some coins?
A sale takes coins out at your current average cost, so the average of what is left does not change. Only a later buy changes it. If you hold 2 coins at an average of $150 and sell 1, you still hold 1 coin at $150.
Is the buy fee part of the average?
Yes. The average buy price shown is the cost per coin with the buy fee in it; the average before fees is shown beside it.
What happens when I sell everything?
The average resets. Nothing is held, the profit is realized, and the next buy starts a new average.
What if I sell more than I hold?
That is an error, and the message names the trade where the holding runs out, so a typo in a quantity is easy to find.
How is this different from the DCA calculator?
The DCA calculator takes equal cash amounts at a list of prices. This one takes any buys and sells, each with its own size and fee.