Package com.opengamma.financial.security.swap

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


    final ConventionBundle fixedLegConvention = getFixedLegConvention(spec, strip, swapIdentifier);
    final ZonedDateTime curveDate = spec.getCurveDate().atStartOfDay(ZoneOffset.UTC);
    final String counterparty = "";
    Calendar calendar;
    ExternalId floatingRateId;
    FloatingInterestRateLeg iborLeg;
    final ExternalId underlyingId = getUnderlyingId(spec, strip);
    if (underlyingId == null) {
      s_logger.info("Could not get convention for underlying from {}; trying tenor-based convention", strip);
      final ExternalId id = ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, spec.getCurrency().getCode() + "_" + months + "M_SWAP");
      ConventionBundle floatingLegConvention = _conventionBundleSource.getConventionBundle(id);
      if (floatingLegConvention == null) {
        floatingLegConvention = _conventionBundleSource.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME,
            spec.getCurrency().getCode() + "_" + months + "_SWAP"));
        if (floatingLegConvention == null) {
          throw new OpenGammaRuntimeException("Could not get floating leg convention for swap strip " + strip);
        }
      }
      calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, floatingLegConvention.getSwapFloatingLegRegion());
      floatingRateId = floatingLegConvention.getSwapFloatingLegInitialRate();
      if (floatingRateId == null) {
        throw new OpenGammaRuntimeException("Could not get floating rate id from convention");
      }
      iborLeg = new FloatingInterestRateLeg(floatingLegConvention.getSwapFloatingLegDayCount(), floatingLegConvention.getSwapFloatingLegFrequency(),
          floatingLegConvention.getSwapFloatingLegRegion(), floatingLegConvention.getSwapFloatingLegBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, floatingRateId,
          FloatingRateType.IBOR);
    } else {
      final ConventionBundle underlyingConvention = _conventionBundleSource.getConventionBundle(underlyingId);
      if (underlyingConvention == null || underlyingConvention.getIdentifiers().size() != 1) {
        s_logger.info("Could not get unique convention for underlying from {}; trying tenor-based convention", strip);
        ConventionBundle floatingLegConvention = _conventionBundleSource.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME,
            spec.getCurrency().getCode() + "_" + months + "M_SWAP"));
        if (floatingLegConvention == null) {
          floatingLegConvention = _conventionBundleSource.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME,
              spec.getCurrency().getCode() + "_" + months + "_SWAP"));
          if (floatingLegConvention == null) {
            throw new OpenGammaRuntimeException("Could not get floating leg convention for swap strip " + strip);
          }
        }
        calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, floatingLegConvention.getSwapFloatingLegRegion());
        floatingRateId = floatingLegConvention.getSwapFloatingLegInitialRate();
        if (floatingRateId == null) {
          throw new OpenGammaRuntimeException("Could not get floating rate id from convention");
        }
        iborLeg = new FloatingInterestRateLeg(floatingLegConvention.getSwapFloatingLegDayCount(), floatingLegConvention.getSwapFloatingLegFrequency(),
            floatingLegConvention.getSwapFloatingLegRegion(), floatingLegConvention.getSwapFloatingLegBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, floatingRateId,
            FloatingRateType.IBOR);
      } else {
        calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, underlyingConvention.getRegion());
        final ExternalId underlyingTicker = Iterables.getOnlyElement(underlyingConvention.getIdentifiers());
        iborLeg = new FloatingInterestRateLeg(underlyingConvention.getDayCount(), PeriodFrequency.of(underlyingConvention.getPeriod()),
            underlyingConvention.getRegion(), underlyingConvention.getBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, underlyingTicker,
            FloatingRateType.IBOR);
      }
    }
    final ZonedDateTime spotDate = ScheduleCalculator.getAdjustedDate(curveDate, fixedLegConvention.getSwapFixedLegSettlementDays(), calendar);
View Full Code Here


    final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, convention.getSwapFloatingLegRegion());
    final ZonedDateTime spotDate = ScheduleCalculator.getAdjustedDate(curveDate, convention.getSwapFixedLegSettlementDays(), calendar);
    final ZonedDateTime maturityDate = spotDate.plus(strip.getMaturity().getPeriod());
    final FixedInterestRateLeg fixedLeg = new FixedInterestRateLeg(convention.getSwapFixedLegDayCount(), convention.getSwapFixedLegFrequency(),
        convention.getSwapFixedLegRegion(), convention.getSwapFixedLegBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, rate);
    final FloatingInterestRateLeg iborLeg = new FloatingInterestRateLeg(convention.getSwapFloatingLegDayCount(), convention.getSwapFloatingLegFrequency(),
        convention.getSwapFloatingLegRegion(), convention.getSwapFloatingLegBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, convention.getSwapFloatingLegInitialRate(),
        FloatingRateType.OIS); //convention type is wrong but it's ignored in the converter anyway.
    final String counterparty = "";
    final SwapSecurity swap = new SwapSecurity(curveDate, spotDate, maturityDate, counterparty, iborLeg, fixedLeg);
    swap.setExternalIdBundle(ExternalIdBundle.of(swapIdentifier));
