# Hedge unwind: a reproducible position-reduction experiment This original engineering illustration asks: with the same gross notional closed and the same fee, how does the allocation of a closeout change a hedged account's modeled risk? It is a small, deterministic model written for Flying Tulip Inc's engineering library. It uses no private contracts, market dataset or third-party dependency. Its outputs are calculations under stated assumptions, not empirical performance, a benchmark against another protocol, or descriptions of deployed FT behavior. The starting account is healthy under this model; this is not a simulation of a liquidation trigger being breached. ## Reproduce Use Node.js 22 or newer. Download these files from `https://flyingtulipinc.com/evidence/hedge-unwind/` into one directory: `model.mjs`, `verify.mjs`, `README.md`, `results.json`, `results.csv`, and `manifest.json`. ```sh node model.mjs node --test verify.mjs node model.mjs --write node --test verify.mjs ``` The first command prints the complete CSV table. Verification compares fresh calculations with the supplied JSON and CSV and checks every published SHA-256 hash. `--write` regenerates the results and manifest without timestamps or randomness. The manifest excludes itself. Hashes establish artifact consistency, not independent authorship, model validity or an audit. From the repository root, use `node public/evidence/hedge-unwind/model.mjs --write` and `node --test tests/hedge-unwind.test.mjs`. The root test wrapper imports the same downloadable verification file. ## Fixed assumptions - One account has a long linear position of 10 units and a short linear position of 8 units. Both markets are marked at $50,000 per unit. Initial gross notional is $900,000 and directional net notional is $100,000. - Initial marked equity is $100,000. Both legs start with zero unrealized P&L. Positions are contract-equivalent exposures, not purchases of spot inventory or repayment of loan principal. - Marks remain unchanged while positions are reduced. Closing at the mark realizes zero trading P&L. The only immediate equity change is the assumed 10-basis-point fee on closed gross notional. - This fee excludes slippage, spread, gas, funding, interest and changes in prices during execution. Any specified size can fill at the fixed mark; no venue depth, counterparty, transfer or cash-settlement constraint is simulated. - Required margin equals the largest nonnegative loss across the scenario grid, plus an assumed reserve of 1% of remaining gross notional. This reserve is a separate model policy, not an estimate calibrated from the 10-basis-point fee or observed liquidation costs. Financial arithmetic uses BigInt, cents for money and millionths of a unit for position size. Every division must be exact. Inputs requiring fractional cents or finer quantity precision throw an error instead of silently rounding. The published parameters are exactly representable. Floating-point numbers are used only to label small integer configuration values in JSON. ## The frozen scenario grid Let `L` and `S` be positive long and short magnitudes, `P = $50,000`, common return `c`, and per-leg basis offset `b`: ```text long-market return = c + b short-market return = c - b scenario P&L = L * P * (c + b) - S * P * (c - b) stress loss = max(0, -scenario P&L) across all tested scenarios margin requirement = stress loss + 0.01 * P * (L + S) marked equity = 100,000 - 0.001 * closed gross notional margin headroom = marked equity - margin requirement margin shortfall = max(0, -margin headroom) ``` The same grid applies to every allocation: `c` is -25%, -10%, 0%, +10%, or +25%; `b` is -5%, 0%, or +5%. A 5-percentage-point per-leg basis offset creates a 10-percentage-point difference between the two market returns. Thus returns can reach +/-30%. These are 15 deterministic joint scenarios, not 15 independent risks or observations. For this linear book and rectangular symmetric grid, the exact closed form is: ```text stress loss = P * (0.25 * abs(L - S) + 0.05 * (L + S)) ``` The corner scenarios determine the maximum. The verification code independently uses this identity to check the enumerated scenario engine. This bounded grid is not a maximum-possible-loss guarantee and supplies no probability of loss. ## Comparable close budgets The experiment closes 0%, 10%, 25%, 50%, 75%, or 100% of initial gross notional. At each budget it compares: - `proportional`: close the same fraction of each starting leg. - `short-first`: close the short leg first, then the long leg after the short is exhausted. - `long-first`: close the long leg first, then the short leg after the long is exhausted. Every path at a given budget closes identical gross notional, pays identical fees and retains identical gross notional. Only the remaining allocation differs. There are 18 allocation outcomes and 270 scenario evaluations. Repeated zero/full-budget results are included for comparability, not counted as independent evidence. ## Useful outcomes and hand checks Initially, worst modeled loss is $70,000: a $150,000 loss on the long at -30%, offset by an $80,000 gain on the short at -20%. Adding the $9,000 reserve gives $79,000 required margin and $21,000 initial headroom. At the 50% budget, every path closes $450,000 and pays $450, leaving marked equity of $99,550: | Allocation | Remaining long / short | Stress loss | Margin reserve | Required margin | Margin shortfall | | --- | --- | ---: | ---: | ---: | ---: | | Proportional | 5 / 4 | $35,000 | $4,500 | $39,500 | $0 | | Short first | 9 / 0 | $135,000 | $4,500 | $139,500 | $39,950 | | Long first | 1 / 8 | $110,000 | $4,500 | $114,500 | $14,950 | For positive net exposure, the binding corner has common return -25% and per-leg basis offset -5%: long-market return -30%, short-market return -20%. For negative net exposure, it has common return +25% and basis offset -5%: long-market return +20%, short-market return +30%. Each row identifies its binding scenario and includes all scenario P&Ls in JSON. Zero exposure has no binding loss scenario. Proportional closeout is not claimed optimal. At the 10% budget, long-first reduces the starting directional imbalance and requires $51,100 of margin, below proportional's $71,100; short-first requires $96,100. Fees are $90 for each. A rule that simply preserves the original 10:8 ratio can miss a better allocation even in this toy model. At full closeout, all paths have zero remaining exposure, loss, reserve and margin, with $99,100 of equity after $900 of fees. ## Interpretation limits A margin shortfall is a deficiency against this model's requirement, not realized bad debt. `worstScenarioEquityUsd` is marked equity plus P&L at the worst tested scenario, before any additional future closeout cost. The three methods are illustrative allocation rules; the experiment does not solve an optimization problem, price an actual liquidation, simulate intratransaction sequencing, or show that the assumed fills can be executed. The useful result is conditional and narrow: lower gross exposure can leave a larger directional imbalance, raising scenario loss and margin enough to create a model shortfall. Real systems also need justified calibration, stateful execution checks, liquidity and funding constraints, validated oracles, and an operational closeout process. For external context, [Deribit's portfolio-margin documentation](https://support.deribit.com/hc/en-us/articles/25944756247837-Portfolio-Margin) describes scenario-based requirements, and its [margin explainer](https://support.deribit.com/hc/en-us/articles/25944811089565-What-is-margin) explains that reducing a hedged position can raise the requirement on what remains. This experiment does not reproduce Deribit's model or parameters.