REST API · JSON-RPC 2.0 · 19 endpoints

Crypto futures calculator API
for exact trading math

Every calculator on TradingCalc is available as a REST API call. Position size, liquidation price, funding cost, PnL — deterministic results from verified formulas. Same inputs always produce the same outputs.

POST https://tradingcalc.io/api/mcp

Why a deterministic calculation API?

For risk-sensitive trading math, approximations fail. LLMs give plausible-looking numbers that change between calls. TradingCalc is the computation layer that AI calls — not AI itself.

Regression-tested

66 Vitest tests run on every deployment. 22 canonical vectors. Every formula traceable to exchange documentation.

Exchange-normalized

Binance, Bybit, OKX, Hyperliquid, KuCoin, MEXC, Aster — fee structures and funding mechanics handled per exchange.

Structured output

JSON-RPC 2.0. Consistent schema. No parsing free-form text. Direct integration into trading bots and agent workflows.

Quickstart — position size API

Calculate position size from account balance and max risk %. No API key required for the free tier.

Request
curl -X POST https://tradingcalc.io/api/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0", "id": 1,
    "method": "tools/call",
    "params": {
      "name": "workflow.run_position_sizing",
      "arguments": {
        "side": "long",
        "entryPrice": 83000,
        "stopLoss": 81000,
        "riskUsdt": 100,
        "leverage": 5
      }
    }
  }'
Response
{
  "result": {
    "sizeBase": 0.04861,
    "sizeQuote": 4034.56,
    "margin": 806.91,
    "stopDistPct": 2.41
  }
}

Liquidation price API

Calculate the exact liquidation price for a futures position. Isolated and cross margin, long and short.

Request
curl -X POST https://tradingcalc.io/api/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer tc_your_key" \
  -d '{
    "jsonrpc": "2.0", "id": 1,
    "method": "tools/call",
    "params": {
      "name": "workflow.run_liquidation_safety",
      "arguments": {
        "side": "long",
        "entryPrice": 83000,
        "leverage": 10,
        "marginType": "isolated"
      }
    }
  }'
Response
{
  "result": {
    "liquidationPrice": 75155.00,
    "liquidationDistPct": 9.45,
    "initialMarginPct": 10.0,
    "maintenanceMarginPct": 0.5
  }
}

API endpoints — full inventory

workflow.run_position_sizingPosition size from account balance and max risk %
workflow.run_liquidation_safetyLiquidation price for long/short with cross or isolated margin
workflow.run_funding_costCumulative funding cost over a holding period
primitive.average_entryAverage entry price after DCA into a position
workflow.run_pnl_planningNet PnL, ROE, fees and gross P&L for a futures trade
workflow.run_breakeven_planningBreak-even price accounting for entry and exit fees
workflow.run_exit_targetExit price required to hit a target PnL or ROE
workflow.run_pre_trade_checkFull pre-trade risk: position size, liquidation, breakeven, funding — one call

Full reference at tradingcalc.io/docs — includes all parameters, response schemas, and error codes.

Authentication

No API key required for free tier usage (20 calls/day). For higher limits, pass your key via Authorization header.

// Free tier — no key required
curl -X POST https://tradingcalc.io/api/mcp \
  -H "Content-Type: application/json" \
  -d '{ "jsonrpc": "2.0", ... }'

// Authenticated — bearer token
curl -X POST https://tradingcalc.io/api/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer tc_your_api_key" \
  -d '{ "jsonrpc": "2.0", ... }'

Pricing

Sandbox
Free
20 calls/day
No signup
Trader
$19/mo
250 credits
Light automation
Builder
$79/mo
5,000 credits
Bots & agents
Team
$249/mo
25,000 credits
Shared infra

Primitive = 1 credit · Workflow = 5 credits · Pre-trade check = 10 credits

Full pricing →

Formula verification

Call system.verify via the API to run all 22 canonical test vectors and confirm every formula is working correctly. Or view the live proof page — it runs the full test suite on every request, no cache.

Get API access

Free tier available with no signup. For higher limits — request a key and get it within 24 hours.