Package com.opengamma.financial.convention.daycount

Examples of com.opengamma.financial.convention.daycount.DayCount


  @Override
  public BondFuturesSecurity toDerivative(final ZonedDateTime date) {
    ArgumentChecker.notNull(date, "date");
    ArgumentChecker.isTrue(!date.isAfter(getNoticeLastDate()), "Date is after last notice date");
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final double lastTradingTime = actAct.getDayCountFraction(date, getTradingLastDate(), _calendar);
    final double firstNoticeTime = actAct.getDayCountFraction(date, getNoticeFirstDate(), _calendar);
    final double lastNoticeTime = actAct.getDayCountFraction(date, getNoticeLastDate(), _calendar);
    final double firstDeliveryTime = actAct.getDayCountFraction(date, getDeliveryFirstDate(), _calendar);
    final double lastDeliveryTime = actAct.getDayCountFraction(date, getDeliveryLastDate(), _calendar);
    final BondFixedSecurity[] basket = new BondFixedSecurity[_deliveryBasket.length];
    for (int loopbasket = 0; loopbasket < _deliveryBasket.length; loopbasket++) {
      basket[loopbasket] = _deliveryBasket[loopbasket].toDerivative(date, _deliveryLastDate);
    }
    return new BondFuturesSecurity(lastTradingTime, firstNoticeTime, lastNoticeTime, firstDeliveryTime, lastDeliveryTime, _notional, basket, _conversionFactor);
View Full Code Here


    ArgumentChecker.isTrue(yieldCurveNames.length > 0, "at least one curve required");
    final String creditCurveName = yieldCurveNames[0];
    final String discountingCurveName = yieldCurveNames[1];
    final String iborCurveName = yieldCurveNames[2];
    final String[] couponCurveName = new String[] {creditCurveName, iborCurveName };
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final ZonedDateTime spot = ScheduleCalculator.getAdjustedDate(date, getUnderlyingBond().getSettlementDays(), getUnderlyingBond().getCalendar());
    final double spotTime = actAct.getDayCountFraction(date, spot, getUnderlyingBond().getCalendar());
    final double settlementTime;
    if (getSettlementDate().isBefore(date)) {
      settlementTime = 0;
    } else {
      settlementTime = actAct.getDayCountFraction(date, getSettlementDate(), getUnderlyingBond().getCalendar());
    }
    final AnnuityPaymentFixed nominal = (AnnuityPaymentFixed) getUnderlyingBond().getNominal().toDerivative(date, creditCurveName);
    final Annuity<Coupon> coupon = (Annuity<Coupon>) getUnderlyingBond().getCoupons().toDerivative(date, couponCurveName);
    final AnnuityPaymentFixed nominalPurchase = nominal.trimBefore(settlementTime);
    final Annuity<Coupon> couponPurchase = coupon.trimBefore(settlementTime);
View Full Code Here

    ArgumentChecker.isTrue(yieldCurveNames.length > 0, "at least one curve required");
    final String creditCurveName = yieldCurveNames[0];
    final String discountingCurveName = yieldCurveNames[1];
    final String iborCurveName = yieldCurveNames[2];
    final String[] couponCurveName = new String[] {creditCurveName, iborCurveName };
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final ZonedDateTime spot = ScheduleCalculator.getAdjustedDate(date, getUnderlyingBond().getSettlementDays(), getUnderlyingBond().getCalendar());
    final double spotTime = actAct.getDayCountFraction(date, spot, getUnderlyingBond().getCalendar());
    final double settlementTime;
    if (getSettlementDate().isBefore(date)) {
      settlementTime = 0;
    } else {
      settlementTime = actAct.getDayCountFraction(date, getSettlementDate(), getUnderlyingBond().getCalendar());
    }
    final AnnuityPaymentFixed nominal = (AnnuityPaymentFixed) getUnderlyingBond().getNominal().toDerivative(date, creditCurveName);
    final Annuity<Coupon> coupon = (Annuity<Coupon>) getUnderlyingBond().getCoupons().toDerivative(date, indexFixingTS, couponCurveName);
    final AnnuityPaymentFixed nominalPurchase = nominal.trimBefore(settlementTime);
    final Annuity<Coupon> couponPurchase = coupon.trimBefore(settlementTime);
View Full Code Here

  @Override
  public BondIborTransaction toDerivative(final ZonedDateTime date) {
    // TODO: review this implementation using the Security toDerivative.
    ArgumentChecker.notNull(date, "date");
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final ZonedDateTime spot = ScheduleCalculator.getAdjustedDate(date, getUnderlyingBond().getSettlementDays(), getUnderlyingBond().getCalendar());
    final double spotTime = actAct.getDayCountFraction(date, spot, getUnderlyingBond().getCalendar());
    final double settlementTime;
    if (getSettlementDate().isBefore(date)) {
      settlementTime = 0;
    } else {
      settlementTime = actAct.getDayCountFraction(date, getSettlementDate(), getUnderlyingBond().getCalendar());
    }
    final AnnuityPaymentFixed nominal = (AnnuityPaymentFixed) getUnderlyingBond().getNominal().toDerivative(date);
    final Annuity<Coupon> coupon = (Annuity<Coupon>) getUnderlyingBond().getCoupons().toDerivative(date);
    final AnnuityPaymentFixed nominalPurchase = nominal.trimBefore(settlementTime);
    final Annuity<Coupon> couponPurchase = coupon.trimBefore(settlementTime);
View Full Code Here

  @Override
  public BondIborTransaction toDerivative(final ZonedDateTime date, final DoubleTimeSeries<ZonedDateTime> indexFixingTS) {
    ArgumentChecker.notNull(date, "date");
    ArgumentChecker.notNull(indexFixingTS, "index fixing time series");
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final ZonedDateTime spot = ScheduleCalculator.getAdjustedDate(date, getUnderlyingBond().getSettlementDays(), getUnderlyingBond().getCalendar());
    final double spotTime = actAct.getDayCountFraction(date, spot, getUnderlyingBond().getCalendar());
    final double settlementTime;
    if (getSettlementDate().isBefore(date)) {
      settlementTime = 0;
    } else {
      settlementTime = actAct.getDayCountFraction(date, getSettlementDate(), getUnderlyingBond().getCalendar());
    }
    final AnnuityPaymentFixed nominal = (AnnuityPaymentFixed) getUnderlyingBond().getNominal().toDerivative(date);
    final Annuity<Coupon> coupon = (Annuity<Coupon>) getUnderlyingBond().getCoupons().toDerivative(date, indexFixingTS);
    final AnnuityPaymentFixed nominalPurchase = nominal.trimBefore(settlementTime);
    final Annuity<Coupon> couponPurchase = coupon.trimBefore(settlementTime);
View Full Code Here

    ArgumentChecker.notNull(startDate, "CDS start date");
    ArgumentChecker.notNull(maturity, "CDS maturity");
    ArgumentChecker.notNull(frequency, "frequency");
    ArgumentChecker.notNull(convention, "convention");

    final DayCount dayCount = convention.getDayCount();
    ArgumentChecker.isTrue(!(dayCount instanceof ActualActualICMA) | !(dayCount instanceof ActualActualICMANormal), "Coupon per year required for Actual Actual ICMA");

    // TODO: Handle stubType == StubType.NONE
    final boolean isStubShort = stubType == StubType.SHORT_START || stubType == StubType.SHORT_END;
    final boolean isStubAtEnd = stubType == StubType.SHORT_END || stubType == StubType.LONG_END;

    // If the stub is at the end of the schedule, compute the schedule from the beginning, and vice versa
    final ZonedDateTime[] paymentDates = ScheduleCalculator.getAdjustedDateSchedule(startDate, maturity, frequency,
        isStubShort, !isStubAtEnd, convention.getBusinessDayConvention(), convention.getWorkingDayCalendar(), /* EOM */ false);

    final ZonedDateTime maturityWithOffset = protectStart ? maturity.plusDays(1) : maturity;

    final ISDACDSCouponDefinition[] coupons = new ISDACDSCouponDefinition[paymentDates.length];
    final int maturityIndex = coupons.length - 1;

    if (maturityIndex > 0) {

      // accrual start date is not adjusted for the first coupon
      coupons[0] = new ISDACDSCouponDefinition(currency, paymentDates[0], startDate, paymentDates[0],
          dayCount.getDayCountFraction(startDate, paymentDates[0]), notional, spread);

      for (int i = 1; i < maturityIndex; i++) {
        coupons[i] = new ISDACDSCouponDefinition(currency, paymentDates[i], paymentDates[i - 1], paymentDates[i],
            dayCount.getDayCountFraction(paymentDates[i - 1], paymentDates[i]), notional, spread);
      }

      // Accrual end date is not adjusted for the last coupon
      coupons[maturityIndex] new ISDACDSCouponDefinition(currency, paymentDates[maturityIndex], paymentDates[maturityIndex - 1], maturity,
          dayCount.getDayCountFraction(paymentDates[maturityIndex - 1], maturityWithOffset), notional, spread);

    } else {

      // For a premium consisting of a single payment, neither the accrual start nor end date is adjusted
      coupons[0] = new ISDACDSCouponDefinition(currency, paymentDates[0], startDate, maturity,
          dayCount.getDayCountFraction(startDate, maturityWithOffset), notional, spread);
    }

    return new ISDACDSPremiumDefinition(coupons, calendar);
  }
View Full Code Here

  @Override
  public ForexOptionDigital toDerivative(final ZonedDateTime date, final String... yieldCurveNames) {
    ArgumentChecker.notNull(date, "date");
    ArgumentChecker.notNull(yieldCurveNames, "yieldCurveNames");
    final Forex fx = _underlyingForex.toDerivative(date, yieldCurveNames);
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final double expirationTime = actAct.getDayCountFraction(date, _expirationDate);
    return new ForexOptionDigital(fx, expirationTime, _isCall, _isLong, _payDomestic);
  }
View Full Code Here

   */
  @Override
  public ForexOptionDigital toDerivative(final ZonedDateTime date) {
    ArgumentChecker.notNull(date, "date");
    final Forex fx = _underlyingForex.toDerivative(date);
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final double expirationTime = actAct.getDayCountFraction(date, _expirationDate);
    return new ForexOptionDigital(fx, expirationTime, _isCall, _isLong, _payDomestic);
  }
View Full Code Here

    final Period LENGTH_CMSCAP = Period.ofYears(10);
    final ZonedDateTime START_DATE = ScheduleCalculator.getAdjustedDate(SPOT_DATE, START_CMSCAP, USD_GENERATOR.getIborIndex().getBusinessDayConvention(), CALENDAR, USD_GENERATOR.getIborIndex()
        .isEndOfMonth());
    final ZonedDateTime END_DATE = START_DATE.plus(LENGTH_CMSCAP);
    final Period capPeriod = Period.ofMonths(6);
    final DayCount capDayCount = DayCountFactory.INSTANCE.getDayCount("ACT/360");
    final AnnuityCapFloorCMSDefinition capDefinition = AnnuityCapFloorCMSDefinition.from(START_DATE, END_DATE, NOTIONAL, USD_SWAP_10Y, capPeriod, capDayCount, false, STRIKE, IS_CAP, CALENDAR);
    final Annuity<? extends Payment> cap = capDefinition.toDerivative(REFERENCE_DATE, CURVES_NAME);
    final double pvCalculator = cap.accept(PVC_SABR, SABR_BUNDLE);
    double pvExpected = 0.0;
    for (int loopcpn = 0; loopcpn < cap.getNumberOfPayments(); loopcpn++) {
View Full Code Here

    final Period LENGTH_CMSCAP = Period.ofYears(10);
    final ZonedDateTime START_DATE = ScheduleCalculator.getAdjustedDate(SPOT_DATE, START_CMSCAP, USD_GENERATOR.getIborIndex().getBusinessDayConvention(), CALENDAR, USD_GENERATOR.getIborIndex()
        .isEndOfMonth());
    final ZonedDateTime END_DATE = START_DATE.plus(LENGTH_CMSCAP);
    final Period capPeriod = Period.ofMonths(6);
    final DayCount capDayCount = DayCountFactory.INSTANCE.getDayCount("ACT/360");
    final AnnuityCapFloorCMSDefinition capDefinition = AnnuityCapFloorCMSDefinition.from(START_DATE, END_DATE, NOTIONAL, USD_SWAP_10Y, capPeriod, capDayCount, false, STRIKE, IS_CAP, CALENDAR);
    final Annuity<? extends Payment> cap = capDefinition.toDerivative(REFERENCE_DATE, CURVES_NAME);
    InterestRateCurveSensitivity pvcsCalculator = new InterestRateCurveSensitivity(cap.accept(PVCSC_SABR, SABR_BUNDLE));
    pvcsCalculator = pvcsCalculator.cleaned();
    InterestRateCurveSensitivity pvcsExpected = new InterestRateCurveSensitivity();
View Full Code Here

TOP

Related Classes of com.opengamma.financial.convention.daycount.DayCount

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.