menu
Tutorials

Measures

Measures

A measure is a metric that can be calculated on an instrument, like a dollar price. Below is a table of supported measures and their definitions.

MeasureDefinition
Dollar PricePrice of the instrument in US Dollars
PricePrice of the instrument in the local currency
ForwardPricePrice of the instrument at expiry in the local currency
EqDeltaChange in Dollar Price (USD present value) due to individual $1 moves in the spot price of underlying equity security
EqGammaChange in EqDelta for a $1 shift in the price of the underlying equity security
EqVegaChange in Dollar Price (USD present value) due to individual 1bp moves in the implied volatility of the underlying equity security
FXDeltaDollar Price sensitivity of the instrument to a move in the underlying spot such that dSpot * FXDelta = PnL
FXGammaFXDelta sensitivity of the instrument to a move in the underlying spot such that dSpot * FXGamma = dDelta
FXSpotFX spot reference
FXVegaChange in Dollar Price due to a 1 vol move in the implied volatility of ATM instruments used to build the volatility surface (bucketed)
IRBasisChange in Dollar Price (USD present value) due to individual 1bp moves in the interest rate instruments used to build the basis curve(s) (bucketed)
IRDeltaChange in Dollar Price (USD present value) due to individual 1bp moves in the interest rate instruments used to build the underlying discount curve (bucketed)
IRDeltaParallelChange in Dollar Price (USD present value) due to a parallel 1bp shift in the interest rate instruments used to build the underlying discount curve (scalar)
IRDeltaLocalCcyChange in Price (present value in the denominated currency) due to individual 1bp moves in the interest rate instruments used to build the underlying discount curve (scalar)
IRDeltaParallelLocalCcyChange in Price (present value in the denominated currency) due to a parallel 1bp shift in the interest rate instruments used to build the underlying discount curve (scalar)
IRGammaChange in IRDeltaParallel for a parallel 1bp shift in the interest rate instruments used to build the underlying discount curve (scalar)
IRVegaChange in Dollar Price (USD present value) due to individual 1bp moves in the implied volatility (IRAnnualImpliedVol) of instruments used to build the volatility surface (bucketed)
IRVegaParallelChange in Dollar Price (USD present value) due to a parallel 1bp move in the implied volatility (IRAnnualImpliedVol) of instruments used to build the volatility surface (scalar)
IRVegaLocalCcyChange in Price (present value in the denominated currency) due to individual 1bp moves in the implied volatility (IRAnnualImpliedVol) of instruments used to build the volatility surface (bucketed)
IRVegaParallelLocalCcyChange in Price (present value in the denominated currency) due to a parallel 1bp move in the implied volatility (IRAnnualImpliedVol) of instruments used to build the volatility surface (scalar)
IRAnnualImpliedVolInterest rate annual implied volatility (in percent)
IRAnnualATMImpliedVolInterest rate annual implied at-the-money volatility (in percent)
IRDailyImpliedVolInterest rate daily implied volatility (in basis points)
IRSpotRateInterest rate at-the-money spot rate (in percent)
IRFwdRateInterest rate par rate (in percent)

Calculating Price Measures

Let's price an instrument. For information on how to define an instrument, please refer to the Instruments tutorial.

Note, below we resolve the swaption parameters that will be used to price the swaption, thereby mutating the swaption object. If resolve(), is not called prior to calling price(), the object will be copied and resolved on the fly without mutating the original swaption object. The preferred behavior may depend on the PricingContext - more on this in the Pricing Context guide.

price() method will return price in the local currency.

IR Swaps

from gs_quant.instrument import IRSwap
from gs_quant.common import PayReceive, Currency
# Creating Swaps - spot starting, forward starting
swap = IRSwap(PayReceive.Receive, '10y', 'GBP', fixed_rate='atm+50', notional_amount=1e8)  # running
swap_fwd_start = IRSwap(PayReceive.Pay, '5y', 'EUR', fixed_rate='atm+20', effective_date='3y')  # fwd starting
# View Instrument w/ specified relative parameters
swap_fwd_start.as_dict()

Output:

{'asset_class': Rates,
 'fee': 0,
 'termination_date': '5y',
 'fixed_rate': 'atm+20',
 'pay_or_receive': Pay,
 'notional_currency': EUR,
 'type': Swap,
 'effective_date': '3y'}
