Trading math cheat sheet: 8 formulas behind crypto calculators
Every trading calculator is a few lines of arithmetic. Here are the eight that come up most, each with a worked example and the thing it does not tell you.
1. Position size from risk
How much to buy so that hitting your stop loses a set share of the account.
risk amount = account x risk % / 100 loss per coin = |entry - stop| quantity = risk amount / loss per coin position value = quantity x entry
Example: account 1,000, risk 1%, entry 0.50, stop 0.45. Risk amount 10, loss per coin 0.05, so 200 coins worth 100.
Limit: it assumes you exit exactly at the stop. On a thin market the price can jump past it.
Calculator: position size calculator. Code walkthrough: position sizing in TypeScript.
2. Liquidation price with leverage
The price at which the margin left equals the maintenance margin. For an isolated position, with m the maintenance margin rate:
long: liquidation = entry x (1 - 1 / leverage) / (1 - m) short: liquidation = entry x (1 + 1 / leverage) / (1 + m)
Example: long, entry 2, 10x leverage, m = 0.5%. Liquidation is about 1.809, less than 10% below the entry.
Limit: exchanges add fees, funding and their own rounding, so the real price is usually a little closer to the entry.
Calculator: leverage and liquidation calculator. Code walkthrough: the math behind a liquidation price.
3. Average price from several buys
average price = total spent / total coins
Example: 100 at 1.00, then 100 at 0.50. That is 300 coins for 200, so the average is about 0.667, not 0.75. The mean of the two prices is wrong because each buy got a different number of coins.
Limit: the average price is also your break-even price, but only before selling fees and slippage.
Calculator: dca and average price calculator. Code walkthrough: average price from a list of buys.
4. Profit with fees
coins bought = amount x (1 - fee) / buy price value at sell = coins bought x sell price x (1 - fee) profit = value at sell - amount return = profit / amount
Example: 100 in at 0.50, out at 0.75, 1% fee on each trade. 198 coins, 147.02 at the sell, profit 47.02, a return of about 47% instead of the 50% the prices alone suggest. With these fees the break-even sell price is about 0.510, not 0.50.
Limit: network costs and slippage come on top unless you include them in the fee.
Calculator: crypto profit calculator.
5. Break-even win rate
How often a setup has to win just to break even, from its entry, stop and target.
win = |target - entry| - fee loss = |entry - stop| + fee R = win / loss break-even win rate = 1 / (1 + R)
Example: entry 0.50, stop 0.45, target 0.65. Without fees R = 3 and the break-even rate is 25%. With 1% round-trip fees it is 27.5%. The same 3 to 1 shape with a tight stop (0.49 and 0.53) needs 37.5%: fees hurt most when the stop is close.
Limit: it says nothing about your real win rate, which only a long trade history can measure.
Calculator: copy trading calculator. Code walkthrough: break-even win rate with fees.
6. Perp funding cost
funding paid = position value x hourly rate x hours annualized rate = hourly rate x 24 x 365
Example: a 10,000 long at 0.01% per hour pays about 24 a day. That rate is 87.6% a year. At 10x leverage it is about 2.4% of your margin every day, because funding is paid on the full position, not on the margin.
Limit: the rate changes every hour. With a rate history, add up each hour instead of multiplying.
Calculator: Hyperliquid funding rate calculator. Code walkthrough: what perp funding really costs you.
7. Market cap and a target cap
market cap = price x supply multiple = target cap / market cap today bag at target = bag today x multiple / (1 + supply growth)
Example: a bag worth 200 in a coin at a 2 million market cap. At 50 million that is 25x, so 5,000. If 10% more tokens are issued first, it is about 4,545.
Limit: market cap is not money you can take out. Selling moves the price, and most memecoins never reach a large cap.
Calculator: memecoin market cap calculator. Code walkthrough: what a target cap really implies.
8. Realized and unrealized PnL
realized = what sells brought in - cost of the coins sold unrealized = coins held x current price - cost of the coins held total = realized + unrealized
Example: buy 1,000 at 0.10 and 1,000 at 0.20, sell 1,500 at 0.25, with small fees. Valued at 0.12, the total is 128.25 with either method. The realized part is 144 with average cost and 169.25 with first in, first out, because the methods disagree on which coins were sold.
Limit: realized PnL alone can look good while the account is down. Selling winners and holding losers does exactly that, so look at open positions too.
Tool: crypto wallet tracker (realized PnL and open positions of public traders). Code walkthrough: realized and unrealized PnL from a list of trades.