io.github.SKalinin909/tradingcalc
8 crypto futures calculators: PnL, liquidation, break-even, target exit, risk sizing, funding cost.
- -Reduce response time (currently 2088ms, target <1000ms)
Calculate net PnL, ROE, fees and gross profit/loss for a futures trade.
Calculate the liquidation price for an isolated-margin futures position.
Calculate the break-even exit price that covers all trading fees.
Calculate the correct position size given a maximum risk in USDT and a stop-loss price.
Calculate the total funding cost (or income) for holding a perpetual futures position.
Calculate the weighted average entry price from multiple buy/sell fills.
Calculate the exact exit price needed to hit a target PnL or ROE percentage.
Run a scenario analysis: compute PnL for multiple price-change percentages at once.
Calculate the maximum safe leverage based on account size, max acceptable drawdown, and asset daily volatility. Returns recommended leverage and margin at risk.
Calculate the short perpetual futures position size needed to hedge a spot holding. Returns notional, required margin, and estimated funding cost.
Calculate funding rate arbitrage profit: annualized yield, net profit, and breakeven days for a long/short basis trade across two exchanges.
Composite pre-trade check: given a single trade setup, orchestrates risk_sizer + breakeven + liquidation + funding_cost and returns a structured decision card covering position size, breakeven, funding cost, liquidation safety, and overnight breakeven shift.
Project capital growth from reinvesting perpetual futures funding income. Returns final capital, annualized APY, total earned, and a growth snapshot table.
Run the full test-vector suite against all 12 calculators and return a pass/fail report. Use this to confirm that calculator results are correct before trusting them.
| Timestamp | Status | Latency | Conformance |
|---|---|---|---|
| Apr 3, 2026 | success | 1941.6ms | Pass |
| Apr 3, 2026 | success | 256.1ms | Pass |
| Apr 3, 2026 | success | 516.7ms | Pass |
| Apr 3, 2026 | success | 165.9ms | Pass |
| Apr 3, 2026 | success | 474.3ms | Pass |
| Apr 3, 2026 | success | 210.9ms | Pass |
| Apr 3, 2026 | success | 482.5ms | Pass |
| Apr 3, 2026 | success | 294.9ms | Pass |
| Apr 3, 2026 | success | 2297.3ms | Pass |
| Apr 3, 2026 | success | 1852.8ms | Pass |