LIVE, NO CACHE, EVERY REQUEST

Verified futures calculations
for deterministic workflows

Every formula is traceable. Every output is regression-tested. This page runs live on every request.

36 passed · 36 total vectors · checked live at Wed, 09 Sep 2026 00:54:58 GMT
01WHAT IS THIS

Every calculator on TradingCalc runs against a set of canonical test vectors: exact input/output pairs derived step-by-step from the underlying formulas. This page executes all vectors in real time on each request (no cache) and reports the result.

The vectors cover all 12 calculators: PnL, Liquidation, Breakeven, Risk Sizer, Funding Cost, Average Entry, Target Exit, Scenario, Max Leverage, Hedge Ratio, Funding Arb, and Compound Funding.

The same vectors are also available to AI agents via the verify_calculators MCP tool at tradingcalc.io/api/mcp.

02FORMULA ASSUMPTIONS
pnlFees applied on notional at entry and exit. Gross = (exitPrice − entryPrice) × size for long.
breakevenBreak-even solved analytically: price where PnL = 0 after both fees.
target_exitExit price solved for target PnL or ROE, accounting for entry and exit fees.
position_sizerPosition size = (balance × riskPct) / (entryPrice × stopDistancePct).
average_entryWeighted average of entry prices by position size.
scenarioPnL computed per price target using same formula as pnl tool.
liquidationIsolated margin: liqPrice = entryPrice × (1 − 1/leverage + maintenanceMarginRate) for long. Cross margin uses total account equity.
max_leverageMax leverage = 1 / (stopDistancePct + maintenanceMarginRate + feePct).
hedge_ratioHedge size = spotSize × (spotPrice / perpPrice). Funding cost applied over holding period.
funding_costCost = positionSize × entryPrice × fundingRate × periods.
funding_arbAnnualized yield = (rateA − rateB) × periodsPerYear.
compound_fundingIterative: each period cost reduces position size.
pre_trade_checkComposite: orchestrates risk_sizer + breakeven + liquidation + funding_cost. Safety = liqDistance / stopDistance ratio (danger <1.5x, warn <3x). Summaries generated in Russian.
03TEST VECTORS
#CALCULATORTEST CASESTATUS
1pnlBTC long +10%: gross=500, fees=3.75, pnl=496.25PASS
2pnlETH short −10%: gross=300, fees=1.95, pnl=298.05PASS
3pnlZero fees: pnl equals gross exactlyPASS
4pnlInverse (coin-margined) long, $1M contracts: gross=100 BTC, fees=0.3 BTC, pnl=99.7 BTCPASS
5pnlInverse short, price falls 20%, zero fees: gross=0.25 BTCPASS
6liquidationBTC long 10x: liqPrice=45250 (Binance isolated-margin formula)PASS
7liquidationBTC short 10x: liqPrice=54750PASS
8liquidationInverse long 10x: liqPrice≈45662.1005 (Bybit inverse isolated-margin formula)PASS
9liquidationInverse short 10x: liqPrice≈55248.6188PASS
10breakevenLong with standard exchange fees: breakeven≈100.0700PASS
11breakevenZero fees: breakeven=entry, totalFees=0, distance=0PASS
12breakevenInverse long, $1M contracts: BE≈100.3003 (mirrors linear short formula)PASS
13breakevenInverse short, $1M contracts: BE≈99.7003PASS
14risk_sizerLong, 5% stop, $10 risk: stopDistPct=5, sizeBase≈1.9734PASS
15risk_sizerInverse long, 5% stop, $1000 risk: sizeQuote=19000 USD contractsPASS
16risk_sizerInverse short, 5% stop, $1000 risk: sizeQuote=21000 USD contractsPASS
17funding_costLong, 0.01% per 8h, 7 days: totalCost=0.21, annualPct=10.95PASS
18funding_costShort receives when rate is positive: totalCost=−0.03PASS
19funding_costInverse long, $1M contracts, 0.01%/8h, 7 days: totalCost=21 coin, breakevenShift≈0.2104PASS
20average_entryWeighted average: (100×1+200×3)/4=175PASS
21average_entryInverse (coin-margined): two equal-USD fills at 2000 and 4000 average to the harmonic mean 2666.67, not the arithmetic mean 3000PASS
22target_exitTarget pnl=0 → net pnl is zero (round-trip breakeven)PASS
23target_exitLong target $10 PnL no fees: pnl≈10, exit above entryPASS
24target_exitInverse long, $1M contracts, target 50 coin PnL, zero fees: exitPrice≈100.5025PASS
25target_exitInverse short, $1M contracts, target 50% ROE, zero fees: exitPrice≈95.2381PASS
26scenarioLong +10% no fees: scenarios[0].pnl=10PASS
27scenarioInverse long +25%, $1M contracts, no fees: scenarios[0].gross=100 coinPASS
28max_leverage10k acct, 10% max drawdown, 3% vol: maxLev=2.8x, safeMargin=3500PASS
29max_leverageExtreme volatility: leverage is always ≥1 (floored)PASS
30hedge_ratioFull hedge 2x: perpNotional=10000, margin=5000, dailyCost=3PASS
31hedge_ratio50% hedge 1x: perpNotional=5000, margin=5000PASS
32funding_arb0.02% net rate 30d: gross=180, net=170, APY=21.9%PASS
33funding_arbHyperliquid 1h interval: 24 periods/dayPASS
34compound_funding1000 USDT, 0.01%/8h, 1 day, 100% reinvest: finalCapital≈1000.3003PASS
35compound_fundingreinvestPct=0: capital unchanged, totalEarned=0PASS
36pre_trade_checkBTC long 10x, 5% SL, 1% risk, 0.01%/8h funding: size=0.04, liqDist=9.5%, safety=warnPASS
04ERROR MODEL
INVALID_INPUT

