Package com.opengamma.financial.convention

Examples of com.opengamma.financial.convention.PriceIndexConvention


      final String name = message.getString(NAME_FIELD);
      final ExternalIdBundle externalIdBundle = deserializer.fieldValueToObject(ExternalIdBundle.class, message.getByName(EXTERNAL_ID_BUNDLE_FIELD));
      final Currency currency = Currency.of(message.getString(CURRENCY_FIELD));
      final ExternalId region = deserializer.fieldValueToObject(ExternalId.class, message.getByName(REGION_FIELD));
      final ExternalId priceIndexId = deserializer.fieldValueToObject(ExternalId.class, message.getByName(PRICE_INDEX_ID_FIELD));
      final PriceIndexConvention convention = new PriceIndexConvention(name, externalIdBundle, currency, region, priceIndexId);
      final FudgeField uniqueIdMsg = message.getByName(UNIQUE_ID_FIELD);
      if (uniqueIdMsg != null) {
        convention.setUniqueId(deserializer.fieldValueToObject(UniqueId.class, uniqueIdMsg));
      }
      return convention;
    }
View Full Code Here


    }
    final InflationLegConvention inflationLegConvention = _conventionSource.getConvention(InflationLegConvention.class, inflationNode.getInflationLegConvention());
    if (inflationLegConvention == null) {
      throw new OpenGammaRuntimeException("Convention with id " + inflationNode.getInflationLegConvention() + " was null");
    }
    final PriceIndexConvention priceIndexConvention = _conventionSource.getConvention(PriceIndexConvention.class, inflationLegConvention.getPriceIndexConvention());
    if (priceIndexConvention == null) {
      throw new OpenGammaRuntimeException("Convention with id " + inflationLegConvention.getPriceIndexConvention() + " was null");
    }
    final int settlementDays = fixedLegConvention.getSettlementDays();
    final Period tenor = inflationNode.getTenor().getPeriod();
    final double notional = 1;
    //TODO business day convention and currency are in both conventions - should we enforce that they're the same or use
    // different ones for each leg?
    final BusinessDayConvention businessDayConvention = fixedLegConvention.getBusinessDayConvention();
    final boolean endOfMonth = fixedLegConvention.isIsEOM();
    final Currency currency = priceIndexConvention.getCurrency();
    final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, priceIndexConvention.getRegion());
    final ZoneId zone = _valuationTime.getZone(); //TODO time zone set to midnight UTC
    final ZonedDateTime settlementDate = ScheduleCalculator.getAdjustedDate(_valuationTime, settlementDays, calendar).toLocalDate().atStartOfDay(zone);
    final ZonedDateTime paymentDate = ScheduleCalculator.getAdjustedDate(settlementDate, tenor, businessDayConvention, calendar, endOfMonth).toLocalDate().atStartOfDay(zone);
    final CouponFixedCompoundingDefinition fixedCoupon = CouponFixedCompoundingDefinition.from(currency, settlementDate, paymentDate, notional, tenor.getYears(),
        rate);
    final HistoricalTimeSeries ts = _timeSeries.get(MarketDataRequirementNames.MARKET_VALUE, priceIndexConvention.getPriceIndexId());
    if (ts == null) {
      throw new OpenGammaRuntimeException("Could not get price index time series with id " + priceIndexConvention.getPriceIndexId());
    }
    final LocalDateDoubleTimeSeries localDateTS = ts.getTimeSeries();
    final DoubleTimeSeries<ZonedDateTime> priceIndexTimeSeries = convertTimeSeries(zone, localDateTS);
    final int conventionalMonthLag = inflationLegConvention.getMonthLag();
    final int monthLag = inflationLegConvention.getMonthLag();
    final IndexPrice index = new IndexPrice(priceIndexConvention.getName(), currency);
    switch (inflationNode.getInflationNodeType()) {
      case INTERPOLATED:
      {
        final CouponInflationZeroCouponInterpolationDefinition inflationCoupon = CouponInflationZeroCouponInterpolationDefinition.from(settlementDate, paymentDate,
            -notional, index, conventionalMonthLag, monthLag, false);
View Full Code Here

  }

  @Override
  public InstrumentDefinition<?> visitYearOnYearInflationSwapSecurity(final YearOnYearInflationSwapSecurity security) {
    final Currency currency = FinancialSecurityUtils.getCurrency(security);
    final PriceIndexConvention indexConvention = _conventionSource.getConvention(PriceIndexConvention.class, getIds(currency, PRICE_INDEX));
    if (indexConvention == null) {
      throw new OpenGammaRuntimeException("Price index convention with id " + getIds(currency, PRICE_INDEX) + " was null");
    }
    final SwapFixedLegConvention fixedLegConvention = _conventionSource.getConvention(SwapFixedLegConvention.class, getIds(currency, IRS_FIXED_LEG));
    if (fixedLegConvention == null) {
      throw new OpenGammaRuntimeException("Swap fixed leg convention with id " + getIds(currency, IRS_FIXED_LEG) + " was null");
    }
    final InflationLegConvention inflationLegConvention = _conventionSource.getConvention(InflationLegConvention.class, getIds(currency, INFLATION_LEG));
    if (inflationLegConvention == null) {
      throw new OpenGammaRuntimeException("Inflation leg convention with id " + getIds(currency, INFLATION_LEG) + " was null");
    }
    final IndexPrice priceIndex = new IndexPrice(indexConvention.getName(), currency);
    final SwapLeg payLeg = security.getPayLeg();
    final SwapLeg receiveLeg = security.getReceiveLeg();
    final FixedInflationSwapLeg fixedLeg;
    final InflationIndexSwapLeg indexLeg;
    final boolean isPayer;
    if (payLeg instanceof FixedInflationSwapLeg && receiveLeg instanceof InflationIndexSwapLeg) {
      fixedLeg = (FixedInflationSwapLeg) payLeg;
      indexLeg = (InflationIndexSwapLeg) receiveLeg;
      isPayer = true;
    } else if (payLeg instanceof InflationIndexSwapLeg && receiveLeg instanceof FixedInflationSwapLeg) {
      fixedLeg = (FixedInflationSwapLeg) receiveLeg;
      indexLeg = (InflationIndexSwapLeg) payLeg;
      isPayer = false;
    } else {
      throw new OpenGammaRuntimeException("Can only convert fixed / float inflation swaps");
    }
    final int settlementDays = fixedLegConvention.getSettlementDays();
    final boolean isEOM = fixedLegConvention.isIsEOM();
    final DayCount fixedLegDayCount = fixedLeg.getDayCount();
    final BusinessDayConvention businessDayConvention = fixedLeg.getBusinessDayConvention();
    final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, indexConvention.getRegion());
    final ZoneOffset zone = ZoneOffset.UTC; //TODO
    final Period paymentPeriod = getTenor(indexLeg.getFrequency());
    final Period maturityTenor = security.getMaturityTenor().getPeriod();
    boolean isMonthly;
    switch (indexLeg.getInterpolationMethod()) {
View Full Code Here

  }

  @Override
  public InstrumentDefinition<?> visitZeroCouponInflationSwapSecurity(final ZeroCouponInflationSwapSecurity security) {
    final Currency currency = FinancialSecurityUtils.getCurrency(security);
    final PriceIndexConvention indexConvention = _conventionSource.getConvention(PriceIndexConvention.class, getIds(currency, PRICE_INDEX));
    if (indexConvention == null) {
      throw new OpenGammaRuntimeException("Price index convention with id " + getIds(currency, PRICE_INDEX) + " was null");
    }
    final SwapFixedLegConvention fixedLegConvention = _conventionSource.getConvention(SwapFixedLegConvention.class, getIds(currency, IRS_FIXED_LEG));
    if (fixedLegConvention == null) {
      throw new OpenGammaRuntimeException("Swap fixed leg convention with id " + getIds(currency, IRS_FIXED_LEG) + " was null");
    }
    final InflationLegConvention inflationLegConvention = _conventionSource.getConvention(InflationLegConvention.class, getIds(currency, INFLATION_LEG));
    if (inflationLegConvention == null) {
      throw new OpenGammaRuntimeException("Inflation leg convention with id " + getIds(currency, INFLATION_LEG) + " was null");
    }
    final IndexPrice priceIndex = new IndexPrice(indexConvention.getName(), currency);
    final SwapLeg payLeg = security.getPayLeg();
    final SwapLeg receiveLeg = security.getReceiveLeg();
    final FixedInflationSwapLeg fixedLeg;
    final InflationIndexSwapLeg indexLeg;
    final boolean isPayer;
    if (payLeg instanceof FixedInflationSwapLeg && receiveLeg instanceof InflationIndexSwapLeg) {
      fixedLeg = (FixedInflationSwapLeg) payLeg;
      indexLeg = (InflationIndexSwapLeg) receiveLeg;
      isPayer = true;
    } else if (payLeg instanceof InflationIndexSwapLeg && receiveLeg instanceof FixedInflationSwapLeg) {
      fixedLeg = (FixedInflationSwapLeg) receiveLeg;
      indexLeg = (InflationIndexSwapLeg) payLeg;
      isPayer = false;
    } else {
      throw new OpenGammaRuntimeException("Can only convert fixed / float inflation swaps");
    }
    final int settlementDays = fixedLegConvention.getSettlementDays();
    final boolean isEOM = fixedLegConvention.isIsEOM();
    final BusinessDayConvention businessDayConvention = fixedLeg.getBusinessDayConvention();
    final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, indexConvention.getRegion());
    final ZoneOffset zone = ZoneOffset.UTC; //TODO
   
    final int swapMaturityTenor = (int) Math.round(indexLeg.getDayCount().getDayCountFraction(security.getEffectiveDate(), security.getMaturityDate()));
    boolean isMonthly;
    switch (indexLeg.getInterpolationMethod()) {
View Full Code Here

          } // Node points - end
          for (final CurveTypeConfiguration type : entry.getValue()) { // Type - start
            if (type instanceof InflationCurveTypeConfiguration) {
              final InflationCurveTypeConfiguration inflationConfiguration = (InflationCurveTypeConfiguration) type;
              final String reference = inflationConfiguration.getReference();
              final PriceIndexConvention priceIndexConvention = conventionSource.getConvention(PriceIndexConvention.class, inflationConfiguration.getPriceIndex());
              if (priceIndexConvention == null) {
                throw new OpenGammaRuntimeException("Could not get convention called " + inflationConfiguration.getPriceIndex());
              }
              try {
                final Currency currency = Currency.of(reference);
                //should this map check that the curve name has not already been entered?
                inflation.add(new IndexPrice(priceIndexConvention.getName(), currency));
              } catch (final IllegalArgumentException e) {
                throw new OpenGammaRuntimeException("Cannot handle reference type " + reference + " for inflation curves");
              }
            } else {
              throw new OpenGammaRuntimeException("Cannot handle " + type.getClass());
View Full Code Here

        ExternalId.of(ExchangeTradedInstrumentExpiryCalculator.SCHEME, FedFundFutureAndFutureOptionMonthlyExpiryCalculator.NAME), US, overnightConventionId, 5000000);
    final Convention cmsDeliverableSwapFutureConvention = new DeliverablePriceQuotedSwapFutureConvention(cmeDeliverableSwapFutureConventionName,
        ExternalIdBundle.of(SCHEME_NAME, CME_DELIVERABLE_SWAP_FUTURE), ExternalId.of(ExchangeTradedInstrumentExpiryCalculator.SCHEME,
            IMMFutureAndFutureOptionQuarterlyExpiryCalculator.NAME), US, liborConventionId, 100000);
    // Inflation
    final PriceIndexConvention priceIndexConvention = new PriceIndexConvention(priceIndexName, getIds(Currency.USD, PRICE_INDEX), Currency.USD, US,
        ExternalSchemes.bloombergTickerSecurityId("CPURNSA Index"));
    final Convention inflationConvention = new InflationLegConvention(inflationConventionName, getIds(Currency.USD, INFLATION_LEG), MODIFIED_FOLLOWING, ACT_360, false, 3, 2,
        priceIndexId);
    // US Treasury: Synthetic swaps to represent bonds, using yield
    final String fixedLegGovtConventionName = getConventionName(Currency.USD, TENOR_STR_6M, GOVT + FIXED_LEG);
View Full Code Here

    assertEquals(convention, cycleObject(OvernightIndexConvention.class, convention));
  }

  @Test
  public void testPriceIndexConvention() {
    final PriceIndexConvention convention = new PriceIndexConvention("CPI", ExternalIdBundle.of(InMemoryConventionBundleMaster.simpleNameSecurityId("CPI")), Currency.USD, ExternalId.of("Region", "US"),
        ExternalId.of("Test", "CPI"));
    convention.setUniqueId(UniqueId.of("Test", "9385"));
    assertEquals(convention, cycleObject(PriceIndexConvention.class, convention));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.financial.convention.PriceIndexConvention

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.