Я хотел бы рассчитать ставки свопов по номиналу (т. Е. Фиксированные ставки) для свопов, торгуемых по номиналу (т. Е. Рыночная стоимость = 0), с учетом кривой без купона с наблюдаемыми сроками погашения от 3 до 120 месяцев. .
Вот что я сделал:
# define constants
face_amount = 100
settlementDays = 0
calendar = ql.NullCalendar()
fixedLegAdjustment = ql.Unadjusted
floatingLegAdjustment = ql.Unadjusted
fixedLegDayCounter = ql.SimpleDayCounter()
floatingLegDayCounter = ql.SimpleDayCounter()
end_of_month = False
floating_rate = ql.IborIndex("MyIndex", ql.Period("3m"), settlementDays, ql.USDCurrency(), calendar, floatingLegAdjustment, end_of_month, floatingLegDayCounter)
# pre-allocate
irs = {}
# calculate dates
curve_date = ql.DateParser.parseFormatted("2020-05-26", "%Y-%m-%d")
ql.Settings.instance().evaluationDate = curve_date
spot_date = calendar.advance(curve_date, settlementDays, ql.Days)
# pre-allocate
irs_rate = []
tenors = []
maturity_dates = []
# loop over maturities
for tenor in np.arange(3, 120 + 1, 3):
# maturity date
maturity_date = calendar.advance(spot_date, ql.Period(int(tenor), ql.Months))
# gather maturity dates
maturity_dates.append(maturity_date)
# build zero coupon curve object
zero_curve = ql.YieldTermStructureHandle(ql.ZeroCurve(maturity_dates, zero_rates, fixedLegAdjustment, calendar))
# build swap curve
# loop over maturities
for tenor in np.arange(3, 120 + 1, 3):
# fixed leg tenor
fixedLegTenor = ql.Period(tenor, ql.Months)
# fixed leg coupon schedule
fixedLegSchedule = ql.Schedule(spot_date, maturity_date,
fixedLegTenor, calendar,
fixedLegAdjustment, fixedLegAdjustment,
ql.DateGeneration.Forward, end_of_month)
# floating leg tenor
floatingLegTenor = ql.Period(3, ql.Months)
# floating leg coupon schedule
floatingLegSchedule = ql.Schedule(spot_date, maturity_date,
floatingLegTenor, calendar,
floatingLegAdjustment, floatingLegAdjustment,
ql.DateGeneration.Forward, end_of_month)
# build swap pricer
irs = ql.VanillaSwap(ql.VanillaSwap.Receiver, face_amount, fixedLegSchedule, FIXED_RATE, fixedLegDayCounter, floatingLegSchedule, floating_rate, 0, floatingLegDayCounter)
# build swap curve
swap_curve = ql.DiscountingSwapEngine(zero_curve)
# get swap rate
irs.setPricingEngine(swap_curve)
# get par swap rate
irs_rate.append(irs.fairRate())
Однако это необходимо для получения рыночной стоимости свопа с наблюдаемой фиксированной ставкой = FIXED_RATE
Вместо этого мне нужна ставка для данной наблюдаемой рыночной стоимости (ноль).
Заранее большое спасибо за вашу помощь.