menu
Pricing and Risk

Scenarios

Scenario contexts enable the user to price and calculate risk under varying market states and pricing environments.

info

Note

Examples require an initialized GsSession and relevant entitlements. Please refer to Sessions for details.

from gs_quant.instrument import IRSwaption
from gs_quant.risk import MarketDataPattern, MarketDataShock, MarketDataShockType, MarketDataShockBasedScenario, RollFwd, CurveScenario, IndexCurveShift
# Create and price a swaption
swaption = IRSwaption('Pay', '5y', 'USD', expiration_date='3m')
base_price = swaption.price()
base_price

Output:

365492.8324509927

MarketDataShockBasedScenario

Allows the user to create a bespoke market data shock

# Scenario Creation: Shock all points on the Vol Curve by 1bp
ir_vol_scenario = MarketDataShockBasedScenario(
    shocks={
        MarketDataPattern('IR Vol'): MarketDataShock(MarketDataShockType.Absolute, 1e-4)
    }
)
# Price swaption under scenario
with ir_vol_scenario:
    scenario_price = swaption.price()

scenario_price

Output:

375348.4697367982
# Swaption Price Comparison: Base vs. Shocked Vol Curves
diff = scenario_price - base_price
diff

Output:

9855.637285805482
# Comparing Parallel Bump Scenario w/ Vega
from gs_quant.risk import IRVega
vega = swaption.calc(IRVega).value.sum()
vega

Output:

9855.949321512366

Curve Scenario

A predefined scenario used to modify the shape of the curve with bespoke transformations - by applying both parallel and slope shifts.

  • market_data_pattern - Market pattern for matching curve assets (required parameter).
  • parallel_shift - A constant (X bps) which shifts all points by the same amount.
  • curve_shift - A double which represents the net rate change (X bps) between tenorStart and tenorEnd.
  • pivot_point – The tenor in years (float) at which there is zero rate change, which is between tenor_start and tenor_end inclusive, informing the type of curve shift. If not specified, pivot_point is the midpoint of tenor_start and tenor_end.
  • tenor_start – The tenor, in years, (float) which is the starting point of the curve shift (required parameter is curve_shift is specified).
  • tenor_end – The tenor, in years, (float) which is the end point of the curve shift (required parameter is curve_shift is specified).
# Scenario Creation: modify the Vol Curve by a 5bp parallel shift, 1bp slope shift pivoted at 5y point (up to 50y)
curve_scenario = CurveScenario(market_data_pattern=MarketDataPattern('IR', 'USD'), parallel_shift=5,
                               curve_shift=1, pivot_point=5, tenor_end=50, tenor_start=0)

with curve_scenario:
    swaption_scenario_price = swaption.price()

# Look at the difference between scenario and base prices
print('Base price:     {:,.2f}'.format(base_price))
print('Scenario price: {:,.2f}'.format(swaption_scenario_price))

Output:

Base price:     365,492.83
Scenario price: 375,741.75

RollFwd Scenario

A predefined scenario used to evolve market data and trades over a period of time.

  • date - Absolute or Relative Date to shift markets to.
  • realise_fwd - Roll along the forward curve or roll in spot space.
  • holiday_calendar - Calendar to use if relative date is specified in the date parameter.
 # RollFwd Scenario - Roll forward 1 month
base_price = swaption.price()
with RollFwd(date='1m', holiday_calendar='NYC', realise_fwd=False):
    fwd_price = swaption.price()

# Look at the difference between scenario and base prices
print('Base price:     {:,.2f}'.format(base_price))
print('Scenario price: {:,.2f}'.format(fwd_price))
print('Diff: {:,.2f}'.format(fwd_price - base_price))

Output:

Base price:     365,492.83
Scenario price: 365,709.19
Diff: 216.35

Index Curve Shift Scenario

A predefined scenario used to modify the shape of the index curve. This allows the user to easily shock the curve including parallel shift and slope shift. Users can even specify which part of the curve for parallel shift through custom bucket.

  • market_data_pattern - Market pattern for matching curve assets.
  • rate_option - Rate option of the index curve.
  • tenor - Tenor of the index curve.
  • floor - Floor size in bps of the index curve.
  • annualised_parallel_shift – Parallel shift in bps.
  • annualised_slope_shift – Annual slope shift in bps with pivot = 0.
  • cutoff – Cutoff time in years to stop applying the shift.
  • bucket_start - Start date for the custom bucket.
  • bucket_end - End date for the custom bucket.
  • bucket_shift - Bucket shift in bps for the custom bucket.
# Scenario Creation: modify the index curve of this swaption by a 1bp parallel shift, 1bp slope shift, pivoted default to 0 year with floor value -1bp (up to 50y)
index_curve_shift = IndexCurveShift(rate_option="USD-LIBOR-BBA", tenor="3m", annualised_parallel_shift=1,
                               annualised_slope_shift=1, floor=-1, cutoff=50)

with index_curve_shift:
    swaption_scenario_price = swaption.price()

# Look at the difference between scenario and base prices
print('Base price:     {:,.2f}'.format(base_price))
print('Scenario price: {:,.2f}'.format(swaption_scenario_price))

Output:

Base price:     365,492.83
Scenario price: 470,222.06

Related Content


Certain solutions and Institutional Services described herein are provided via our Marquee platform. The Marquee platform is for institutional and professional clients only. This site is for informational purposes only and does not constitute an offer to provide the Marquee platform services described, nor an offer to sell, or the solicitation of an offer to buy, any security. Some of the services and products described herein may not be available in certain jurisdictions or to certain types of clients. Please contact your Goldman Sachs sales representative with any questions. Any data or market information presented on the site is solely for illustrative purposes. There is no representation that any transaction can or could have been effected on such terms or at such prices. Please see https://www.goldmansachs.com/disclaimer/sec-div-disclaimers-for-electronic-comms.html for additional information.
Transaction Banking services are offered by Goldman Sachs Bank USA (“GS Bank”). GS Bank is a New York State chartered bank, a member of the Federal Reserve System and a Member FDIC.
GS DAP™ is owned and operated by Goldman Sachs. This site is for informational purposes only and does not constitute an offer to provide, or the solicitation of an offer to provide access to or use of GS DAP™. Any subsequent commitment by Goldman Sachs to provide access to and / or use of GS DAP™ would be subject to various conditions, including, amongst others, (i) satisfactory determination and legal review of the structure of any potential product or activity, (ii) receipt of all internal and external approvals (including potentially regulatory approvals); (iii) execution of any relevant documentation in a form satisfactory to Goldman Sachs; and (iv) completion of any relevant system / technology / platform build or adaptation required or desired to support the structure of any potential product or activity.
Mosaic is a service mark of Goldman Sachs & Co. LLC. This service is made available in the United States by Goldman Sachs & Co. LLC and outside of the United States by Goldman Sachs International, or its local affiliates in accordance with applicable law and regulations. Goldman Sachs International and Goldman Sachs & Co. LLC are the distributors of the Goldman Sachs Funds. Depending upon the jurisdiction in which you are located, transactions in non-Goldman Sachs money market funds are affected by either Goldman Sachs & Co. LLC, a member of FINRA, SIPC and NYSE, or Goldman Sachs International. For additional information contact your Goldman Sachs representative. Goldman Sachs & Co. LLC, Goldman Sachs International, Goldman Sachs Liquidity Solutions, Goldman Sachs Asset Management, L.P., and the Goldman Sachs funds available through Goldman Sachs Liquidity Solutions and other affiliated entities, are under the common control of the Goldman Sachs Group, Inc.
© 2024 Goldman Sachs. All rights reserved.