# Resolve Instrument, View fixed parameters
swap_fwd_start.resolve()
swap_fwd_start.as_dict()

Output:

{'fixed_rate_day_count_fraction': 30/360,
 'principal_exchange': None,
 'fixed_rate_frequency': '1y',
 'notional_amount': 100000000.0,
 'roll_convention': 'Default',
 'floating_rate_business_day_convention': Modified Following,
 'fee_payment_date': datetime.date(2020, 10, 29),
 'floating_rate_designated_maturity': '6m',
 'fixed_last_stub': datetime.date(2028, 10, 30),
 'asset_class': Rates,
 'fixed_first_stub': datetime.date(2023, 10, 30),
 'floating_hols': 'Target',
 'floating_rate_option': 'EUR-EURIBOR-Telerate',
 'floating_rate_day_count_fraction': ACT/360,
 'fixed_rate_business_day_convention': Modified Following,
 'floating_rate_spread': 0.0,
 'floating_rate_frequency': '6m',
 'fee': 0.0,
 'termination_date': datetime.date(2028, 10, 30),
 'fixed_rate': -0.0003280328013176625,
 'floating_first_stub': datetime.date(2023, 10, 30),
 'pay_or_receive': Pay,
 'fee_currency': EUR,
 'fixed_hols': 'Target',
 'notional_currency': EUR,
 'type': Swap,
 'clearing_house': NONE,
 'effective_date': datetime.date(2023, 10, 30),
 'floating_last_stub': datetime.date(2028, 10, 30)}

Calculating Risk Measures

We can also calculate risk measures for the defined instrument. Please refer to the Risk Package for the available risk measures. Calling calc(risk_measure) calculates the value of the risk measure and can return a float, a dataframe or a future thereof, depending on how PricingContext is being used - more on this in the Pricing Context tutorial.

Calculate a scalar value like implied volatility:

import gs_quant.risk as risk

swaption.calc(risk.IRAnnualImpliedVol) * 10000

Output:

65.75327244844051

Calculate a structured value like vega:

swaption.calc(risk.IRVega)

Output:

 marketDataType	      assetId	pointClass	point	      value
0       IR VOL	USD-LIBOR-BBA	SWAPTION	5Y;9M	-833.270880
1	    IR VOL	USD-LIBOR-BBA	SWAPTION	5Y;1Y	11436.482786
2	    IR VOL	USD-LIBOR-BBA	SWAPTION	5Y;15M	6506.953414
3	    IR VOL	USD-LIBOR-BBA	SWAPTION	5Y;18M	-881.193556

Calculate IR Delta (Parallel and Ladder) for Swaps

ir_risk = swap.calc((risk.IRDeltaParallel, risk.IRDeltaParallelLocalCcy, risk.IRDelta))

# Print Risks
print(ir_risk[risk.IRDeltaParallel])
print(ir_risk[risk.IRDeltaParallelLocalCcy])
print(ir_risk[risk.IRDelta])

Output:

-126266.81091040764
-96980.10870167123
   mkt_type mkt_asset mkt_class  mkt_point         value
