# Crypto trading profit, liquidation and staking calculator documentation

Inputs, formulas, assumptions and API/MCP examples for the crypto trading profit, liquidation and staking calculator. Reproduce a calculation and cite its sources.

Canonical calculator: https://klarfort.com/tools/crypto-trading-calculator/
Content updated: 2026-09-07
Assumptions reviewed: 2026-09-07

## Overview
Explore five calculations: long or short trade profit, a simplified liquidation price, position size from a stop-loss budget, staking rewards and APR/APY conversion. Prices and trade cash amounts use US dollars; quantities use coin units.

The liquidation calculation models one isolated linear position. It does not reproduce a specific exchange's rules, and a position-size estimate cannot guarantee the loss at which a trade closes.

## How to use
1. Choose the calculation mode and coin. For a trade, select long or short and enter the relevant prices.
2. Enter the quantity and fees for profit, or isolated margin, leverage and maintenance rate for liquidation.
3. For position size, enter account equity, risk percentage, stop price and leverage. For staking or rate conversion, enter the rate type and compounding frequency.
4. Calculate and check the result unit and assumptions before interpreting the profit, price, coin quantity or percentage.

## Understanding the result
Profit subtracts entry fees, exit fees and net funding cost. A negative funding cost represents a credit. Position size is capped by both the stop-loss budget and equity available for margin plus the entry fee.

Staking results show coins after compounding and the entered fee on positive rewards. APR is a nominal annual rate; APY includes compounding. Neither staking mode nor rate conversion assumes token-price appreciation.

## Questions
### Will the liquidation estimate match my exchange?
Not necessarily. It assumes isolated linear margin and a constant maintenance rate. Exchange tiers, maintenance deductions, inverse contracts, cross collateral, slippage and mark-price differences are excluded.

### Does risk-based position sizing cap my actual trading loss?
No. It sizes against the entered stop price and entry and exit fees, with an available-margin cap. Stops may fill at worse prices, and funding or other execution effects are not included in this sizing calculation.

### What is the difference between staking APR and APY?
APR is converted using the entered number of compounds per year. APY is already an effective annual rate. The staking projection compounds coin units over the duration and deducts the entered fee only from positive rewards.

### Can I use the reference price as an exchange execution price?
The reference is indicative and only fills the entry-price field. Powered by CoinGecko through a KlarFort snapshot, its timestamp records when KlarFort retrieved that snapshot, not an exchange trade or mark-price observation. Enter your own execution, exit and stop prices for the scenario. Manual entry remains available when a quote is missing.

## Default worked example
Net profit or loss: 4,895 USD. Linear position profit after entry fees, exit fees and net funding cost. Assumptions as of 2026-09-07.

## Formula
Linear profit = direction × quantity × (exit − entry) − entry fee − exit fee − funding. Liquidation solves equity = maintenance margin + closing fee.

- Prices and trade amounts are in USD; quantities and staking principal are coin units.
- Liquidation is an estimate for one isolated linear position with constant maintenance rate. It excludes exchange tiers, maintenance deductions, inverse contracts, cross collateral, slippage and mark-price differences.
- Stops may execute at a worse price; position sizing does not guarantee a maximum loss.
- Staking assumes constant rates, fractional compounding, no token-price change, and a fee on positive rewards only.

## Inputs
- symbol: A supported symbol; arithmetic uses the price you enter.; default "BTC"
- mode: Mode; default "profit-loss"
- side: Position direction; default "long"
- entryPrice: Entry price in USD; default 50000
- exitPrice: Exit price in USD; default 55000
- quantity: Coin quantity; default 1
- entryFeePercent: Entry fee (%); default 0.1
- exitFeePercent: Exit or liquidation closing fee (%); default 0.1
- fundingCost: Positive is a payment; negative is a funding credit.; default 0
- margin: Isolated margin in USD; default 1000
- leverage: Leverage multiple; default 10
- maintenanceMarginPercent: Maintenance margin (%); default 0.5
- accountEquity: Account equity in USD; default 10000
- riskPercent: Risk budget (%); default 1
- stopPrice: Stop price in USD; default 45000
- principal: Coins staked; default 100
- annualRate: Annual rate (%); default 5
- rateKind: Annual rate type; default "apr"
- compoundingPeriods: Compounds per year; default 12
- months: Staking duration in months; default 12
- stakingFeePercent: Fee on positive staking rewards (%); default 0

## Interfaces
Input schema: https://klarfort.com/tools/crypto-trading-calculator/schema.json
Worked request and response: https://klarfort.com/tools/crypto-trading-calculator/examples.json
Public table: https://klarfort.com/tools/crypto-trading-calculator/table.json
JSON API: POST https://klarfort.com/tools/api/v1/crypto-trading-calculator
MCP endpoint: POST https://klarfort.com/tools/mcp
MCP tool name: crypto-trading-calculator

## JSON request body
```json
{
  "symbol": "BTC",
  "mode": "profit-loss",
  "side": "long",
  "entryPrice": 50000,
  "exitPrice": 55000,
  "quantity": 1,
  "entryFeePercent": 0.1,
  "exitFeePercent": 0.1,
  "fundingCost": 0,
  "margin": 1000,
  "leverage": 10,
  "maintenanceMarginPercent": 0.5,
  "accountEquity": 10000,
  "riskPercent": 1,
  "stopPrice": 45000,
  "principal": 100,
  "annualRate": 5,
  "rateKind": "apr",
  "compoundingPeriods": 12,
  "months": 12,
  "stakingFeePercent": 0
}
```

## Usage and credit
Free for personal, commercial and any other lawful use with credit to KlarFort at https://klarfort.com/. Third-party data terms still apply.

Computed with KlarFort Calculators, https://klarfort.com/

Place a visible credit near the reused material or in the credits for your work or integration. One clear credit per work or integration is sufficient; no separate credit per API request is required. The credit_url field contains the homepage. The citation_url field is an optional calculator reference. Full permission: https://klarfort.com/tools/docs/license/

## Sources
KlarFort calculation methodology: https://klarfort.com/tools/methodology/ (1)
