Package com.opengamma.financial.security.swap

Examples of com.opengamma.financial.security.swap.FloatingSpreadIRLeg


      if (random.nextBoolean()) {
        payFrequency = QUARTERLY;
        receiveFrequency = SEMI_ANNUAL;
        payRate = EURIBOR_3M;
        receiveRate = EURIBOR_6M;
        payLeg = new FloatingSpreadIRLeg(ACT_360, payFrequency, REGION, MODIFIED_FOLLOWING, notional, false, payRate, FloatingRateType.IBOR, spread);
        receiveLeg = new FloatingInterestRateLeg(ACT_360, receiveFrequency, REGION, MODIFIED_FOLLOWING, notional, false, receiveRate, FloatingRateType.IBOR);
        frequencyLabel = "pay 3M Euribor + " + FORMATTER.format((int) (spread * 1000)) + "bp, receive 6M Euribor";
      } else {
        payFrequency = SEMI_ANNUAL;
        receiveFrequency = QUARTERLY;
        payRate = EURIBOR_6M;
        receiveRate = EURIBOR_3M;
        payLeg = new FloatingInterestRateLeg(ACT_360, payFrequency, REGION, MODIFIED_FOLLOWING, notional, false, payRate, FloatingRateType.IBOR);
        receiveLeg = new FloatingSpreadIRLeg(ACT_360, receiveFrequency, REGION, MODIFIED_FOLLOWING, notional, false, receiveRate, FloatingRateType.IBOR, spread);
        frequencyLabel = "receive 3M Euribor + " + FORMATTER.format((int) (spread * 1000)) + "bp, pay 6M Euribor";
      }
      final SwapSecurity swap = new SwapSecurity(tradeDate, effectiveDate, maturityDate, COUNTERPARTY, payLeg, receiveLeg);
      final String name = years + "Y EUR " + FORMATTER.format(notional.getAmount() / 1000000) + "MM, " + frequencyLabel;
      swap.setName(name);
