Package com.opengamma.financial.convention.frequency

Examples of com.opengamma.financial.convention.frequency.PeriodFrequency


    final ExternalId regionId = security.getRegionId();
    final Calendar calendar = new HolidaySourceCalendarAdapter(_holidaySource, _regionSource.getHighestLevelRegion(regionId));
    final ZonedDateTime startDate = security.getStartDate();
    final ZonedDateTime effectiveDate = security.getEffectiveDate();
    final ZonedDateTime maturityDate = security.getMaturityDate();
    final PeriodFrequency couponFrequency = getPeriodFrequency(security.getCouponFrequency());
    final DayCount dayCount = security.getDayCount();
    final BusinessDayConvention businessDayConvention = security.getBusinessDayConvention();
    final boolean immAdjustMaturityDate = security.isImmAdjustMaturityDate();
    final boolean adjustEffectiveDate = security.isAdjustEffectiveDate();
    final boolean adjustMaturityDate = security.isAdjustMaturityDate();
View Full Code Here


    final ExternalId regionId = security.getRegionId();
    final Calendar calendar = new HolidaySourceCalendarAdapter(_holidaySource, _regionSource.getHighestLevelRegion(regionId));
    final ZonedDateTime startDate = security.getStartDate();
    final ZonedDateTime effectiveDate = security.getEffectiveDate();
    final ZonedDateTime maturityDate = security.getMaturityDate();
    final PeriodFrequency couponFrequency = getPeriodFrequency(security.getCouponFrequency());
    final DayCount dayCount = security.getDayCount();
    final BusinessDayConvention businessDayConvention = security.getBusinessDayConvention();
    final boolean immAdjustMaturityDate = security.isImmAdjustMaturityDate();
    final boolean adjustEffectiveDate = security.isAdjustEffectiveDate();
    final boolean adjustMaturityDate = security.isAdjustMaturityDate();
View Full Code Here

    @SuppressWarnings("synthetic-access")
    private SwapSecurity createSwap(final Tenor tenor) {
      final ZonedDateTime maturityDate = _tradeDate.plus(tenor.getPeriod());
      ExternalId iborReferenceRate;
      PeriodFrequency frequency;
      if (RANDOM.nextBoolean()) {
        iborReferenceRate = LIBOR_3M;
        frequency = PeriodFrequency.QUARTERLY;
      } else {
        iborReferenceRate = LIBOR_6M;
        frequency = PeriodFrequency.SEMI_ANNUAL;
      }
      final FloatingInterestRateLeg iborLeg = new FloatingInterestRateLeg(ACT_360, frequency, REGION, FOLLOWING, _notional, true,
          iborReferenceRate, FloatingRateType.IBOR);
      final String ticker = "USDISDA10" + tenor.getPeriod().toString();
      final ExternalId cmsReferenceRate = ExternalSchemes.syntheticSecurityId(ticker);
      final FloatingInterestRateLeg cmsLeg = new FloatingInterestRateLeg(ACT_360, frequency, REGION, FOLLOWING, _notional, true,
          cmsReferenceRate, FloatingRateType.CMS);
      SwapSecurity security;
      boolean payIbor;
      if (RANDOM.nextBoolean()) {
        security = new SwapSecurity(_tradeDate, _tradeDate, maturityDate, COUNTERPARTY, iborLeg, cmsLeg);
        payIbor = true;
      } else {
        security = new SwapSecurity(_tradeDate, _tradeDate, maturityDate, COUNTERPARTY, cmsLeg, iborLeg);
        payIbor = false;
      }
      security.setName(CURRENCY.getCode() + " " + FORMAT.format(_notional.getAmount() / 1000000) + "MM Swap, pay " +
          (payIbor ? frequency.getPeriod().getMonths() + "M Libor, receive " + tenor.getPeriod().getYears() + "Y ISDA fixing (" :
            tenor.getPeriod().getYears() + "Y ISDA fixing, receive " + frequency.getPeriod().getMonths() + "M Libor (") +
            _tradeDate.toLocalDate().toString() + " - " + maturityDate.toLocalDate().toString() + ")");
      return security;
    }
View Full Code Here

    // Get the coupon stub type
    final StubType stubType = cds.getStubType();

    // Get the coupon frequency
    final PeriodFrequency couponFrequency = cds.getCouponFrequency();

    // Compute the number of cashflows in the premium leg schedule (based on the adjusted effective and maturity dates and the coupon frequency and stub type)
    final int numberOfCashflows = calculateNumberOfPremiumLegCashflows(adjustedEffectiveDate, adjustedMaturityDate, couponFrequency, stubType);

    //final int numberOfCashflows = calculateNumberOfPremiumLegCashflows(startDate, adjustedMaturityDate, couponFrequency, stubType);

    // TODO : Need to check if there are less than two cashflow dates

    // Build the cashflow schedule (include the node at the effective date even though there is no cashflow on this date)
    final ZonedDateTime[] cashflowSchedule = new ZonedDateTime[numberOfCashflows + 1];

    // -------------------------------------------------------------------------------

    // The stub is at the front of the premium leg schedule
    if (stubType == StubType.FRONTSHORT || stubType == StubType.FRONTLONG) {

      // Start at the adjusted maturity of the contract
      ZonedDateTime cashflowDate = adjustedMaturityDate;

      /*
      int i = 0;

      cashflowSchedule[i] = cashflowDate;

      while (cashflowDate.isAfter(startDate)) {
        i++;
        cashflowDate = cashflowDate.minus(couponFrequency.getPeriod());
        cashflowSchedule[i] = cashflowDate;
      }
       */

      // Note the order of the loop and the termination condition (i > 0 not i = 0)
      for (int i = numberOfCashflows; i > 0; i--) {

        // Store the date (note this is at the top of the loop)
        cashflowSchedule[i] = cashflowDate;

        // Step back in time by the specified number of months
        cashflowDate = cashflowDate.minus(couponFrequency.getPeriod());
      }

      // TODO : Sort this out

      if (stubType == StubType.FRONTSHORT) {
        // Append the timenode at the adjusted effective date at the beginning of the cashflow schedule vector
        cashflowSchedule[0] = adjustedEffectiveDate;
      }

      if (stubType == StubType.FRONTLONG) {
        cashflowSchedule[0] = cashflowDate.minus(couponFrequency.getPeriod());
      }

    }

    // -------------------------------------------------------------------------------

    // TODO : Test this code
    // TODO : Add the appendage at the end

    // The stub is at the back of the premium leg schedule
    if (stubType == StubType.BACKSHORT || stubType == StubType.BACKLONG) {

      // Start at the adjusted effective date of the contract
      ZonedDateTime cashflowDate = adjustedEffectiveDate;

      /*
      int i = 0;

      cashflowSchedule[i] = cashflowDate;

      while (cashflowDate.isBefore(adjustedMaturityDate)) {
        i++;
        cashflowDate = cashflowDate.plus(couponFrequency.getPeriod());
        cashflowSchedule[i] = cashflowDate;
      }
       */

      for (int i = 0; i < numberOfCashflows; i++) {

        // Store the date (note this is at the top of the loop)
        cashflowSchedule[i] = cashflowDate;

        // Step forward in time by the specified number of months
        cashflowDate = cashflowDate.plus(couponFrequency.getPeriod());
      }

    }

    // -------------------------------------------------------------------------------
View Full Code Here

TOP

Related Classes of com.opengamma.financial.convention.frequency.PeriodFrequency

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.