← Back to the workbench
TRANSPARENT BY DESIGN

The model behind
the numbers.

A deterministic model of hypothetical positions. Every leg uses the same pricing, funding and margin engine; examples do not contain precomputed results.

Contracts, currencies & units

Each analysis contains one underlying asset (BTC or ETH). Linear analyses can combine long spot and long or short perpetuals quoted and settled in USD, USDT or USDC. A user-defined, fixed USD-per-quote conversion is applied at entry and exit; stablecoins are not silently equated to USD. Inverse analyses support USD-quoted, coin-settled perpetuals alone (including multiple legs), or one nonzero separately held spot long with one nonzero inverse long or short. Mixed analyses allow no additional nonzero legs; zero-size legs are ignored for eligibility. Linear and inverse perpetuals cannot share an analysis. Spot settles in USD; inverse P&L, funding and fees settle in the underlying coin.

Let q be quantity × multiplier, s be +1 for a long or −1 for a short, E be reference entry price and P be closing reference mark. In inverse contracts, q is USD contract notional, not coin quantity.

Linear reference-price P&L = s × q × (P − E)
Inverse price P&L in coin = s × q × (1/E − 1/P)

Spot long P&L is q × (closing spot − entry spot). Changing leverage alone never multiplies price P&L. Price P&L is unrealized while a position is open; the workbench reports a projected full close at the horizon, or at an earlier observed margin breach. No actual trade is executed.

Funding & deterministic time

All horizons are elapsed hours. A day is 24 hours and the simple annualization year is 365 days. The first funding payment is at one complete interval after hour 0. Funding occurs at each complete interval up to and including the horizon, before voluntary closing. There is no prorating and no compounding.

Linear funding cash flow = −s × q × mark × rate
Inverse funding cash flow in coin = −s × q / mark × rate
Simple annualized rate = interval rate × 8,760 / interval hours

Positive cash flow means received. In the flat scenario, prices jump to the entered scenario levels at hour 0 and remain constant. A custom path holds each observation's spot, mark and rate forward until the next observation. At a coincident observation and funding time, update prices, check margin, apply funding to surviving positions, then check margin again. Opening fees and linear entry execution drag affect equity before all events; funding always uses the unadjusted mark.

Rates are inputs, independent of basis. Variable paths are not annualized. The ledger shows individual payments and cumulative cash flows. A discrete path cannot prove that liquidation was avoided between observations.

Isolated margin & estimated liquidation

Each perpetual has a separate collateral allocation. At entry, collateral after opening fees and entry execution drag must cover reference entry notional divided by selected leverage, and independently exceed maintenance plus all modeled closing costs. Entry notional is q × E for linear contracts or q / E in coin for inverse contracts. A leg that cannot open is explicitly excluded from portfolio results.

Equity = collateral − opening fee − entry execution drag + reference-price P&L + cumulative funding
Liquidation condition: equity ≤ mark-based maintenance + modeled closing-cost reserve

Maintenance uses current mark notional (q × P for linear, q / P for inverse). Linear closing reserve = exit execution drag + fee on the modeled exit fill. This is reserved while open and charged once at closing. Let d be the exit adverse fraction, f the effective exit fee rate, C = collateral − opening fee − entry drag + accrued funding, and m = maintenance rate + d + f × (1 − s × d). For inverse positions, entry drag is zero and m remains maintenance rate + custom closing fee rate. With funding frozen:

Linear threshold = (s × q × E − C) / [q × (s − m)]
Inverse threshold = q × (s + m) / (C + s × q / E)

A nonfinite or nonpositive solution is reported as no positive threshold. At a sampled breach, the linear derivative closes at the adverse modeled fill around that observation's mark (inverse positions still close at the mark), incurs the closing fee and stops accruing derivative P&L or funding. A price gap can create a negative balance; this model does not invent an insurance recovery or cap losses. A spot position continues separately.