View Full Code Here


        final BusinessDayConvention businessDayConvention = swapLeg.getBusinessDayConvention();
        final double notional = interestRateNotional.getAmount();
        final IborIndex iborIndex = new IborIndex(currency, tenorIbor, spotLag, iborIndexConvention.getDayCount(), iborIndexConvention.getBusinessDayConvention(),
            iborIndexConvention.isIsEOM(), iborIndexConvention.getName());
        if (swapLeg instanceof FloatingSpreadIRLeg) {
          final FloatingSpreadIRLeg spread = (FloatingSpreadIRLeg) swapLeg;
          return AnnuityCouponIborSpreadDefinition.from(effectiveDate, maturityDate, tenorIbor, notional, iborIndex, isPayer, businessDayConvention, swapLeg.isEom(), dayCount,
              spread.getSpread(), calendar);
        }
        return AnnuityCouponIborDefinition.from(effectiveDate, maturityDate, tenorIbor, notional, iborIndex, isPayer, businessDayConvention, swapLeg.isEom(), dayCount,
            calendar);
      }

      private AnnuityDefinition<? extends PaymentDefinition> getOISAnnuity(final FloatingInterestRateLeg swapLeg, final InterestRateNotional interestRateNotional,
          final Currency currency) {
        final String oisConventionName = getConventionName(currency, OIS_ON_LEG);
        final OISLegConvention oisConvention = _conventionSource.getConvention(OISLegConvention.class, ExternalId.of(SCHEME_NAME, oisConventionName));
        if (oisConvention == null) {
          throw new OpenGammaRuntimeException("Could not get OIS leg convention with the identifier " + ExternalId.of(SCHEME_NAME, oisConventionName));
        }
        final OvernightIndexConvention indexConvention = _conventionSource.getConvention(OvernightIndexConvention.class, oisConvention.getOvernightIndexConvention());
        if (indexConvention == null) {
          throw new OpenGammaRuntimeException("Could not get OIS index convention with the identifier " + oisConvention.getOvernightIndexConvention());
        }
        final String currencyString = currency.getCode();
        final Integer publicationLag = indexConvention.getPublicationLag();
        final Period paymentFrequency = getTenor(swapLeg.getFrequency());
        final IndexON index = new IndexON(indexConvention.getName(), currency, indexConvention.getDayCount(), publicationLag);
        final BusinessDayConvention businessDayConvention = swapLeg.getBusinessDayConvention();
        final double notional = interestRateNotional.getAmount();
        final int paymentLag = oisConvention.getPaymentLag();
        final boolean isEOM = oisConvention.isIsEOM();
        final Calendar indexCalendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, indexConvention.getRegionCalendar());
        if (swapLeg instanceof FloatingSpreadIRLeg) {
          final FloatingSpreadIRLeg spread = (FloatingSpreadIRLeg) swapLeg;
          return AnnuityCouponONSpreadDefinition.from(effectiveDate, maturityDate, notional, isPayer, index, paymentLag, indexCalendar, businessDayConvention, paymentFrequency, isEOM,
              spread.getSpread());
        }
        return AnnuityCouponONDefinition.from(effectiveDate, maturityDate, notional, isPayer, index, paymentLag, indexCalendar, businessDayConvention, paymentFrequency, isEOM);
      }

      private AnnuityDefinition<? extends PaymentDefinition> getCMSAnnuity(final FloatingInterestRateLeg swapLeg, final InterestRateNotional interestRateNotional,
          final Currency currency, final Calendar calendar) {
        if (swapLeg instanceof FloatingSpreadIRLeg) {
          throw new OpenGammaRuntimeException("Cannot create an annuity for a CMS leg with a spread");
        }
        final String tenorString = getTenorString(swapLeg.getFrequency());
        final String iborLegConventionName = getConventionName(currency, tenorString, IRS_IBOR_LEG);
        final VanillaIborLegConvention iborLegConvention = _conventionSource.getConvention(VanillaIborLegConvention.class,
            ExternalId.of(SCHEME_NAME, getConventionName(currency, tenorString, IRS_IBOR_LEG)));
        if (iborLegConvention == null) {
          throw new OpenGammaRuntimeException("Could not get Ibor leg convention with the identifier " + ExternalId.of(SCHEME_NAME, iborLegConventionName));
        }
        final IborIndexConvention iborIndexConvention = _conventionSource.getConvention(IborIndexConvention.class, iborLegConvention.getIborIndexConvention());
        final String swapIndexConventionName = getConventionName(currency, tenorString, SWAP_INDEX);
        final SwapIndexConvention swapIndexConvention = _conventionSource.getConvention(SwapIndexConvention.class, ExternalId.of(SCHEME_NAME, swapIndexConventionName));
        if (swapIndexConvention == null) {
          throw new OpenGammaRuntimeException("Could not get swap index convention with the identifier " + ExternalId.of(SCHEME_NAME, swapIndexConventionName));
        }
        final SwapConvention underlyingSwapConvention = _conventionSource.getConvention(SwapConvention.class, swapIndexConvention.getSwapConvention());
        if (underlyingSwapConvention == null) {
          throw new OpenGammaRuntimeException("Could not get swap convention with the identifier " + swapIndexConvention.getSwapConvention());
        }
        final SwapFixedLegConvention payLegConvention = _conventionSource.getConvention(SwapFixedLegConvention.class, underlyingSwapConvention.getPayLegConvention());
        if (payLegConvention == null) {
          throw new OpenGammaRuntimeException("Could not get convention with the identifier " + underlyingSwapConvention.getPayLegConvention());
        }
        final VanillaIborLegConvention receiveLegConvention = _conventionSource.getConvention(VanillaIborLegConvention.class, underlyingSwapConvention.getReceiveLegConvention());
        if (receiveLegConvention == null) {
          throw new OpenGammaRuntimeException("Could not get convention with the identifier " + underlyingSwapConvention.getReceiveLegConvention());
        }
        final Frequency freqIbor = swapLeg.getFrequency();
        final Period tenorIbor = getTenor(freqIbor);
        final int spotLag = iborIndexConvention.getSettlementDays();
        final DayCount dayCount = swapLeg.getDayCount();
        final BusinessDayConvention businessDayConvention = swapLeg.getBusinessDayConvention();
        final double notional = interestRateNotional.getAmount();
        final IborIndex iborIndex = new IborIndex(currency, tenorIbor, spotLag, iborIndexConvention.getDayCount(), iborIndexConvention.getBusinessDayConvention(),
            iborIndexConvention.isIsEOM(), iborIndexConvention.getName());
        final Period fixedLegPaymentPeriod = payLegConvention.getPaymentTenor().getPeriod();
        final DayCount fixedLegDayCount = payLegConvention.getDayCount();
        final Period period = Period.ofYears(10); // TODO why is a variable field like this in IndexSwap? It's only used in one place in the entire analytics library.
        final IndexSwap swapIndex = new IndexSwap(fixedLegPaymentPeriod, fixedLegDayCount, iborIndex, period, calendar);
        return AnnuityCouponCMSDefinition.from(effectiveDate, maturityDate, notional, swapIndex, tenorIbor, dayCount, isPayer, calendar);
      }

      private AnnuityDefinition<? extends PaymentDefinition> getOvernightAAverageAnnuity(final FloatingInterestRateLeg swapLeg, final InterestRateNotional interestRateNotional,
          final Currency currency) {
        final String oisConventionName = getConventionName(currency, OIS_ON_LEG);
        final OISLegConvention oisConvention = _conventionSource.getConvention(OISLegConvention.class, ExternalId.of(SCHEME_NAME, oisConventionName));
        if (oisConvention == null) {
          throw new OpenGammaRuntimeException("Could not get OIS leg convention with the identifier " + ExternalId.of(SCHEME_NAME, oisConventionName));
        }
        final OvernightIndexConvention indexConvention = _conventionSource.getConvention(OvernightIndexConvention.class, oisConvention.getOvernightIndexConvention());
        if (indexConvention == null) {
          throw new OpenGammaRuntimeException("Could not get OIS index convention with the identifier " + oisConvention.getOvernightIndexConvention());
        }
        final String currencyString = currency.getCode();
        final Integer publicationLag = indexConvention.getPublicationLag();
        final Period paymentFrequency = getTenor(swapLeg.getFrequency());
        final IndexON index = new IndexON(indexConvention.getName(), currency, indexConvention.getDayCount(), publicationLag);
        final BusinessDayConvention businessDayConvention = swapLeg.getBusinessDayConvention();
        final double notional = interestRateNotional.getAmount();
        final int paymentLag = oisConvention.getPaymentLag();
        final boolean isEOM = oisConvention.isIsEOM();
        final Calendar indexCalendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, indexConvention.getRegionCalendar());
        if (swapLeg instanceof FloatingSpreadIRLeg) {
          final FloatingSpreadIRLeg spread = (FloatingSpreadIRLeg) swapLeg;
          return AnnuityCouponArithmeticAverageONSpreadDefinition.from(effectiveDate, maturityDate, notional, spread.getSpread(), isPayer, paymentFrequency, index,
              paymentLag, businessDayConvention, isEOM, indexCalendar);
        }
        return AnnuityCouponArithmeticAverageONDefinition.from(effectiveDate, maturityDate, notional, isPayer, paymentFrequency, index, paymentLag,
            businessDayConvention, isEOM, indexCalendar);
      }
