API Reference
Deterministic compute for futures trading. Two surfaces: REST /v1/ for direct integration, MCP for AI agents.
Quick start
Request access at tradingcalc.io/request-access — key delivered within 24h. Or use the anonymous sandbox (20 calls/day, no key required).
curl -X POST https://tradingcalc.io/v1/primitives/pnl \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"side": "long",
"entryPrice": 80000,
"exitPrice": 85000,
"size": 0.1
}'{
"request_id": "uuid",
"execution_id": "uuid",
"primitive_id": "pnl",
"primitive_version": "v1.0",
"status": "completed",
"result": {
"gross": 500,
"pnl": 483.5,
"pnlPct": 0.0604,
"fees": 16.5
},
"trust": {
"verification_status": "verified",
"verification_level": 1,
"manifest_id": "..."
}
}Auth & rate limits
All /v1/* endpoints require a Bearer token. Anonymous requests return 401.
Authorization: Bearer tc_<key>| Plan | Requests / day |
|---|---|
| free | 200 |
| trader | 2,500 |
| builder | 50,000 |
| team | 250,000 |
| growth | unlimited |
Every response includes X-RateLimit-Remaining. Exceeded limit → 429 rate_limit_exceeded.
Primitives
Single-calculator calls. 1 credit each. All inputs are user-provided — no live data fetch.
GET https://tradingcalc.io/v1/primitivesPOST /v1/primitives/:primitive_idpnlNet PnL, ROE, fees for a futures tradeliquidationLiquidation price, isolated marginbreakevenBreak-even exit price after feesrisk_sizerPosition size from max-risk USDT + stop-lossfunding_costTotal funding cost over a holding periodaverage_entryWeighted average entry from multiple fillstarget_exitExit price to hit a target PnL or ROEscenarioPnL table across price-change percentagesmax_leverageMax safe leverage from drawdown + volatilitycompound_fundingCapital growth from reinvesting funding incomefunding_arbFunding arbitrage yield across two exchangeshedge_ratioPerp short size to hedge a spot positionFull input schemas: GET /v1/primitives → input_schema per primitive.
Workflows
Orchestrated operations — resolve live market data, apply reference fee schedules, return structured decision output.
POST https://tradingcalc.io/v1/workflows/:workflow_idpnl-planningworkflow.run_pnl_planningbreakeven-planningworkflow.run_breakeven_planningexit-targetworkflow.run_exit_targetscenario-planningworkflow.run_scenario_planningdca-entryworkflow.run_dca_entryscale-outworkflow.run_scale_outliquidation-safetyworkflow.run_liquidation_safetyposition-sizingworkflow.run_position_sizingmax-leverageworkflow.run_max_leveragerisk-rewardworkflow.run_risk_rewardfunding-costworkflow.run_funding_costfunding-arbitrageworkflow.run_funding_arbitragecompound-fundingworkflow.run_compound_fundingfunding-breakevenworkflow.run_funding_breakevencarry-tradeworkflow.run_carry_tradepre-trade-checkworkflow.run_pre_trade_checkcurl -X POST https://tradingcalc.io/v1/workflows/pre-trade-check \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"side": "long",
"entry_price": 80000,
"stop_loss": 78000,
"account_balance": 10000,
"risk_pct": 1,
"leverage": 10,
"exchange": "binance",
"symbol": "BTCUSDT"
}'Response contract
{
"request_id": "uuid",
"execution_id": "uuid",
"primitive_id": "pnl",
"primitive_version": "v1.0",
"status": "completed",
"result": { ... },
"metadata": {
"degraded_mode": false,
"request_surface": "api",
"completed_at": "2026-04-06T00:00:00.000Z"
},
"trust": {
"verification_status": "verified",
"verification_level": 1,
"manifest_id": "cuid or null"
}
}{
"request_id": "uuid",
"execution_id": "uuid",
"workflow_id": "pre-trade-check",
"workflow_version": "v1.0",
"status": "completed",
"result": { ... },
"metadata": {
"executed_class": "integrated_decision",
"degraded_mode": false,
"request_surface": "api",
"completed_at": "2026-04-06T00:00:00.000Z"
},
"trust": {
"verification_status": "verified",
"verification_level": 1,
"manifest_id": "cuid or null"
}
}trust.verification_status — verified (all inputs deterministic) or degraded (live market data used but not validated).
trust.manifest_id — non-null when API key has a workspace. Identifies the immutable execution record.
metadata.degraded_mode — true only for workflows that fetched live market data.
Error codes
| HTTP | error | when |
|---|---|---|
| 401 | unauthorized | Missing or invalid API key |
| 400 | invalid_input | Validation failed — message contains field details |
| 404 | primitive_not_found | Unknown primitive_id |
| 404 | workflow_not_found | Unknown workflow slug |
| 429 | rate_limit_exceeded | Daily quota exhausted — check X-RateLimit-Remaining |
| 502 | upstream_error | Live funding rate fetch failed (pre-trade-check only) |
{
"error": "invalid_input",
"message": "entryPrice: Required; side: Invalid enum value"
}TypeScript SDK
Official SDK — namespaced API, full TypeScript types, zero dependencies. Wraps both /v1/primitives/* and /v1/workflows/* REST endpoints.
npm install tradingcalc-sdkimport { TradingCalcClient } from 'tradingcalc-sdk';
const client = new TradingCalcClient({ apiKey: 'tc_...' });
// All 12 primitives available
const pnl = await client.primitives.pnl({
side: 'long', entryPrice: 80000, exitPrice: 85000, size: 0.1
});
// → { pnl: 483.5, pnlPct: 0.0604, fees: 16.5, gross: 500 }
const liq = await client.primitives.liquidation({
side: 'long', entryPrice: 80000, leverage: 10
});
// → { liqPrice: 72360 }
const sizing = await client.primitives.positionSizer({
side: 'long', entryPrice: 80000, stopLoss: 78000, riskUsdt: 100
});
// → { sizeBase: 0.05, sizeQuote: 4000, margin: 400, stopDistPct: 2.5 }// Risk/Reward analysis — sizing + liquidation + breakeven + P&L at stop/target
const rr = await client.workflows.riskReward({
side: 'long',
entry_price: 80000, stop_loss: 78000, take_profit: 86000,
account_balance: 10000, risk_pct: 1, leverage: 10
});
// → { risk_reward_ratio: 3, verdict: 'strong', pnl_at_stop: -100, pnl_at_target: 300, ... }
// DCA entry — avg price, breakeven, per-level contribution
const dca = await client.workflows.dcaEntry({
side: 'long',
entries: [{ price: 80000, size: 0.1 }, { price: 78000, size: 0.15 }]
});
// → { avg_entry_price: 78800, breakeven_price: 78897, levels: [...] }
// Full pre-trade check with live funding rate
const check = await client.workflows.preTradeCheck({
side: 'long', entry_price: 80000, stop_loss: 78000,
account_balance: 10000, risk_pct: 1, leverage: 10,
funding_rate: 0.0001, hold_hours: 24
});
// → { verdict: 'safe', liquidation_price: ..., breakeven_price: ..., ... }client.primitives.*pnl · liquidation · breakeven · positionSizer · targetExit · averageEntry · scenario · fundingCost · fundingArb · compoundFunding · maxLeverage · hedgeRatioclient.workflows.*pnl · breakeven · targetExit · positionSize · scenario · dcaEntry · scaleOut · liquidation · maxLeverage · riskReward · fundingCost · fundingArb · compoundFunding · fundingBreakeven · carryTrade · preTradeCheckclient.system.*verify()Source: github.com/SKalinin909/tradingcalc-mcp · npm: tradingcalc-sdk
MCP surface
19 MCP tools via Streamable HTTP: 12 calculator tools (namespaced as workflow.run_* or primitive.*) + 6 standalone workflows + system.verify. MCP tool names are shown in the workflow table above.
// ~/.claude/claude_desktop_config.json
{
"mcpServers": {
"tradingcalc": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://tradingcalc.io/api/mcp",
"--header", "Authorization: Bearer YOUR_API_KEY"]
}
}
}{
"tradingcalc": {
"url": "https://tradingcalc.io/api/mcp",
"headers": { "Authorization": "Bearer YOUR_API_KEY" }
}
}curl -X POST https://tradingcalc.io/api/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"jsonrpc": "2.0", "id": 1,
"method": "tools/call",
"params": {
"name": "workflow.run_pnl_planning",
"arguments": { "side": "long", "entryPrice": 80000, "exitPrice": 85000, "size": 0.1 }
}
}'Self-verify all formulas: { "name": "system.verify", "arguments": {} } → 22 canonical vectors, pass/fail. Live proof →
What deterministic computation means and how workflows are built.