A required parameter is missing, out of range, or the wrong type.

OUT_OF_DOMAIN

Inputs are valid but the combination produces a mathematically undefined result (e.g. liquidation price below zero).

UNSUPPORTED_COMBINATION

The requested exchange / margin type / side combination is not supported by the formula.

RATE_LIMITED

The caller has exceeded the call quota for their tier. Retry after the window resets.

AUTH_REQUIRED

The endpoint requires a valid API key. Anonymous quota exhausted.

INTERNAL_ERROR

Unexpected server-side error. The formula did not execute. Safe to retry.

05VERSION HISTORY
v1.3.0 · 2026-09-08
  • Added: contractType ('linear' | 'inverse') on pnl, liquidation, average_entry, breakeven, target_exit, scenario, risk_sizer, funding_cost
  • Inverse (coin-margined) contracts settle in the base coin and use reciprocal price math — average_entry's inverse average is the harmonic mean of fill prices, not arithmetic
  • Verification: 35 canonical test vectors (was 23)
v1.2.1 · 2026-03-31
  • Changed: pre_trade_check output now includes summary_a/b/c: human-readable Russian decision strings
  • summary_a: position size, breakeven price, funding cost per 24h
  • summary_b: liquidation distance ratio with safety verdict (ok/warn/danger)
  • summary_c: overnight breakeven shift over hold_hours
v1.2.0 · 2026-03-31
  • Added: pre_trade_check, a composite intent tool (orchestrates risk_sizer + breakeven + liquidation + funding_cost)
  • Returns decision card: position size, breakeven, funding cost, liquidation safety, overnight breakeven shift
  • Verification: 23 canonical test vectors (was 22)
v1.1.0 · 2026-03-30
  • Added: max_leverage, hedge_ratio, funding_arb, compound_funding
  • Changed: tool grouping into 3 canonical suites (Trade Planning / Risk & Margin / Funding & Carry)
  • Verification: 22 canonical test vectors (was 12)
v1.0.0 · 2025-12-01
  • Initial release: pnl, breakeven, target_exit, position_sizer, average_entry, scenario, liquidation, funding_cost
  • Verification: 12 canonical test vectors
MCP ENDPOINT: POST /api/mcp · TOOL: verify_calculators · API DOCS