Thresholds are estimates under these simplified assumptions, not exchange-exact prices. The model excludes cross margin, portfolio margin, risk tiers, liquidation penalties beyond the closing fee, insurance funds, automatic deleveraging and venue-specific waterfalls. No spot-to-margin transfers occur.

Basis, attribution & hedge effectiveness

Basis = perpetual mark − spot/index
Percentage basis = basis / spot/index × 100
Hedge ratio = −signed perpetual units / spot units
Exposure offset = 1 − |net units| / gross units

For surviving linear legs, basis contribution is signed perpetual quantity times the change in (perpetual − spot). Every perpetual entry uses the common entry spot reference; individual spot reference entry prices remain separate. Residual price contribution is total reference-price P&L less basis contribution, so the two reconcile exactly. Attribution is suppressed after a liquidation and for inverse analyses; linear hedge ratios do not describe inverse collateral exposure.

Initial hedge ratio uses positions successfully opened at entry; remaining hedge ratio and residual exposure reflect surviving positions immediately before the horizon close. Rejected and zero-size positions are excluded. A spot hedge ratio is undefined without spot holdings. Perpetuals have no expiration date and their basis is not guaranteed to converge. Basis can widen, funding can reverse, fees can outweigh receipts, and margin requirements can render a hedge infeasible.

Inverse hedge exposure

Spot inventory Q (quantity × multiplier) and posted inverse collateral C are distinct funded balances. Spot quantity excludes collateral, and collateral is not automatically deducted from spot. If you own one coin and post part as collateral, enter only the remaining separately held amount as spot. No spot-to-margin transfer or collateral-purchase transaction is simulated. The common entry spot reference values posted coin collateral in USD.

Let D be inverse USD contract notional (contracts × USD-per-contract multiplier), s be +1 for long or −1 for short, E the inverse entry mark, M the current mark, and B the account coin equity. Immediately before voluntary horizon closing:

B = C − opening coin fee + s × D × (1/E − 1/M) + settled coin funding
Joint USD sensitivity per $1 spot move = Q + B + s × D/M
Inverse exposure-offset hedge ratio = −s × D/M / (Q + B), only when Q + B > 0

Sensitivity has units of underlying coin. Spot and mark move proportionally with percentage basis fixed and settled cash flows frozen. Surviving equity B is before projected closing fees. These local metrics exclude future funding and projected exit costs. Initial metrics use successfully opened positions at entry, mark E and collateral after opening fees; rejected and zero-size positions contribute nothing. Ratios with nonpositive denominators are undefined, while signed exposures remain meaningful. Inverse-only multi-leg exposure sums account balances and each live contract contribution.

After liquidation, the live contract contribution is zero and B is the retained coin balance after the actual closing fee, including negative balances. Remaining exposure is Q + B. Derivative P&L and funding stop at liquidation, but retained coin still revalues until the horizon. Spot continues separately. Rejected inverse entry means the requested hedge was never established, even if spot alone profits.

Joint-move neutrality does not remove basis risk: spot and mark can move independently. Coin collateral, settled funding and fees contribute to USD exposure. Matching inverse USD notional to separate spot value alone does not generally neutralize the funded portfolio. For example, with 1 BTC spot, 0.2 BTC additional collateral, entry spot and mark $50,000 and zero fees/funding, a $60,000 inverse short has zero initial joint exposure; a $50,000 short leaves 0.2 BTC exposure. No local ratio guarantees survival of a finite scenario. Linear basis attribution, Net carry eligibility, break-even analytics, margin planning and scenario matrices remain unavailable for inverse hedges.

Execution assumptions

For spot longs and linear perpetuals, entry prices and scenario spot/mark prices are reference centers around which hypothetical fills are constructed. An exchange mark is not an executable midpoint quote. Full bid-ask spreads and additional adverse slippage are entered in basis points (1 bp = 0.01%).

Adverse fraction = (full spread bps / 2 + slippage bps) / 10,000
Buy fill = reference × (1 + adverse fraction)
Sell fill = reference × (1 − adverse fraction)
Execution drag = q × |fill − reference|

