Hi guys,
I’m getting started with strata.
I m writting a code to calculate the cashflow on a swaptrade. I want to know the duration of this task. Unfortunatly , I don’t know how to create a rateProvider. Can someone please explain to me what should I do and how ?
This is the code :
public static void main(String[] args) {
SwapLeg payLeg = RateCalculationSwapLeg.builder()
.payReceive(PayReceive.PAY)
.accrualSchedule(PeriodicSchedule.builder()
.startDate(LocalDate.of(2014, 9, 12))
.endDate(LocalDate.of(2021, 9, 12))
.frequency(Frequency.P6M)
.businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, HolidayCalendarIds.USNY))
.build())
.paymentSchedule(PaymentSchedule.builder()
.paymentFrequency(Frequency.P6M)
.paymentDateOffset(DaysAdjustment.NONE)
.build())
.notionalSchedule(NotionalSchedule.of(Currency.USD, 100_000_000))
.calculation(FixedRateCalculation.of(0.015, DayCounts.THIRTY_U_360))
.build();
SwapLeg receiveLeg = RateCalculationSwapLeg.builder()
.payReceive(PayReceive.RECEIVE)
.accrualSchedule(PeriodicSchedule.builder()
.startDate(LocalDate.of(2014, 9, 12))
.endDate(LocalDate.of(2021, 9, 12))
.frequency(Frequency.P3M)
.businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, HolidayCalendarIds.USNY))
.build())
.paymentSchedule(PaymentSchedule.builder()
.paymentFrequency(Frequency.P3M)
.paymentDateOffset(DaysAdjustment.NONE)
.build())
.notionalSchedule(NotionalSchedule.of(Currency.USD, 100_000_000))
.calculation(IborRateCalculation.of(USD_LIBOR_3M))
.build();
Swap swap = Swap.of(payLeg, receiveLeg);
SwapTradeCalculations SwapTradeCalculator = SwapTradeCalculations.DEFAULT;
SwapTrade trade = SwapTrade.builder()
.info(TradeInfo.builder().tradeDate(LocalDate.of(2016, 8, 8)).build())
.product(swap).build();
ResolvedSwapTrade resolvedSwapTrade = trade.resolve(ReferenceData.standard());
RatesProvider BaseProvider;
SwapTradeCalculator.cashFlows(resolvedSwapTrade, BaseProvider);
}```