Package com.opengamma.analytics.financial.instrument.index

Source Code of com.opengamma.analytics.financial.instrument.index.GeneratorSwapFixedInflationMaster

/**
* Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.analytics.financial.instrument.index;

import java.util.HashMap;
import java.util.Map;

import org.threeten.bp.ZonedDateTime;

import com.opengamma.OpenGammaRuntimeException;
import com.opengamma.analytics.financial.provider.description.MulticurveProviderDiscountDataSets;
import com.opengamma.financial.convention.businessday.BusinessDayConvention;
import com.opengamma.financial.convention.businessday.BusinessDayConventionFactory;
import com.opengamma.financial.convention.calendar.Calendar;
import com.opengamma.financial.convention.calendar.CalendarNoHoliday;
import com.opengamma.timeseries.DoubleTimeSeries;

/**
*
*/
public final class GeneratorSwapFixedInflationMaster {

  /**
   * The method unique instance.
   */
  private static final GeneratorSwapFixedInflationMaster INSTANCE = new GeneratorSwapFixedInflationMaster();

  /**
   * Return the unique instance of the class.
   * @return The instance.
   */
  public static GeneratorSwapFixedInflationMaster getInstance() {
    return INSTANCE;
  }

  /**
   * The map with the list of names and the swap generators.
   */
  private final Map<String, GeneratorSwapFixedInflationZeroCoupon> _generatorSwap;

  /**
   * Private constructor.
   */
  private GeneratorSwapFixedInflationMaster() {
    final PriceIndexMaster priceIndexMaster = PriceIndexMaster.getInstance();

    final DoubleTimeSeries<ZonedDateTime> eurPriceIndexTimeSerie = MulticurveProviderDiscountDataSets.euroHICPXFrom2009();
    final DoubleTimeSeries<ZonedDateTime> usPriceIndexTimeSerie = MulticurveProviderDiscountDataSets.usCpiFrom2009();
    final DoubleTimeSeries<ZonedDateTime> ukPriceIndexTimeSerie = MulticurveProviderDiscountDataSets.ukRpiFrom2010();

    final BusinessDayConvention modFol = BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Modified Following");
    final Calendar baseCalendar = new CalendarNoHoliday("No Holidays");
    final boolean endOfMonth = true;
    final int monthLag = 3;
    final int spotLag = 2;
    final boolean linear = true;
    final boolean piecewiseconstant = false;
    _generatorSwap = new HashMap<>();
    _generatorSwap.put("EURHICP",
        new GeneratorSwapFixedInflationZeroCoupon("EUR HICP", priceIndexMaster.getIndex("EURHICP"), modFol, baseCalendar, endOfMonth, monthLag, spotLag, piecewiseconstant));
    _generatorSwap.put("UKRPI",
        new GeneratorSwapFixedInflationZeroCoupon("UK RPI", priceIndexMaster.getIndex("UKRPI"), modFol, baseCalendar, endOfMonth, monthLag, spotLag, piecewiseconstant));
    _generatorSwap.put("USCPI",
        new GeneratorSwapFixedInflationZeroCoupon("US CPI", priceIndexMaster.getIndex("USCPI"), modFol, baseCalendar, endOfMonth, monthLag, spotLag, linear));
  }

  public GeneratorSwapFixedInflationZeroCoupon getGenerator(final String name) {
    final GeneratorSwapFixedInflationZeroCoupon generatorNoCalendar = _generatorSwap.get(name);
    if (generatorNoCalendar == null) {
      throw new OpenGammaRuntimeException("Could not get price index index for " + name);
    }
    return new GeneratorSwapFixedInflationZeroCoupon(generatorNoCalendar.getName(), generatorNoCalendar.getIndexPrice(), generatorNoCalendar.getBusinessDayConvention(),
        generatorNoCalendar.getCalendar(), generatorNoCalendar.isEndOfMonth(), generatorNoCalendar.getMonthLag(), generatorNoCalendar.getSpotLag(),
        generatorNoCalendar.isLinear());
  }
}
TOP

Related Classes of com.opengamma.analytics.financial.instrument.index.GeneratorSwapFixedInflationMaster

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.