View Full Code Here

    final Frequency receiveFrequency = PeriodFrequency.of(fixedIncomeStrip.getReceiveTenor().getPeriod());
    final BusinessDayConvention receiveBusinessDayConvention = receiveConvention.getBusinessDayConvention();
    final FloatingRateType receiveFloatingRateType = getFloatingTypeFromIndexType(fixedIncomeStrip.getReceiveIndexType());
    final double spread = marketValues.getDataPoint(swapIdentifier);
    // Implementation note: By convention the spread is on the first leg (shorter tenor)
    final FloatingSpreadIRLeg payLeg = new FloatingSpreadIRLeg(payDayCount, payFrequency, payRegionIdentifier, payBusinessDayConvention, notional, false, payFloatingReferenceRateId,
        payFloatingRateType, spread);
    final FloatingInterestRateLeg receiveLeg = new FloatingInterestRateLeg(receiveDayCount, receiveFrequency, receiveRegionIdentifier, receiveBusinessDayConvention, notional, false,
        receiveFloatingReferenceRateId, receiveFloatingRateType);
    //TODO don't use pay spot date and maturity date automatically
    final SwapSecurity swap = new SwapSecurity(curveDate, paySpotDate, payMaturityDate, counterparty, payLeg, receiveLeg);
View Full Code Here

    final double spread = rate;
    // REVIEW: jim 25-Aug-2010 -- we need to change the swap to take settlement days.

    final SwapSecurity swap = new SwapSecurity(tradeDate, effectiveDate, maturityDate, counterparty, new FloatingInterestRateLeg(convention.getBasisSwapPayFloatingLegDayCount(),
        convention.getBasisSwapPayFloatingLegFrequency(), convention.getBasisSwapPayFloatingLegRegion(), convention.getBasisSwapPayFloatingLegBusinessDayConvention(), new InterestRateNotional(
            spec.getCurrency(), 1), false, payLegFloatRateBloombergTicker, FloatingRateType.IBOR), new FloatingSpreadIRLeg(convention.getBasisSwapReceiveFloatingLegDayCount(),
                convention.getBasisSwapReceiveFloatingLegFrequency(), convention.getBasisSwapReceiveFloatingLegRegion(), convention.getBasisSwapReceiveFloatingLegBusinessDayConvention(),
                new InterestRateNotional(spec.getCurrency(), 1), false, receiveLegFloatRateBloombergTicker, FloatingRateType.IBOR, spread));
    swap.setExternalIdBundle(ExternalIdBundle.of(swapIdentifier));
    return swap;
  }
