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


This site is for informational purposes only and does not constitute an offer to sell, or the solicitation of an offer to buy, any security. The Goldman Sachs Marquee® platform is for institutional and professional clients only. Some of the services and products described on this site may not be available in certain jurisdictions or to certain types of client. Please contact your Goldman Sachs sales representative with any questions. Nothing on this site constitutes an offer, or an invitation to make an offer from Goldman Sachs to purchase or sell a product. This site is given for purely indicative purposes and does not create any contractual relationship between you and Goldman Sachs. Any market information contained on the site (including but not limited to pricing levels) is based on data available to Goldman Sachs at a given moment and may change from time to time. 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. © 2023 Goldman Sachs. All rights reserved.
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. © 2023 Goldman Sachs. All rights reserved.
Not all products and functionality mentioned on this website are currently available through our API platform.
All loans and deposit products are provided by Goldman Sachs Bank USA, Salt Lake City Branch. Member FDIC.
Brokerage and investment advisory services offered by our investment products are provided by Goldman Sachs & Co. LLC (`‘GS&CO.`’), which is an SEC registered broker-dealer and investment adviser, and member FINRA/SIPC. Research our firm at FINRA's BrokerCheck. Custody and clearing services are provided by Apex Clearing Corporation, a registered broker-dealer and member FINRA/SIPC. Please consider your objectives before investing. A diversified portfolio does not ensure a profit or protect against a loss. Past performance does not guarantee future results. Investment outcomes and projections are forward-looking statements and hypothetical in nature. Neither this website nor any of its contents shall constitute an offer, solicitation, or advice to buy or sell securities in any jurisdictions where GS&Co. is not registered. Any information provided prior to opening an investment account is on the basis that it will not constitute investment advice and that GS&Co. is not a fiduciary to any person by reason of providing such information. For more information about our investment offerings, visit our Full Disclosures.
Investment products are: NOT FDIC INSURED ∙ NOT A DEPOSIT OR OTHER OBLIGATION OF, OR GUARANTEED BY, GOLDMAN SACHS BANK USA ∙ SUBJECT TO INVESTMENT RISKS, INCLUDING POSSIBLE LOSS OF THE PRINCIPAL AMOUNT INVESTED