View Full Code Here

    }
    final ZonedDateTime curveDate = spec.getCurveDate().atStartOfDay(ZoneOffset.UTC);
    final String counterparty = "";
    Calendar calendar;
    ExternalId floatingRateId;
    FloatingInterestRateLeg iborLeg;
    final ExternalId underlyingId = getUnderlyingId(spec, strip);
    if (underlyingId == null) {
      s_logger.info("Could not get convention for underlying from {}; trying tenor-based convention", strip);
      final ExternalId id = ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, spec.getCurrency().getCode() + "_28D_SWAP");
      final ConventionBundle floatingLegConvention = _conventionBundleSource.getConventionBundle(id);
      if (floatingLegConvention == null) {
        throw new OpenGammaRuntimeException("Could not get floating leg convention for swap strip " + strip);
      }
      calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, floatingLegConvention.getSwapFloatingLegRegion());
      floatingRateId = floatingLegConvention.getSwapFloatingLegInitialRate();
      if (floatingRateId == null) {
        throw new OpenGammaRuntimeException("Could not get floating rate id from convention");
      }
      iborLeg = new FloatingInterestRateLeg(floatingLegConvention.getSwapFloatingLegDayCount(), floatingLegConvention.getSwapFloatingLegFrequency(),
          floatingLegConvention.getSwapFloatingLegRegion(), floatingLegConvention.getSwapFloatingLegBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, floatingRateId,
          FloatingRateType.IBOR);
    } else {
      final ConventionBundle underlyingConvention = _conventionBundleSource.getConventionBundle(underlyingId);
      if (underlyingConvention == null || underlyingConvention.getIdentifiers().size() != 1) {
        s_logger.info("Could not get unique convention for underlying from {}; trying tenor-based convention", strip);
        final ConventionBundle floatingLegConvention = _conventionBundleSource.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME,
            spec.getCurrency().getCode() + "_28D_SWAP"));
        if (floatingLegConvention == null) {
          throw new OpenGammaRuntimeException("Could not get floating leg convention for swap strip " + strip);
        }
        calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, floatingLegConvention.getSwapFloatingLegRegion());
        floatingRateId = floatingLegConvention.getSwapFloatingLegInitialRate();
        if (floatingRateId == null) {
          throw new OpenGammaRuntimeException("Could not get floating rate id from convention");
        }
        iborLeg = new FloatingInterestRateLeg(floatingLegConvention.getSwapFloatingLegDayCount(), floatingLegConvention.getSwapFloatingLegFrequency(),
            floatingLegConvention.getSwapFloatingLegRegion(), floatingLegConvention.getSwapFloatingLegBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, floatingRateId,
            FloatingRateType.IBOR);
      } else {
        calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, underlyingConvention.getRegion());
        final ExternalId underlyingTicker = Iterables.getOnlyElement(underlyingConvention.getIdentifiers());
        iborLeg = new FloatingInterestRateLeg(underlyingConvention.getDayCount(), PeriodFrequency.of(underlyingConvention.getPeriod()),
            underlyingConvention.getRegion(), underlyingConvention.getBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, underlyingTicker,
            FloatingRateType.IBOR);
      }
    }
    final ZonedDateTime spotDate = ScheduleCalculator.getAdjustedDate(curveDate, fixedLegConvention.getSwapFixedLegSettlementDays(), calendar);
View Full Code Here

    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);
    swap.setExternalIdBundle(ExternalIdBundle.of(swapIdentifier));
    return swap;
View Full Code Here

      throw new OpenGammaRuntimeException("Could not get spread; was trying " + swapIdentifier);
    }
    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));
