<jupyter_start><jupyter_text>Curve Overlay ContextScenario contexts enable the users to price and calculate risk using their own curves.<jupyter_code>from gs_quant.instrument import IRSwaption
from gs_quant.risk import MarketDataPattern, MarketDataShock, MarketDataShockType, MarketDataShockBasedScenario, \
    RollFwd, CurveScenario, IndexCurveShift, CurveOverlay
from gs_quant.session import Environment, GsSession
from datetime import datetime
# external users should substitute their client id and secret; please skip this step if using internal jupyterhub
GsSession.use(Environment.PROD, client_id=None, client_secret=None, scopes=('run_analytics',))
# Create and price a swaption
swaption = IRSwaption('Pay', '5y', 'USD', expiration_date='3m')
base_price = swaption.price()
print('Original price: {:,.2f}'.format(base_price))<jupyter_output>Original price: 605,255.51<jupyter_text>Curve Overlay Scenario A predefined scenario used to overlay discount curve or index curve. This allows the user to use customized discount factors to overwrite existing curves on graph.* discount_factors - Discount factors* dates - Dates of the discount factors.* curve_type - Discount curve or index curve.* rate_option - Rate option of the index curve.* tenor - Tenor of the index curve.* csa_term - The funding scenario of the curve.* denominated - The denominated currency of the curve.<jupyter_code>import pandas as pd

# Read discount factors from a csv file
df = pd.read_csv (r'CurveExample.csv', sep="," )
dates = df.MaturityDate.tolist()
dates_reformat = [ datetime.strptime(date, "%d-%b-%Y").strftime("%Y-%m-%d") for date in dates ]
discount_factors = df.DiscountFactor.tolist()

curve_overlay_scenario = CurveOverlay(
    dates = dates_reformat,
    discount_factors = discount_factors,
    denominated = "USD",
    csa_term = "USD-SOFR",
    curve_type = "Discount Curve"
)
with curve_overlay_scenario:
    price_with_overlay = swaption.price()

print('Scenario price: {:,.2f}'.format(price_with_overlay))<jupyter_output>Scenario price: 635,392.60
{'fraction_non_alphanumeric': 0.09228515625, 'fraction_numerical': 0.009765625, 'mean_word_length': 5.922297297297297, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '519129', 'license': 'Apache-2.0', 'n_tokens_mistral': 637, 'n_tokens_neox': 620, 'n_words': 194, 'path': 'gs_quant/documentation/02_pricing_and_risk/01_scenarios_and_contexts/examples/07_curve_overlay/010700_discount_curve_overlay.ipynb', 'repo_name': 'webclinic017/gs-quant', 'size': '2048'}