Strategy analytics
Valuation
A strategy is a list of legs with signed quantity in lots; size = qty x lot size. P&L at scenario spot S on date t:
pnl(S, t) = sum over legs of size x ( value_leg(S, t) - entry_leg )
- Option leg: model price with remaining time T = (expiry - t)/365 and vol from the vol source (flat or surface) at that strike and remaining time; intrinsic value when T <= 0.
- Futures/stock leg: value = S, entry = given price (or spot).
- Entry: the
premiumif given, otherwise the model price at the as-of date.
"At expiry" means the earliest expiry among the legs. In a calendar spread the far leg is still alive on that date and is priced with surface vol, which is why the payoff has a hump instead of a kink. T+n curves use date min(asof + n days, first expiry).
Breakevens and max profit/loss
The P&L is sampled on a grid from 0 to 5x the largest of spot and strikes (2001 points, plus a 2001-point refinement around spot, plus the strikes themselves). Each sign change is refined with Brent's method. Because every strike is in the grid and the expiry payoff is piecewise linear between strikes, breakevens are exact for same-expiry strategies; for calendars they are numerical.
Max profit/loss are the grid extremes, again exact for piecewise-linear payoffs because S = 0 and all kinks are sampled. Unbounded detection uses the asymptotic slope: the net signed quantity of calls, futures and stock. A positive slope means unlimited profit as S grows, a negative one unlimited loss; puts cannot be unbounded because S >= 0. A calendar with equal calls long and short has zero net slope and is correctly reported as bounded. When the extreme sits on the right edge of the grid (a calendar's loss far out of the money), no location is shown.
Worked example, bull call spread long 24500C at 505, short 24800C at 360: debit 145, max profit 300 - 145 = 155 for S >= 24800, max loss -145 for S <= 24500, breakeven 24500 + 145 = 24645. These hand calculations are tests.
Probability of profit and expected value
The terminal price at the evaluation date is lognormal:
ln S_T ~ Normal( ln S + (mu - sigma^2/2) T, sigma^2 T )
mu is r - q (risk-neutral) unless --drift supplies a real-world drift; sigma is the model vol at spot for that expiry unless --pop-vol is given.
Probability of profit is exact given the breakevens: the breakevens split [0, inf) into intervals, one probe point per interval decides the sign of the P&L, and the CDF mass of the winning intervals is summed. Example, the iron condor with breakevens 24169.92 and 25130.08 at 14.81% vol and 5.2% drift wins in the band between them (31.1%): the lognormal mass inside [24170, 25130] with T = 39/365.
Expected value integrates pnl against the lognormal density on 2001 points over +-8 standard deviations in z. Check used in the tests: for a single European call priced at the same flat vol, the risk-neutral expectation of the P&L is cost x (e^{rT} - 1) (the payoff is worth cost x e^{rT} at expiry on average); the integrator reproduces it to 0.02 currency units. With skew in the vol source the expected value can differ from that figure, because the legs are priced at their own strike vols while the distribution uses one vol.
Probability of profit is tested against a 400,000 path Monte Carlo of the same distribution within four standard errors.
Margin estimate
A simplified SPAN risk array: reprice the position one day ahead over a grid of 7 price moves from -x% to +x% (default 8%) crossed with 3 vol shifts (-y, 0, +y, default 4 vol points), compare with today's mark and take the worst loss. Reported with the scenario that caused it. Differences from exchange SPAN: SPAN uses 16 scenarios with fractions of the range, a short option minimum charge, inter-month spread credits and exposure margin on top, and exchanges publish their own scan ranges. Treat the result as a relative risk gauge (a short straddle needs more than an iron condor; a future needs lot x spot x x%), not a broker margin. For one future the scan returns exactly lot x spot x range, which is a test.
Risk matrix
Rows are spots from -span to +span around spot (default +-6%, 13 rows), columns are T+n dates plus expiry, cells are P&L in currency. Vol is held at the surface value for each strike (sticky strike), so the table isolates spot and time.
Chart and export
The terminal chart resamples the P&L onto 72 columns, fills the expiry curve between zero and its value (green profit, red loss), overlays T+n curves as markers, marks the spot with a dotted column and breakevens with triangles. The SVG draws the same curves with filled profit/loss areas clipped at the zero line; the HTML report embeds the SVG with the summary and matrix.