Fractions are additive, not compounded. Spot and linear longs buy at entry and sell at exit; shorts sell at entry and buy at exit. Entry and exit independently select custom, maker or taker fees. Maker/taker rates are user assumptions shared per leg; each transaction uses exactly one rate. This designation does not guarantee fills or remove spread/slippage. Rates are nonnegative and at most 10%; each spread/slippage input is finite, nonnegative and at most 10,000 bps. Sell-side half-spread plus slippage must be strictly below 10,000 bps; invalid fills are rejected, never clamped.

Execution changes neither the reference path nor mark-based funding and maintenance. Inverse positions retain their existing custom fees, coin settlement and reporting; nondefault execution settings are rejected per inverse leg. A spot leg in inverse mode keeps all spot execution settings and USD accounting.

Capital, fees & reporting

Each linear/spot fee is its single effective rate times actual modeled fill notional; inverse fees retain their custom rate times coin notional at the reference price. Fees cannot be negative; rebates and borrowing are not modeled. Spot capital is actual modeled purchase cost plus opening fee. Perpetual capital is allocated collateral, with the opening fee and entry execution loss affecting that account, never added again to the capital denominator. Collateral transfers and spot purchases are not double-counted as P&L.

Net portfolio P&L = reference-price P&L + funding − opening and closing fees − entry and exit execution drag + inverse collateral revaluation. This equals direct fill-price P&L minus fees plus funding; execution drag is not deducted twice. Return on total capital uses initial spot purchase cost including fees plus all allocated derivative collateral. A zero capital base yields no defined return. Account cash unrelated to these legs is outside the model.

For inverse contracts, all coin flows—including liquidated balances—are retained in coin until the horizon. They are translated at the final spot USD/coin price. Collateral revaluation is collateral coin × (final spot − entry spot). Collateral revaluation applies only to posted inverse collateral. USD spot cash flows are never multiplied by final spot. For a mixed portfolio, initial capital = actual spot purchase cost + spot opening fee + C × entry spot. Final wealth = net spot horizon close proceeds + (C + inverse coin P&L + settled funding − opening fee − closing fee) × final spot. Net USD P&L equals final wealth minus initial capital. Perpetual opening fees are already paid from C and are not added again to capital. Coin and USD breakdowns show these cash flows separately, with collateral revaluation counted once.

Net carry is labeled only for a surviving fully quantity-matched spot-long / linear-short strategy. Basis and residual reference-price attribution remain separate; directional gains in unmatched positions are not pure carry. “Net” includes only modeled fees and execution drag. Borrowing, financing, taxes, transfers, opportunity costs, market impact and liquidity constraints are excluded. Hypothetical fills are not execution guarantees. Inputs are bounded; no intermediate cash flow is rounded. Display rounding does not change calculations.

Local data & model references

The Workbench starts with a default hypothetical example and does not automatically read or write persistent storage. Local save offers Save to this browser, Restore browser save and Delete browser save. Each action accesses only basis-workbench-v1; valid saves from earlier versions remain restorable on request. Saving is a one-shot action: later edits require another Save. Named comparison snapshots stay in React memory for the current page session; loading one does not save it persistently. JSON export/import stays local and does not create or overwrite a browser save. Standalone calculators do not use persistent storage. Imported and restored inputs are strictly validated before calculation, including unknown fields. Version-1 analyses without execution settings explicitly use custom opening/closing rates and zero spread/slippage, preserving prior results; examples, storage and comparison snapshots use the same convention. There are no accounts, wallets, exchange APIs, data subscriptions or backend storage.

Settlement conventions were checked against primary documentation: inverse P&L and funding calculations. These establish units and signs; this workbench does not reproduce that venue's risk system.

Explore the workbench →

Perpetual funding spread strategies

