Examples of FixedInterestRateLeg


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

  private static ZeroCouponInflationSwapSecurity zciSwap(final SwapLeg payLeg, final SwapLeg receiveLeg) {
    return new ZeroCouponInflationSwapSecurity(ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), "cpty", payLeg, receiveLeg);
  }

  private static SwapLeg fixedLeg(final Frequency frequency) {
    return new FixedInterestRateLeg(DayCountFactory.INSTANCE.getDayCount("Actual/360"),
        frequency,
        ExternalId.of("Reg", "123"),
        BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following"),
        new InterestRateNotional(Currency.USD, 1234),
        true,
View Full Code Here

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

      swap = ((SwaptionCashFixedCompoundedONCompoundingDefinition) swaption).getUnderlyingSwap();
    } else {
      throw new OpenGammaRuntimeException("Can only handle cash- and physically-settled ibor swaptions");
    }
    final SwapSecurity underlyingSecurity = (SwapSecurity) securitySource.getSingle(ExternalIdBundle.of(security.getUnderlyingId()));
    FixedInterestRateLeg fixedLeg;
    FloatingInterestRateLeg floatLeg;
    if (underlyingSecurity.getPayLeg() instanceof FixedInterestRateLeg) {
      fixedLeg = (FixedInterestRateLeg) underlyingSecurity.getPayLeg();
      floatLeg = (FloatingInterestRateLeg) underlyingSecurity.getReceiveLeg();
    } else {
      fixedLeg = (FixedInterestRateLeg) underlyingSecurity.getReceiveLeg();
      floatLeg = (FloatingInterestRateLeg) underlyingSecurity.getPayLeg();
    }
    switch (floatLeg.getFloatingRateType()) {
      case IBOR: {
        AnnuityCouponIborDefinition iborLeg;
        if (swap.getFirstLeg() instanceof AnnuityCouponIborDefinition) {
          iborLeg = (AnnuityCouponIborDefinition) swap.getFirstLeg();
        } else if (swap.getSecondLeg() instanceof AnnuityCouponIborDefinition) {
          iborLeg = (AnnuityCouponIborDefinition) swap.getSecondLeg();
        } else {
          throw new OpenGammaRuntimeException("Could not find ibor leg for " + underlyingSecurity);
        }
        final IborIndex iborIndex = iborLeg.getIborIndex();
        final Calendar calendar = iborLeg.getIborCalendar();
        final DayCount fixedLegDayCount = fixedLeg.getDayCount();
        final Frequency frequency = fixedLeg.getFrequency();
        final Period fixedLegPeriod;
        if (frequency instanceof PeriodFrequency) {
          fixedLegPeriod = ((PeriodFrequency) frequency).getPeriod();
        } else if (frequency instanceof SimpleFrequency) {
          fixedLegPeriod = ((SimpleFrequency) frequency).toPeriodFrequency().getPeriod();
        } else {
          throw new OpenGammaRuntimeException("Can only handle PeriodFrequency or SimpleFrequency");
        }
        return new GeneratorSwapFixedIbor("Swap Generator", fixedLegPeriod, fixedLegDayCount, iborIndex, calendar);
      }
      case OIS: {
        IndexON onIndex;
        Calendar calendar;
        if (swap.getFirstLeg() instanceof AnnuityCouponONDefinition) {
          final AnnuityCouponONDefinition annuityCouponONDefinition = (AnnuityCouponONDefinition) swap.getFirstLeg();
          onIndex = annuityCouponONDefinition.getOvernightIndex();
          calendar = annuityCouponONDefinition.getCalendar();
        } else if (swap.getSecondLeg() instanceof AnnuityCouponONDefinition) {
          final AnnuityCouponONDefinition annuityCouponONDefinition = (AnnuityCouponONDefinition) swap.getSecondLeg();
          onIndex = annuityCouponONDefinition.getOvernightIndex();
          calendar = annuityCouponONDefinition.getCalendar();
        } else if (swap.getFirstLeg().getNthPayment(0) instanceof CouponONCompoundedDefinition) {
          final CouponONCompoundedDefinition couponONDefinition = (CouponONCompoundedDefinition) swap.getFirstLeg().getNthPayment(0);
          onIndex = couponONDefinition.getIndex();
          calendar = couponONDefinition.getCalendar();
        } else if (swap.getSecondLeg().getNthPayment(0) instanceof CouponONCompoundedDefinition) {
          final CouponONCompoundedDefinition couponONDefinition = (CouponONCompoundedDefinition) swap.getSecondLeg().getNthPayment(0);
          onIndex = couponONDefinition.getIndex();
          calendar = couponONDefinition.getCalendar();
        } else {
          throw new OpenGammaRuntimeException("Could not find overnight leg for " + underlyingSecurity);
        }
        final DayCount fixedLegDayCount = fixedLeg.getDayCount();
        final Frequency frequency = fixedLeg.getFrequency();
        final Period fixedLegPeriod;
        if (frequency instanceof PeriodFrequency) {
          fixedLegPeriod = ((PeriodFrequency) frequency).getPeriod();
        } else if (frequency instanceof SimpleFrequency) {
          fixedLegPeriod = ((SimpleFrequency) frequency).toPeriodFrequency().getPeriod();
        } else {
          throw new OpenGammaRuntimeException("Can only handle PeriodFrequency or SimpleFrequency");
        }
        final BusinessDayConvention businessDayConvention = fixedLeg.getBusinessDayConvention();
        final boolean isEOM = fixedLeg.isEom();
        final int spotLag = 0; //TODO
        if (FinancialSecurityUtils.getCurrency(underlyingSecurity).getCode().equals("BRL")) {
          return new GeneratorSwapFixedCompoundedONCompounded("Swap Generator", onIndex, fixedLegDayCount, businessDayConvention, isEOM, spotLag, calendar);
        }
        return new GeneratorSwapFixedON("Swap Generator", onIndex, fixedLegPeriod, fixedLegDayCount, businessDayConvention, isEOM, spotLag, calendar);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.