I am valuing few Basis Swaps having combination of USD-FedFunds-H.15-OIS-COMPOUND3M vs USD3MLibor. However, I can understand to value 'USD-FedFunds-H.15-OIS-COMPOUND1D' by using ql.FedFunds(). But dont know how to pass period '3M' parameter in Fedfunds object. Can someone suggest to handle such type of indexes in valuation.
Standard way as mentioned below:
'usd-libor-3m-bba':ql.USDLibor(ql.Period('3M')),
"fedfunds": ql.FedFunds()
Added a sample question for reference.
import QuantLib as ql
import pandas as pd
fedspotRates = [0.02514, 0.026285, 0.027326299999999998,
0.0279, 0.029616299999999998, 0.026526,
0.026028, 0.0258695, 0.025958000000000002,
0.0261375, 0.026355, 0.0266255,
0.026898, 0.0271745, 0.02741,
0.027666, 0.028107000000000004, 0.028412000000000003,
0.028447, 0.0284165]
fedspotPeriod = [ql.Period(1, ql.Weeks), ql.Period(1, ql.Months),
ql.Period(3, ql.Months), ql.Period(6, ql.Months),
ql.Period(9, ql.Months), ql.Period(1, ql.Years),
ql.Period(3, ql.Years), ql.Period(5, ql.Years),
ql.Period(10, ql.Years), ql.Period(15, ql.Years), ql.Period(20, ql.Years),
ql.Period(30, ql.Years), ql.Period(50, ql.Years)]
usdlibor3mRates = [0.0514, 0.006285, 0.027326299999999998,
0.0279, 0.02961, 0.026526,
0.026028, 0.0258695, 0.02595,
0.0261375, 0.026355, 0.0266255,
0.026898, 0.0271745, 0.02741,
0.027666, 0.0281070, 0.028,
0.028447, 0.0284165]
usdlibor3mspotPeriod = [ql.Period(1, ql.Weeks), ql.Period(1, ql.Months),
ql.Period(3, ql.Months), ql.Period(6, ql.Months),
ql.Period(9, ql.Months), ql.Period(1, ql.Years),
ql.Period(3, ql.Years), ql.Period(5, ql.Years),
ql.Period(10, ql.Years), ql.Period(15, ql.Years), ql.Period(20, ql.Years),
ql.Period(30, ql.Years), ql.Period(50, ql.Years)]
dates = [calendar.advance(todaysDate, period) for period in
fedspotPeriod]
curve = ql.ZeroCurve(dates, fedspotRates[:13], day_count, calendar)
yts = ql.YieldTermStructureHandle(curve)
engine = ql.DiscountingSwapEngine(yts)
fed_float3m = floatingSchedule1
usdlibor_float3m = floatingSchedule2
index1 = fedfunds3m
index2 = usdlibor3m
spread=0
notional=100e6
basisSwap=ql.FloatFloatSwap(ql.VanillaSwap.Payer,
[notional] * (len(fed_float3m)-1),
[notional] * (len(usdlibor_float3m)-1),
fed_float3m,
index1,
ql.Actual360(),
usdlibor_float3m,
index2,
ql.Actual360(), False, False,
[] * (len(fed_float3m)-1),
[] * (len(fed_float3m)-1))
swapEngine = DiscountingSwapEngine(discount_curve)
basisSwap.setPricingEngine(swapEngine)