This separate mode has exactly two linear perpetual accounts: long Market A and short Market B, with the same BTC/ETH underlying, quote/settlement currency and fixed USD conversion. Market names are hypothetical labels, not exchange connections. Entry references, scenario marks, funding rates/intervals, effective quantities, collateral, leverage, maintenance and execution assumptions are independent. Both quantities must be positive; unequal quantities form a directional strategy. Rejected entries contribute no capital or P&L and leave an explicit incomplete-strategy warning.

Flat prices jump to each scenario mark at hour zero. Custom paths share up to 24 observation times with separate A/B marks and rates, held forward without interpolation over at most 8,760 hours. The event grid is the union of hour zero, horizon, observations and both funding schedules. Each market settles at positive integer multiples of its own 1–24-hour interval from opening, including exactly at the horizon, without partial intervals or exchange-calendar alignment. Observations apply first, then each open account is checked against its own margin, then due surviving accounts settle funding, then affected accounts are checked again. Simultaneous settlements cannot transfer value between accounts.

Long A price P&L = qA × (closeA − entryA)
Short B price P&L = −qB × (closeB − entryB)
A funding cash flow = −qA × markA × rateA
B funding cash flow = +qB × markB × rateB

Funding uses actual settlement events up to each account's closure. Positive funding means long pays and short receives. Displayed rates retain their own intervals; raw per-interval differences are not a comparable spread. Actual net funding reflects distinct marks, quantities, counts, signs and early closures. Entry costs and actual closing costs are charged once using the existing execution model. At the first sampled margin breach, that account closes and stops subsequent derivative P&L and funding. Signed shortfalls remain; recovery at a later mark cannot reverse the loss. The other account continues independently through the horizon with no transfer, rebalancing or automatic closure.

Cross-market spread = Market B mark − Market A mark
Matched surviving price P&L = q × [entry (B − A) − terminal (B − A)]
Initial signed base exposure = opened qA − opened qB
Remaining exposure = surviving qA − surviving qB

The simplified basis identity is shown only for equal effective quantities with both accounts surviving to the horizon. After liquidation, terminal spread is an informational market observation, not the actual close spread. Remaining exposure is measured immediately before voluntary horizon closure and drops the liquidated contract immediately. Matching quantity does not eliminate basis, funding, cost or liquidation risk; positive combined P&L does not prove establishment or survival.

Initial capital is collateral committed to successfully opened accounts. Perpetual entry fees and execution drag are paid from collateral, not added to the denominator again. Each retained balance equals its committed collateral plus net account P&L; their sum equals final wealth. Net price P&L plus actual funding minus fees and execution drag reconciles to portfolio P&L. The common fixed USD conversion applies once to each amount, and return divides net USD P&L by the full USD capital of both opened accounts. Neither combined equity nor future funding can rescue a deficient isolated account.

Version-2 funding-spread JSON has explicit marketA/marketB objects and separate path marks/rates. Version-1 analyses remain unchanged, including inverse-only multi-leg and spot/inverse hedges. Invalid edits pause results and invalid imports preserve current inputs. Existing single-market sensitivity, break-even analytics, margin planner and matrices are unavailable here because they assume shared market inputs. No inverse or spot spread legs, different assets/currencies, cross margin, transfers, borrowing, resizing, exchange rules or live trading are modeled.

Funding & carry break-even analytics

These calculations support exactly one nonzero linear perpetual, optionally with one spot long in the same underlying and quote currency. Partial hedges are allowed for funding and holding time. Exit-basis thresholds require a spot long and perpetual short with effective quantities matched within a relative tolerance of 1e−10. Zero-size legs are ignored; other nonzero legs, inverse analyses and custom paths are unsupported.

Let A be portfolio reference-price P&L minus effective opening/closing fees and entry/exit execution drag at the fixed scenario prices, N = floor(holding hours / interval hours), q be effective perpetual quantity and s its direction sign. Calculations below use quote currency; fixed quote-to-USD conversion applies to both profit and capital.

