Writing
Demo · Delta-neutral

Delta-neutral strategy simulator

Hard problem
A strategy that is delta-neutral on paper drifts out of neutrality as positions fill and prices move. A final PnL number will not tell you which happened — whether the hedge actually held, or whether the direction simply went your way.
Approach
Derive the entire trade ledger from strategy parameters plus market data, and read neutrality off the derived positions instead of asserting it. The timeline is scrubbable and regenerated from rules, so the state of the hedge is visible at every point rather than only at the end.

Long spot + short perp, unit-matched. A pure generator derives the trade ledger step by step: the two price-PnL legs cancel by construction, so net PnL is just the accrued funding — independent of where price goes. Scrub the timeline.

✓ Delta-neutral — max |delta| over the run: 0.00 ETHprice swung 25.67% · net PnL $799.02 (funding) · yield 2.66%
— net PnL (funding)— spot leg- - perp leg
step 28 / 28ETH $3,510.00
Spot leg (long)+$5,100.00
Perp leg (short)$-5,100.00
Δ delta (ETH)0.00
Funding this step$31.59
Funding accrued$799.02
Net PnL$799.02

Trade ledger · derived

StepPriceSpotPerpFundingNet PnL
13,000.000.000.000.000.00
23,080.00800.00-800.0027.7227.72
33,210.002,100.00-2,100.0056.6156.61
43,150.001,500.00-1,500.0084.9684.96
53,320.003,200.00-3,200.00114.84114.84
63,460.004,600.00-4,600.00145.98145.98
73,380.003,800.00-3,800.00176.40176.40
83,520.005,200.00-5,200.00208.08208.08
93,610.006,100.00-6,100.00240.57240.57
103,540.005,400.00-5,400.00272.43272.43
113,390.003,900.00-3,900.00302.94302.94
123,210.002,100.00-2,100.00331.83331.83
133,050.00500.00-500.00359.28359.28
142,960.00-400.00400.00385.92385.92
152,840.00-1,600.001,600.00411.48411.48
162,910.00-900.00900.00437.67437.67
173,040.00400.00-400.00465.03465.03
183,180.001,800.00-1,800.00493.65493.65
193,260.002,600.00-2,600.00522.99522.99
203,190.001,900.00-1,900.00551.70551.70
213,350.003,500.00-3,500.00581.85581.85
223,470.004,700.00-4,700.00613.08613.08
233,560.005,600.00-5,600.00645.12645.12
243,490.004,900.00-4,900.00676.53676.53
253,380.003,800.00-3,800.00706.95706.95
263,300.003,000.00-3,000.00736.65736.65
273,420.004,200.00-4,200.00767.43767.43
283,510.005,100.00-5,100.00799.02799.02