/** * Creates a periodic frequency. * * @param period the period to represent * @param name the name */ private Frequency(Period period, String name) { ArgChecker.notNull(period, "period"); ArgChecker.isFalse(period.isZero(), "Period must not be zero"); ArgChecker.isFalse(period.isNegative(), "Period must not be negative"); this.period = period; this.name = name; }
/** * Puts the specified date/value point into this builder. * * @param date the date to be added * @param value the value associated with the date * @return this builder */ public LocalDateDoubleTimeSeriesBuilder put(LocalDate date, double value) { ArgChecker.notNull(date, "date"); ArgChecker.isFalse(Double.isNaN(value), "NaN is not allowed as a value"); entries.put(date, value); if (!containsWeekends && date.get(ChronoField.DAY_OF_WEEK) > 5) { containsWeekends = true; } return this; }
// check that one leg is fixed and return it private ExpandedSwapLeg fixedLeg(ExpandedSwap swap) { ArgChecker.isFalse(swap.isCrossCurrency(), "swap should be single currency"); // find fixed leg List<ExpandedSwapLeg> fixedLegs = swap.getLegs(SwapLegType.FIXED); if (fixedLegs.isEmpty()) { throw new IllegalArgumentException("Swap must contain a fixed leg"); } return fixedLegs.get(0); }
/** * A forward starting CDS starts on some date after today (the trade date). The accrual start must * be specified (would normally use this for T+1 accrual atart). The stepin date and cash * settlement date are taken from the forward start date (1 day and 3 working days by default). * * @param tradeDate the trade date (i.e. today) * @param forwardStartDate the forward start date * @param accStartDate the accrual start date * @param maturity the maturity of the CDS * @return a CDS analytic description for a forward starting CDS */ public CdsAnalytic makeForwardStartingCds( LocalDate tradeDate, LocalDate forwardStartDate, LocalDate accStartDate, LocalDate maturity) { ArgChecker.isFalse( forwardStartDate.isBefore(tradeDate), "forwardStartDate of {} is before trade date of {}", forwardStartDate, tradeDate); LocalDate stepinDate = forwardStartDate.plusDays(_stepIn); LocalDate valueDate = addWorkDays(forwardStartDate, _cashSettle, _calendar); return makeCds(tradeDate, stepinDate, valueDate, accStartDate, maturity); }
/** * A forward starting CDS starts on some date after today (the trade date). The stepin date and * cash settlement date are taken from the forward start date (1 day and 3 working days by * default). * * @param tradeDate the trade date (i.e. today) * @param forwardStartDate the forward start date * @param maturity the maturity of the CDS * @return a CDS analytic description for a forward starting CDS */ public CdsAnalytic makeForwardStartingCds( LocalDate tradeDate, LocalDate forwardStartDate, LocalDate maturity) { ArgChecker.isFalse( forwardStartDate.isBefore(tradeDate), "forwardStartDate of {} is before trade date of {}", forwardStartDate, tradeDate); LocalDate stepinDate = forwardStartDate.plusDays(_stepIn); LocalDate valueDate = addWorkDays(forwardStartDate, _cashSettle, _calendar); LocalDate accStartDate = _businessdayAdjustmentConvention.adjust( ImmDateLogic.getPrevIMMDate(forwardStartDate), _calendar); return makeCds(tradeDate, stepinDate, valueDate, accStartDate, maturity); }
// validate that the rates and volatilities providers are coherent private void validate( RatesProvider ratesProvider, ExpandedSwaption swaption, NormalVolatilitySwaptionProvider volatilityProvider) { ArgChecker.isTrue( volatilityProvider .getValuationDateTime() .toLocalDate() .equals(ratesProvider.getValuationDate()), "volatility and rate data should be for the same date"); ArgChecker.isFalse( swaption.getUnderlying().isCrossCurrency(), "underlying swap should be single currency"); ArgChecker.isTrue( swaption.getSwaptionSettlement().getSettlementType().equals(SettlementType.PHYSICAL), "swaption should be physical settlement"); }
@ImmutableValidator private void validate() { ArgChecker.isFalse(periodToStart.isNegative(), "Period to start must not be negative"); ArgChecker.isFalse(periodToEnd.isNegative(), "Period to end must not be negative"); }