Net P&L = A − s × q × mark × N × funding rate
Required funding rate = (target P&L − A) / (−s × q × mark × N)
Target P&L = initial capital × target total return / 100

Initial capital is spot purchase cost plus its opening fee and allocated perpetual collateral, conditional on all required legs opening. Perpetual opening fees are paid from that collateral. The target is total return for the entire holding period, not annualized return. A zero target uses the same calculation as break-even. Negative funding thresholds are permitted. Higher funding improves a short's economic result and reduces a long's. With no settlement, funding cannot change P&L; the interface distinguishes an existing break-even from an unattainable exact target.

Holding time evaluates hour zero first, then complete funding settlements through 8,760 hours. For a negative A and positive payment F, the first economic candidate is ceil(−A/F) payments. No fractional payment is interpolated. Both fees and execution drags are included even at hour zero. Candidate survival is required through the closing settlement, including its post-funding margin check, but not afterward.

Matched hedge net P&L = C + q × (−1 + N × rate − d − f × (1 + d)) × mark
C = spot net P&L after fees and execution + q × perpetual reference entry − perpetual opening fee − perpetual entry drag
Break-even basis = candidate mark − scenario spot

Here d is perpetual exit adverse fraction and f its effective exit fee rate. Changing mark changes perpetual price P&L, funding notional, exit fill, closing fee, execution drag, maintenance and closing reserve. All remain affine under fixed percentage assumptions. The coefficient determines which side of the basis threshold is profitable; it can reverse sign or become flat. A flat relationship distinguishes no unique threshold from no solution. The signed basis distance is threshold basis minus the currently assumed basis, in quote-currency units.

Prices, including a candidate basis mark, apply from hour zero and remain fixed. Holding time is not a forecast of appreciation or basis convergence. Every candidate must satisfy runtime input bounds, open every required nonzero leg, survive the chronological engine and reproduce the target. A rejected perpetual cannot be replaced by a successful spot-only result. Funding candidates are tested independently of liquidation under the currently entered rate. Economic thresholds are not safe margin limits; a blocked exact root does not prove that all profitable outcomes are infeasible. Spot gains never replenish isolated collateral.

Affine coefficients use relative floating-point tolerances. Target verification allows 64 machine epsilons times the number of settlement events plus four, scaled by entry and exit notionals, funding and target cash flows. This accommodates accumulation and cancellation without a fixed cent floor. Calculations retain full precision; displayed thresholds are approximate. The target input lasts for this page session and does not alter saved analyses or JSON.

Margin buffer & liquidation stress planner

The planner selects one nonzero linear perpetual's isolated account, long or short, in USD, USDT or USDC. It reuses the current flat scenario or deterministic path, fixed quote conversion, multiplier, fees, maintenance, interval and horizon. Other accounts and spot gains cannot supply collateral. Inverse planning, transfers, resizing during a trade and exchange-specific tiers are unsupported. Planner reserve and selection are session-only; saved analysis formats are unchanged.

Margin surplus = collateral − opening fee − entry drag + reference-price P&L + cumulative funding − maintenance − modeled closing-cost reserve
Required surplus ≥ additional reserve, and surplus > 0

The additional reserve is a nonnegative absolute amount in settlement currency above maintenance and the modeled closing-cost reserve, not a percentage or transaction cost. Entry equity after opening fees and entry drag must independently cover reference-notional initial margin. The reserve is not added to initial margin. Entry is checked at the entry price separately from the scenario hour-zero mark. Positive-reserve equality is allowed; zero surplus is always a liquidation boundary.

For each checkpoint, let b be opening fee plus entry drag minus reference-price P&L minus cumulative funding plus maintenance and modeled closing-cost reserve, per effective underlying unit. At effective size q and reserve R, collateral must cover q × b + R. Combine the largest such obligation with opening fee plus entry drag plus initial margin at entry. If any binding constraint requires strictly positive surplus with R = 0, this is an excluded boundary, not an attainable minimum.

