stress_portfolio
Reprice your entire portfolio under simultaneous underlying shocks to reveal the worst-case P&L point and the shock level where it occurs, helping you identify maximum loss scenarios.
Instructions
Reprice the whole portfolio — options, equities, futures — across underlying shocks and return the P&L curve and its trough.
The trough is the primary output: the worst point of the curve and the
shock at which it sits. troughRefined interpolates between grid points
for where the minimum actually falls, and is labelled as interpolated.
The model, returned with every result in assumptions:
all underlyings are shocked by the same percentage at once, which is Risk Navigator's own default assumption. Equity positions can be scaled with
betas; options and futures move one-for-one with their underlying.options are repriced with Black-76 on the shocked forward using IB's implied volatility. Equity options are carried from spot using IB's pvDividend, so both kinds go through one pricer.
P&L is model-price-now against model-price-shocked, so the curve is exactly zero at zero shock by construction. The gap between the local model and IB's own price is reported per position as
modelVsMarketinstead of being folded into the curve. Expect it to be small out of the money and a couple of percent in the money, where IB prices the early exercise that Black-76 has no room for — so the curve understates losses slightly once options go deep in the money.bonds are held flat unless
bond_rate_shift_bpis set; anything this server does not model is held flat and named inwarnings.
Check reconciled before quoting anything. At zero shock the portfolio
is rebuilt from its positions and compared against NetLiquidation; a
residual over 1% returns reconciled: false with the residual attached. A
curve that does not reconcile is missing something, and the number it gives
for the trough is missing it too.
Risk Navigator's own volatility shock model is not published. sticky_strike
is the approximation that corresponds to its default curve, not a
reproduction of it — expect the shape to match and the last few percent
not to.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| betas | No | Per-symbol beta for equity positions, e.g. {'AAPL': 1.2}. Options and futures always move with their own underlying. | |
| shocks | Yes | Underlying moves as fractions: -0.10 is a 10% fall. A range like -0.30 to +0.30 in 0.01 steps is the usual ask. | |
| vol_bump | No | Added to every volatility, in points: 0.05 is +5 points. | |
| vol_mode | No | sticky_strike keeps each strike's current volatility and is what Risk Navigator's default curve does. sticky_moneyness slides the smile with the forward. | sticky_strike |
| fetch_skew | No | Let sticky_moneyness pull neighbouring strikes from IB when the portfolio holds too few to define a smile. Costs extra market data requests. | |
| default_beta | No | ||
| date_offset_days | No | Roll the valuation date forward this many days (time decay). | |
| bond_rate_shift_bp | No | Parallel rate shift in basis points applied to bonds. Zero leaves them unchanged, which is the default. | |
| bond_duration_years | No | Duration assumed for bonds when a rate shift is applied. IB does not publish duration, so this is your input and the result is only as good as it. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||