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.
Measure | Definition |
---|---|
Dollar Price | Price of the instrument in US Dollars |
Price* | Price of the instrument (In local currency unless currency specified in parameters) |
ForwardPrice | Price of the instrument at expiry in the local currency |
CDDelta | Change in option Dollar Price relative to the change in underlying index Dollar Price, due to a 1bp shift in the underlying index spread |
CDGamma | Change in option Delta relative to the change in underlying index Delta, due to a 1bp shift in the underlying index spread |
CDTheta | Change in option Dollar Price over one day |
CDVega | Change in option Dollar Price due to a 1bp shift in the implied volatility of the underlying index |
EqDelta* | Change in Dollar Price (USD present value) due to individual 1% move in the spot price of underlying equity security |
EqGamma* | Change in EqDelta for a 1% move in the price of the underlying equity security |
EqVega* | Change in Dollar Price (USD present value) due to individual 1bp moves in the implied volatility of the underlying equity security |
FXDelta* | Dollar Price sensitivity of the instrument to a move in the underlying spot such that dSpot * FXDelta = PnL |
FXGamma* | FXDelta sensitivity of the instrument to a move in the underlying spot such that dSpot * FXGamma = dDelta |
FXAnnualImpliedVol | FX daily implied volatility (in percent) |
FXAnnualATMImpliedVol | FX daily implied volatility (in basis points) |
FXSpot | FX spot reference |
FXVega* | Change in Dollar Price due to a 1 vol move in the implied volatility of ATM instruments used to build the volatility surface |
IRBasis* | Change in Dollar Price (USD present value) due to individual 1bp moves in the interest rate instruments used to build the basis curve(s) |
IRDelta* | Change in Dollar Price (USD present value) due to individual 1bp moves in the interest rate instruments used to build the underlying discount curve |
IRGamma* | Change in aggregated IRDelta for a aggregated 1bp shift in the interest rate instruments used to build the underlying discount curve |
IRVega* | Change in Dollar Price (USD present value) due to individual 1bp moves in the implied volatility (IRAnnualImpliedVol) of instruments used to build the volatility surface |
IRAnnualImpliedVol | Interest rate annual implied volatility (in percent) |
IRAnnualATMImpliedVol | Interest rate annual implied at-the-money volatility (in percent) |
IRDailyImpliedVol | Interest rate daily implied volatility (in basis points) |
IRSpotRate | Interest rate at-the-money spot rate (in percent) |
IRFwdRate | Interest rate par rate (in percent) |
IRXccyDelta* | Change in Price due to 1bp move in cross currency rates. |
InflationDelta* | Change in Price due to 1bp move in inflation curve. |
Note - * indicates parameterised risk measures. See Parameterised Risk Measure section below.
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 (Aggregated Scalar and Ladder) for Swaps
ir_risk = swap.calc((risk.IRDelta(aggregation_level=AggregationLevel.Type), risk.IRDelta(aggregation_level=AggregationLevel.Type, currency='local'), risk.IRDelta))
# Print Risks
print(ir_risk[risk.IRDelta(aggregation_level=AggregationLevel.Type)])
print(ir_risk[risk.risk.IRDelta(aggregation_level=AggregationLevel.Type, currency='local')])
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.
Parameterised Risk Measures
Some risk measures now support extra parameters
You can now specify which currency you want the price of an instrument to be expressed in
eur_swap = IRSwap(PayReceive.Pay, '5y', 'EUR', fixed_rate='atm+20')
price = eur_swap.price(currency='PLN')
print(f'{price} {list(price.unit.keys())[0]}')
Output:
-4634381.565442756 Polish Zloty
For some finite difference risk measures (noted * in the table above), you can now pass in the specifics of the calculation methodology.
Parameters supported in finite difference risk measures
Parameter name | Type | Description |
---|---|---|
currency | string | Currency of risk result |
aggregation_level | gs_quant.target.common.AggregationLevel | Level of aggregate shift |
local_curve | bool | Change in Price (present value in the denominated currency) |
finite_difference_method | gs_quant.target.common.FiniteDifferenceParameter | Direction and dimension of finite difference |
mkt_marking_mode | string | Market marking mode |
bump_size | float | Bump size |
scale_factor | float | Scale factor |
print(swap.calc(risk.IRDelta))
Output:
-4634381.565442756 Polish Zloty
print(swap.calc(risk.IRDelta))
Output:
mkt_type mkt_asset mkt_class mkt_point mkt_quoting_style value
0 IR GBP CASH 1 DAY 3.975320e+01
1 IR GBP CASH CASH STUB -1.712791e+01
2 IR GBP FRA SEP21 -3.340941e+01
3 IR GBP FRA DEC21 -3.304035e+01
4 IR GBP FRA MAR22 -3.388328e+01
5 IR GBP FRA JUN22 -2.238591e+01
6 IR GBP FRA SEP22 -1.839452e+01
7 IR GBP FRA DEC22 -1.489927e+01
8 IR GBP FRA MAR23 -1.882270e+01
9 IR GBP FRA JUN23 -4.702490e+00
10 IR GBP SWAP OIS 3Y -1.963525e+02
11 IR GBP SWAP OIS 4Y -2.661177e+02
12 IR GBP SWAP OIS 5Y -3.323207e+02
13 IR GBP SWAP OIS 6Y -3.993289e+02
14 IR GBP SWAP OIS 7Y -4.709492e+02
15 IR GBP SWAP OIS 8Y -5.330585e+02
16 IR GBP SWAP OIS 9Y -6.006114e+02
17 IR GBP SWAP OIS 10Y -1.356210e+05
18 IR GBP SWAP OIS 12Y 1.755524e-05
19 IR GBP SWAP OIS 15Y -1.166458e-05
20 IR GBP SWAP OIS 20Y 4.046631e-06
21 IR GBP SWAP OIS 25Y -5.867004e-07
22 IR GBP SWAP OIS 30Y 2.937317e-08
23 IR GBP SWAP OIS 40Y 6.866455e-09
24 IR GBP SWAP OIS 50Y -2.162933e-07
25 IR GBP SWAP OIS 60Y -2.059937e-08
26 IR GBP SWAP OIS 70Y 3.128052e-08
27 IR GBP SWAP OIS 80Y -3.433228e-08
28 IR USD CASH O/N -1.874307e+00
29 IR USD CASH CASH STUB -5.621533e+00
30 IR USD FRA SEP21 7.039375e-05
31 IR USD FRA DEC21 -4.110413e-05
32 IR USD FRA MAR22 1.529045e-05
33 IR USD FRA JUN22 -9.892464e-05
34 IR USD FRA SEP22 1.229893e-04
35 IR USD FRA DEC22 1.500053e-04
36 IR USD FRA MAR23 -1.602684e-04
37 IR USD FRA JUN23 -1.144409e-09
38 IR USD FRA SEP23 0.000000e+00
39 IR USD FRA DEC23 0.000000e+00
40 IR USD FRA MAR24 0.000000e+00
41 IR USD FRA JUN24 -3.814697e-10
42 IR USD SWAP 4Y 1.525879e-09
43 IR USD SWAP 5Y 0.000000e+00
44 IR USD SWAP 6Y 3.814697e-10
45 IR USD SWAP 7Y -3.814697e-10
46 IR USD SWAP 8Y -7.629395e-10
47 IR USD SWAP 9Y 0.000000e+00
48 IR USD SWAP 10Y -1.144409e-09
49 IR USD SWAP 12Y -3.814697e-10
50 IR USD SWAP 15Y -3.814697e-10
51 IR USD SWAP 20Y 1.525879e-09
52 IR USD SWAP 25Y 0.000000e+00
53 IR USD SWAP 30Y 1.144409e-09
54 IR USD SWAP 35Y 0.000000e+00
55 IR USD SWAP 40Y 3.814697e-10
56 IR USD SWAP 45Y 0.000000e+00
57 IR USD SWAP 50Y -3.814697e-10
# Calculate delta calculated due to change in Price only in the denominated currency
print(swap.calc(risk.IRDelta(currency='local')))
Output:
mkt_type mkt_asset mkt_class mkt_point mkt_quoting_style value
0 IR GBP CASH 1 DAY -1.068222e+00
1 IR GBP CASH CASH STUB -1.641412e+01
2 IR GBP FRA SEP21 -2.409039e+01
3 IR GBP FRA DEC21 -2.382426e+01
4 IR GBP FRA MAR22 -2.443204e+01
5 IR GBP FRA JUN22 -1.614180e+01
6 IR GBP FRA SEP22 -1.326354e+01
7 IR GBP FRA DEC22 -1.074325e+01
8 IR GBP FRA MAR23 -1.357251e+01
9 IR GBP FRA JUN23 -3.390803e+00
10 IR GBP SWAP OIS 3Y -1.415830e+02
11 IR GBP SWAP OIS 4Y -1.918883e+02
12 IR GBP SWAP OIS 5Y -2.396250e+02
13 IR GBP SWAP OIS 6Y -2.879423e+02
14 IR GBP SWAP OIS 7Y -3.395852e+02
15 IR GBP SWAP OIS 8Y -3.843700e+02
16 IR GBP SWAP OIS 9Y -4.330801e+02
17 IR GBP SWAP OIS 10Y -9.779165e+04
18 IR GBP SWAP OIS 12Y 1.270790e-05
19 IR GBP SWAP OIS 15Y -8.369064e-06
20 IR GBP SWAP OIS 20Y 2.946854e-06
21 IR GBP SWAP OIS 25Y -4.714966e-07
22 IR GBP SWAP OIS 30Y 5.264282e-08
23 IR GBP SWAP OIS 40Y 2.021790e-08
24 IR GBP SWAP OIS 50Y -1.125336e-07
25 IR GBP SWAP OIS 60Y 3.433228e-08
26 IR GBP SWAP OIS 70Y 0.000000e+00
27 IR GBP SWAP OIS 80Y -8.659363e-08
from gs_quant.common import AggregationLevel
# Calculate delta using an aggregated 1bp shift and using change in Price only in the denominated currency
print(swap.calc(risk.IRDelta(aggregation_level=AggregationLevel.Type, currency='local')))
Output:
-100327.21051493683
Related Content
Previous - Instruments
arrow_forwardNext - Pricing Context
arrow_forwardWas this page useful?
Give feedback to help us improve developer.gs.com and serve you better.