Methodology

The calculation below corresponds to the active Calculator.tsx implementation. Display values are rounded; calculations use JavaScript floating-point numbers without intermediate rounding. Finite inputs can still overflow derived arithmetic. The calculator rejects non-finite derived values with a validation error rather than displaying them as estimates.

Exact calculation

Let I be investment (initial margin), L leverage, E entry price, T target price, f fee percent / 100 and p enabled payback percent / 100 (otherwise 0). Position value N = I × L; units Q = N / E; closing value C = Q × T. Gross PnL is C − N for long or N − C for short. Entry fee = N × f; exit fee = C × f; gross fees = entry fee + exit fee; payback = gross fees × p; total fees = gross fees − payback. Net PnL = gross PnL − total fees; ROI = net PnL / I × 100%; final equity = I + net PnL.

Worked examples

For a long trade with E = $50,000, T = $55,000, I = $1,000, L = 10 and fee = 0.075%: N = $10,000, Q = 0.2, C = $11,000, gross PnL = $1,000, entry fee = $7.50, exit fee = $8.25, total fees = $15.75, net PnL = $984.25, ROI = 98.425% (displayed 98.43%) and final equity = $1,984.25. With 20% payback, fees become $12.60 and net PnL becomes $987.40. A short to $45,000 gives gross PnL $1,000, fees $14.25 and net PnL $985.75. A flat $50,000 exit gives gross PnL $0 and net PnL −$15.

Validation and reset

Derived position values, quantities, fees, PnL, ROI and equity must also remain finite. Entry, target, leverage and investment must be finite and greater than zero. Fee must be finite and nonnegative; no maximum fee or leverage is imposed. Enabled payback must be between 0% and 100%. Entry and target start blank. If both are blank, no result or error is shown; once either is entered, all required fields are checked. Reset restores blank prices, 10× leverage, $1,000 investment and 0.075% fee, disables payback and retains the selected direction.

Limitations

This is a linear USD-denominated model with fixed units and exact entry and exit prices, not an exchange settlement engine. Funding, slippage, taxes, inverse contracts, maintenance margin and exchange-specific rules are not modeled. Final equity may be negative; no exchange loss cap is applied. Payback is a hypothetical reduction of both trading fees, not a guaranteed rebate. This is information, not financial advice.