View Full Code Here

        return floatingInterestRateLeg;
      }

      @Override
      public SwapLeg visitFloatingSpreadIRLeg(FloatingSpreadIRLeg ignore) {
        FloatingSpreadIRLeg floatingSpreadIRLeg = new FloatingSpreadIRLeg(
            dayCountBeanToDayCount(bean.getDayCount()),
            frequencyBeanToFrequency(bean.getFrequency()),
            externalIdBeanToExternalId(bean.getRegion()),
            businessDayConventionBeanToBusinessDayConvention(bean.getBusinessDayConvention()),
            NotionalBeanOperation.createNotional(bean.getNotional()),
            bean.isEom(),
            externalIdBeanToExternalId(bean.getRateIdentifier()),
            bean.getFloatingRateType(), bean.getSpread());
        floatingSpreadIRLeg.setInitialFloatingRate(bean.getRate());
        floatingSpreadIRLeg.setSettlementDays(bean.getSettlementDays());
        floatingSpreadIRLeg.setOffsetFixing(frequencyBeanToFrequency(bean.getOffsetFixing()));
        return floatingSpreadIRLeg;
      }

      @Override
      public SwapLeg visitFloatingGearingIRLeg(FloatingGearingIRLeg ignore) {
View Full Code Here

      if (RANDOM.nextBoolean()) {
        payFrequency = QUARTERLY;
        receiveFrequency = SEMI_ANNUAL;
        payRate = EURIBOR_3M;
        receiveRate = EURIBOR_6M;
        payLeg = new FloatingSpreadIRLeg(ACT_360, payFrequency, REGION, MODIFIED_FOLLOWING, notional, false, payRate, FloatingRateType.IBOR, spread);
        receiveLeg = new FloatingInterestRateLeg(ACT_360, receiveFrequency, REGION, MODIFIED_FOLLOWING, notional, false, receiveRate, FloatingRateType.IBOR);
        frequencyLabel = "pay 3M Euribor + " + FORMATTER.format((int) (spread * 1000)) + "bp, receive 6M Euribor";
      } else {
        payFrequency = SEMI_ANNUAL;
        receiveFrequency = QUARTERLY;
        payRate = EURIBOR_6M;
        receiveRate = EURIBOR_3M;
        payLeg = new FloatingInterestRateLeg(ACT_360, payFrequency, REGION, MODIFIED_FOLLOWING, notional, false, payRate, FloatingRateType.IBOR);
        receiveLeg = new FloatingSpreadIRLeg(ACT_360, receiveFrequency, REGION, MODIFIED_FOLLOWING, notional, false, receiveRate, FloatingRateType.IBOR, spread);
        frequencyLabel = "receive 3M Euribor + " + FORMATTER.format((int) (spread * 1000)) + "bp, pay 6M Euribor";
      }
      final SwapSecurity swap = new SwapSecurity(tradeDate, effectiveDate, maturityDate, COUNTERPARTY, payLeg, receiveLeg);
      final String name = years + "Y EUR " + FORMATTER.format(notional.getAmount() / 1000000) + "MM, " + frequencyLabel;
      swap.setName(name);
View Full Code Here

            BUSINESS_DAY,
            new InterestRateNotional(Currency.USD, 123000000),
            true,
            ExternalId.of(ExternalSchemes.OG_SYNTHETIC_TICKER, "USDISDA10P1Y"),
            FloatingRateType.CMS),
        new FloatingSpreadIRLeg(DAY_COUNT,
            SimpleFrequency.QUARTERLY,
            ExternalSchemes.countryRegionId(Country.of("US")),
            BUSINESS_DAY,
            new InterestRateNotional(Currency.USD, 123000000),
            true,
View Full Code Here

                                                                       businessDayConvention,
                                                                       calendar,
                                                                       eomLeg);
    if (isFloatFloat) {
      //return AnnuityCouponIborSpreadDefinition.from(startDate, maturityTenor, 1, iborIndex, spread, isPayer, calendar);
      return Pair.of(new FloatingSpreadIRLeg(dayCount,
                                             PeriodFrequency.of(convention.getResetTenor().getPeriod()),
                                             indexConvention.getRegionCalendar(),
                                             businessDayConvention,
                                             new InterestRateNotional(currency, _amount),
                                             eomLeg,
View Full Code Here

                                                                       businessDayConvention,
                                                                       calendar,
                                                                       eomLeg);
    if (isFloatFloat) {
      //return AnnuityCouponONSpreadSimplifiedDefinition.from(startDate, maturityTenor, 1, spread, isPayer, indexON, paymentLag, calendar, businessDayConvention, paymentPeriod, eomLeg);
      return Pair.of(new FloatingSpreadIRLeg(dayCount,
                                             PeriodFrequency.of(paymentPeriod),
                                             indexConvention.getRegionCalendar(),
                                             businessDayConvention,
                                             new InterestRateNotional(currency, _amount),
                                             eomLeg,
View Full Code Here

TOP

Related Classes of com.opengamma.financial.security.swap.FloatingSpreadIRLeg

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.