For b > 0: effective-size boundary = (collateral − R) / b
Entry initial-margin size boundary = collateral / (opening fee per unit + entry drag per unit + reference entry / leverage)
Quantity = effective size / fixed multiplier
Effective entry leverage = entry notional / allocated collateral

Nonpositive b imposes no upper size bound with a nonnegative reserve budget; an unsatisfied zero coefficient is infeasible. Entry maintenance prevents a reserve above available collateral even if later profits would help. Quantity is capped at the schema limit of 1 billion, separately labeled as a model input limit; collateral is capped at 1 trillion settlement units. Zero size is never a successfully opened position. A reduced proposal is a different initial position under the same scenario. Changing selected leverage alone changes entry eligibility but leaves fixed-size, fixed-collateral margin surplus unchanged. Maximum effective leverage is conditional on these scenario and entry constraints.

The forward engine and planner share the same chronological checkpoint generator: apply an observation, check margin, settle complete-interval funding, check margin again. Prices and rates hold forward; flat prices apply from hour zero. Planning exhausts this sequence through the horizon even when the original position liquidates. These hypothetical obligations only derive candidates; actual liquidated balances and funding still stop at the first breach. Later receipts cannot repair an earlier breach.

Every proposed collateral or size must open and survive the existing forward engine, and its full-checkpoint minimum surplus must meet the reserve. Excluded boundaries first use the adjacent IEEE-754 value on the admissible side. If regrouping or accumulated roundoff prevents verification, one bounded correction uses an error budget scaled to cash operations and checkpoint count, followed by re-verification. There is no fixed cent increment or unbounded search. Reserve comparison allows 16 machine epsilons × (checkpoint count including entry + 8) × the sum of collateral, opening fee, entry drag, absolute reference-price P&L, accumulated absolute funding, maintenance/closing reserve and requested reserve. Tolerance never accepts liquidation. Unrepresentable or out-of-bounds candidates remain unavailable. Display rounding does not override strict-boundary qualifiers.

Survival is established only at modeled checkpoints, including entry, hour zero, every observation, before and after funding, and the horizon. Discrete observations do not prove survival between them. Mathematical boundaries are conditional model outputs, not exchange guarantees.

Advanced basis & funding scenario matrices

Funding rate × Exit basis uses funding percentage per configured settlement interval as rows and absolute scenario basis as a percentage of scenario spot as columns. Spot stays at the current scenario spot; mark = spot × (1 + basis / 100). This is an absolute basis, not a change from the current basis. Holding period × Funding rate uses elapsed hours as rows and funding percentage per configured interval as columns, retaining the current scenario spot and mark.

Each cell independently runs the existing chronological engine with flat prices and a constant funding rate from hour zero. Entry references, quantities, multipliers, collateral, leverage, maintenance, execution settings, fees and fixed quote-to-USD conversion are preserved. Candidate marks affect price P&L, funding notional, exit fills, closing costs and margin. Longer horizons imply neither price appreciation nor basis convergence. Only complete funding intervals settle, without prorating or compounding; zero hours includes opening and closing costs.

Matrices require a linear analysis with at least one nonzero linear perpetual and flat assumptions; spot and multiple linear legs are supported. Custom paths are preserved and must be explicitly turned off to use matrices. Inverse analyses retain their existing tools. Each axis has two through seven evenly spaced, unrounded levels (five by default), with at most 49 cells. Invalid basis-derived marks remain visible in their original cells. Configuration or analysis edits require recalculation; selection never applies a scenario to the strategy.

Cells show actual engine net P&L or return on initial capital alongside intact, liquidated, rejected, combined rejection/liquidation, or invalid states. Zero-size legs do not count as failures. Rejected legs contribute nothing to the engine aggregate. Liquidated legs close at the observed breach and stop funding; possible future settlement times are not receipts. Positive aggregate profit does not establish that the requested strategy opened and survived. Undefined returns and suppressed basis attribution remain unavailable. Colors are centered on zero and supplemented by numerical values and explicit status labels.