0        IR       GBP      CASH      1 DAY  1.739874e+00
1        IR       GBP      CASH  CASH STUB  1.759617e+03
2        IR       GBP       FRA      DEC20  3.164005e+03
3        IR       GBP       FRA      MAR21  1.459212e+03
4        IR       GBP       FRA      JUN21 -3.191050e+01
5        IR       GBP       FRA      SEP21 -2.765180e+01
6        IR       GBP       FRA      DEC21 -2.575705e+01
7        IR       GBP       FRA      MAR22 -1.708280e+01
8        IR       GBP       FRA      JUN22 -1.008386e+01
9        IR       GBP       FRA      SEP22 -1.347198e+01
10       IR       GBP  SWAP OIS         3Y -1.644059e+02
11       IR       GBP  SWAP OIS         4Y -3.068205e+02
12       IR       GBP  SWAP OIS         5Y -1.554243e+02
13       IR       GBP  SWAP OIS         6Y -4.754207e+02
14       IR       GBP  SWAP OIS         7Y -3.978586e+02
15       IR       GBP  SWAP OIS         8Y -4.717499e+02
16       IR       GBP  SWAP OIS         9Y -6.641736e+02
17       IR       GBP  SWAP OIS        10Y -1.298433e+05
18       IR       GBP  SWAP OIS        12Y -4.921439e+01
19       IR       GBP  SWAP OIS        15Y  7.086755e+00
20       IR       GBP  SWAP OIS        20Y -5.343531e-01
21       IR       GBP  SWAP OIS        25Y -1.732565e-03
22       IR       GBP  SWAP OIS        30Y  2.842251e-04
23       IR       GBP  SWAP OIS        40Y -8.279800e-06
24       IR       GBP  SWAP OIS        50Y -7.247925e-08
25       IR       GBP  SWAP OIS        60Y  1.945496e-08
26       IR       GBP  SWAP OIS        70Y  3.051758e-08
27       IR       GBP  SWAP OIS        80Y  1.564026e-08
28       IR       USD      CASH        O/N -1.800790e+00
29       IR       USD      CASH  CASH STUB -1.800005e+00
30       IR       USD       FRA      DEC20  8.923584e-04
31       IR       USD       FRA      MAR21 -2.621010e-04
32       IR       USD       FRA      JUN21  2.066803e-06
33       IR       USD       FRA      SEP21  1.328514e-04
34       IR       USD       FRA      DEC21 -3.990868e-04
35       IR       USD       FRA      MAR22  3.143867e-04
36       IR       USD       FRA      JUN22  1.238235e-04
37       IR       USD       FRA      SEP22  0.000000e+00
38       IR       USD       FRA      DEC22  0.000000e+00
39       IR       USD       FRA      MAR23  0.000000e+00
40       IR       USD       FRA      JUN23  3.814697e-10
41       IR       USD       FRA      SEP23  0.000000e+00
42       IR       USD      SWAP         4Y  0.000000e+00
43       IR       USD      SWAP         5Y  3.814697e-10
44       IR       USD      SWAP         6Y -3.814697e-10
45       IR       USD      SWAP         7Y  0.000000e+00
46       IR       USD      SWAP         8Y  3.814697e-10
47       IR       USD      SWAP         9Y -7.629395e-10
48       IR       USD      SWAP        10Y -7.629395e-10
49       IR       USD      SWAP        12Y  3.814697e-10
50       IR       USD      SWAP        15Y  0.000000e+00
51       IR       USD      SWAP        20Y -3.814697e-10
52       IR       USD      SWAP        25Y  3.814697e-10
53       IR       USD      SWAP        30Y  0.000000e+00
54       IR       USD      SWAP        35Y  7.629395e-10
55       IR       USD      SWAP        40Y  3.814697e-10
56       IR       USD      SWAP        45Y  0.000000e+00
57       IR       USD      SWAP        50Y -7.629395e-10

Calculate a conditional risk measure. Show IRDelta Ladder only where exposure >1e-2

ird_ladder=ir_risk[risk.IRDelta]
print(ird_ladder[abs(ird_ladder.value)>1e-2])

Output:

   mkt_type mkt_asset mkt_class  mkt_point          value
0        IR       GBP      CASH      1 DAY       1.739874
1        IR       GBP      CASH  CASH STUB    1759.617323
2        IR       GBP       FRA      DEC20    3164.005345
3        IR       GBP       FRA      MAR21    1459.211995
4        IR       GBP       FRA      JUN21     -31.910504
5        IR       GBP       FRA      SEP21     -27.651800
6        IR       GBP       FRA      DEC21     -25.757052
7        IR       GBP       FRA      MAR22     -17.082804
8        IR       GBP       FRA      JUN22     -10.083864
9        IR       GBP       FRA      SEP22     -13.471984
10       IR       GBP  SWAP OIS         3Y    -164.405861
11       IR       GBP  SWAP OIS         4Y    -306.820500
12       IR       GBP  SWAP OIS         5Y    -155.424287
13       IR       GBP  SWAP OIS         6Y    -475.420745
14       IR       GBP  SWAP OIS         7Y    -397.858642
15       IR       GBP  SWAP OIS         8Y    -471.749941
16       IR       GBP  SWAP OIS         9Y    -664.173632
17       IR       GBP  SWAP OIS        10Y -129843.283225
18       IR       GBP  SWAP OIS        12Y     -49.214390
19       IR       GBP  SWAP OIS        15Y       7.086755
20       IR       GBP  SWAP OIS        20Y      -0.534353
28       IR       USD      CASH        O/N      -1.800790
29       IR       USD      CASH  CASH STUB      -1.800005

See measures table for information on units.


Related Content