View Full Code Here

      floatingReferenceRateId = swapConvention.getSwapFloatingLegInitialRate();
      if (floatingReferenceRateId == null) {
        throw new OpenGammaRuntimeException("Could not get floating reference rate from convention");
      }
    }
    final FloatingInterestRateLeg oisLeg = new FloatingInterestRateLeg(swapConvention.getSwapFloatingLegDayCount(), floatingFrequency,
        swapConvention.getSwapFloatingLegRegion(), swapConvention.getSwapFloatingLegBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, floatingReferenceRateId,
        FloatingRateType.OIS);
    final FixedInterestRateLeg fixedLeg = new FixedInterestRateLeg(swapConvention.getSwapFixedLegDayCount(), swapConvention.getSwapFixedLegFrequency(), swapConvention.getSwapFixedLegRegion(),
        swapConvention.getSwapFixedLegBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, rate);
    final SwapSecurity swap = new SwapSecurity(curveDate, spotDate, maturityDate, counterparty, oisLeg, fixedLeg);
View Full Code Here

        swapConvention.getSwapFixedLegFrequency(),
        swapConvention.getSwapFixedLegRegion(),
        swapConvention.getSwapFixedLegBusinessDayConvention(),
        new InterestRateNotional(ccy, notional),
        false, fixedRate);
    FloatingInterestRateLeg floatingLeg = new FloatingInterestRateLeg(swapConvention.getSwapFloatingLegDayCount(),
        swapConvention.getSwapFloatingLegFrequency(),
        swapConvention.getSwapFloatingLegRegion(),
        swapConvention.getSwapFloatingLegBusinessDayConvention(),
        new InterestRateNotional(ccy, notional),
        false, tsIdentifier,
        FloatingRateType.IBOR);
    floatingLeg.setInitialFloatingRate(initialRate);
    String fixedLegDescription = RATE_FORMATTER.format(fixedRate);
    String floatingLegDescription = swapConvention.getSwapFloatingLegInitialRate().getValue();
    boolean isPayFixed = getRandom().nextBoolean();
    SwapLeg payLeg;
    String payLegDescription;
View Full Code Here

      swapConvention.getSwapFixedLegRegion(),
      swapConvention.getSwapFixedLegBusinessDayConvention(),
      new InterestRateNotional(ccy, notional),
      false, fixedRate);

    final FloatingInterestRateLeg floatingLeg = new FloatingInterestRateLeg(swapConvention.getSwapFloatingLegDayCount(),
      swapConvention.getSwapFloatingLegFrequency(),
      swapConvention.getSwapFloatingLegRegion(),
      swapConvention.getSwapFloatingLegBusinessDayConvention(),
      new InterestRateNotional(ccy, notional),
      false, ExternalId.of(liborIdentifier.getScheme().toString(), liborIdentifier.getValue()),
      FloatingRateType.IBOR);
    // look up the value on our chosen trade date
    final Double initialRate = getInitialRate(tradeDate, liborIdentifier);
    floatingLeg.setInitialFloatingRate(initialRate);

    final String fixedLegDescription = PortfolioLoaderHelper.RATE_FORMATTER.format(fixedRate);
    final String floatingLegDescription = swapConvention.getSwapFloatingLegInitialRate().getValue();
    SwapLeg payLeg;
    String payLegDescription;
View Full Code Here

    if (type != InterestRateInstrumentType.SWAP_FIXED_IBOR &&
        type != InterestRateInstrumentType.SWAP_FIXED_OIS &&
        type != InterestRateInstrumentType.SWAP_FIXED_IBOR_WITH_SPREAD) {
      throw new OpenGammaRuntimeException("Can only get series for fixed / float swaps; have " + type);
    }
    final FloatingInterestRateLeg floatingLeg = (FloatingInterestRateLeg) (security.getPayLeg() instanceof FixedInterestRateLeg ? security.getReceiveLeg() : security.getPayLeg());
    final ZonedDateTime swapStartDate = security.getEffectiveDate();
    return getIndexTimeSeries(floatingLeg, swapStartDate, _now, true, _resolver);
  }
View Full Code Here

    return getIndexTimeSeries(floatingLeg, swapStartDate, _now, true, _resolver);
  }

  private ValueRequirement getIndexTimeSeries(final FloatingInterestRateLeg leg, final ZonedDateTime swapEffectiveDate, final DateConstraint now,
      final boolean includeEndDate, final HistoricalTimeSeriesResolver resolver) {
    final FloatingInterestRateLeg floatingLeg = leg;
    final ExternalIdBundle id = getIndexIdForSwap(floatingLeg);
    final LocalDate startDate = swapEffectiveDate.toLocalDate().minusDays(30); // To catch first fixing. SwapSecurity does not have this date.
    final HistoricalTimeSeriesResolutionResult ts = resolver.resolve(id, null, null, null, MarketDataRequirementNames.MARKET_VALUE, null);
    if (ts == null) {
      throw new OpenGammaRuntimeException("Could not get time series of underlying index " + id.getExternalIds().toString() + " bundle used was " + id);
View Full Code Here

TOP

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

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.