Every slider move triggers a fresh Monte Carlo run. The symbols used below live on the Model page. The desk splits into zero-capital operating books (fee, b2b, retained, switching) plus an active treasury at \((k, C_{\mathrm{basis}})\), and the desk P&L on each sample path is the sample-by-sample sum of operating and treasury. The price process is compensated Merton, and setting \(\lambda_J = 0\) recovers pure GBM.
viewof barrierRatioSlider = Inputs.range([0,10], {step:0.01,value:1.25,label:"threshold h = H/S₀",transform: x =>Math.log(x +1e-3),invert: y =>Math.max(0,Math.exp(y) -1e-3),})
The cards below show the derived quantities that the Monte Carlo consumes. They are computed from the sidebar inputs and include \(S_0 = \pi_0 / P\), the horizon \(T\) in years, the total tonnes retired \(N = \lambda T\), the coverage fraction \(\alpha = \min(1, k / (N P))\), the inventory-exhaustion time \(\tau_{\mathrm{cov}} = \min(T, k / (P \lambda))\) (shown as “inventory runs out at” in days), and the break-even quote \(Q^* = (1 + f) P S_0 (e^{\mu T} - 1) / (\mu T)\).
The implied basis per token is \(C_{\mathrm{basis}} / k\). When it sits above \(S_0\) the inventory carries an unrealised loss; when it sits below \(S_0\) it carries an unrealised gain. Either way the shape of the custom book’s P&L is unchanged and only its location moves.
The summary cards, the table, the histograms, and the sample paths below refresh on every slider change; a 5,000–10,000-path run finishes in under a second. Under the Merton compensation the mean rule on each histogram holds its position while SD, VaR, and CVaR widen with the jump sliders. The “premium \(\pi_{\mathrm{syn}}\) received” card reports the up-front syndication premium priced off the b2b book’s moments. At \(\theta = 0\) the premium is actuarially fair and equals \(\beta \, \mathbb{E}[\Pi_{\mathrm{b2b}}]\).
The cards below show the top-line numbers of the current run.
// Composed switching + treasury(k, C_basis) desk; shares seed with run// and switchRun so the sum is path-aligned.switchCustomDesk = {if (!switchOn) returnnull;const n =Math.min(switchRun.pnlSamples.length, run.treasurySamples.length);const samples =newFloat64Array(n);for (let i =0; i < n; i++) { samples[i] = switchRun.pnlSamples[i] + run.treasurySamples[i]; }return { samples,summary:summarise(samples) };}
Enabling switching activates the threshold \(H = h S_0\). The cards below then report the first-passage probability, the mean time in fee mode, and the mean number of crossings per path.
The table below has one row per operating book plus the treasury at \((k, C_{\mathrm{basis}})\) and the derived custom desk \(= b2b +
\text{treasury}\). Each row’s \(\Pi\) is that book’s terminal P&L in USD over \([0, T]\).
P&L is the USD total over \([0, T]\). Divide by \(N = \lambda T\) for a per-tonne figure. As the sliders move, the treasury row opens at MTM \(k \cdot S_0 - C_{\mathrm{basis}}\) and drifts as inventory burns down, so sweeping \(C_{\mathrm{basis}}\) translates its location without changing its shape. The custom-desk row collapses to the matched limit at \(k = N P\) and \(C_{\mathrm{basis}} = N P
S_0\), where \(I_T\) cancels between b2b and treasury consumption and the desk total becomes the deterministic \(N (Q - P S_0)\). At \(k = 0\) the treasury is zero sample by sample and the custom desk collapses onto b2b.
Inputs.table(summaryRows, {columns: ["book","mean","sd","ci95","var95","var99","cvar95","cvar99","probLoss","sharpe"],header: {book:"book",mean:"E[Π] (mc)",sd:"SD",ci95:"±CI95",var95:"VaR95",var99:"VaR99",cvar95:"CVaR95",cvar99:"CVaR99",probLoss:"P[Π<0]",sharpe:"Sharpe", },format: {mean: x => (x >=0?"$":"−$") +Math.abs(x).toFixed(2),sd: x =>"$"+ x.toFixed(2),ci95: x =>"±$"+ x.toFixed(2),var95: x => (x >=0?"$":"−$") +Math.abs(x).toFixed(2),var99: x => (x >=0?"$":"−$") +Math.abs(x).toFixed(2),cvar95: x => (x >=0?"$":"−$") +Math.abs(x).toFixed(2),cvar99: x => (x >=0?"$":"−$") +Math.abs(x).toFixed(2),probLoss: x => x.toFixed(3),sharpe: x => x ===null?"n/a": (x >=0?"":"−") +Math.abs(x).toFixed(3), }})
P&L distributions
The panels below show the empirical terminal-P&L density for each book, one panel per book. The x-axis is terminal P&L in USD and the y-axis is empirical density. The black rule in each panel is the Monte Carlo mean, and the dashed grey rule sits at \(\Pi = 0\). The fee panel is non-negative and the b2b panel is its mirror. The custom-desk panel collapses to a spike at the matched limit.
The chart below shows twenty sampled kVCM trajectories as a function of time, with the first one highlighted in orange and the others in grey. The green dashed rule marks the inventory-exhaustion time \(\alpha T\). If switching is on, a second dashed rule marks the fee-mode threshold \(H = h S_0\). The randomness of the custom desk lives on \([\alpha T, T]\), the region to the right of the green dashed rule.