This is the lean framework for quantitative activities. It utilized linerapy Python package. The package can be installed:
pip install linerapyThe data folder gives example how to store Yield Curves and Interest Rate Swap. Simply update the quotes with your market data, update the value date with the valuation date and run the pricing.
data_path = os.path.join(os.getcwd(), '..', 'data')
yc_dict = load_yield_curves(os.path.join(data_path, 'yield_curves.csv'))
yield_curves = {}
for value_date in yc_dict.keys():
yield_curve_data = yc_dict[value_date]
for yield_curve_id in yield_curve_data.keys():
yield_curve_dict = yield_curve_data[yield_curve_id]
yield_curve_dict['id'] = yield_curve_id
yield_curve_dict['value date'] = value_date
yc = linerapy.YieldCurve(yield_curve_dict)
yield_curves[yield_curve_id] = yc
swaps = load_swaps(os.path.join(data_path, "swaps.csv"))
curve_assignment = {
"USD": "USD SOFR",
"SGD": "SGD SORA",
"GBP": "GBP SONIA",
"CHF": "CHF SARON",
"JPY": "JPY TONA"
}
for swap_id in swaps.keys():
swap = swaps[swap_id]
if swap['leg1']['currency'] != swap['leg1']['currency']:
print("Cross currency swap is not supported.")
continue
yc = yield_curves[curve_assignment[swap['leg1']['currency']]]
irs = linerapy.IRS(swap)