Example usage for org.apache.commons.lang Validate notNull

List of usage examples for org.apache.commons.lang Validate notNull

Introduction

In this page you can find the example usage for org.apache.commons.lang Validate notNull.

Prototype

public static void notNull(Object object, String message) 

Source Link

Document

Validate an argument, throwing IllegalArgumentException if the argument is null.

 Validate.notNull(myObject, "The object must not be null"); 

Usage

From source file:com.opengamma.examples.convention.SyntheticGBConventions.java

public static synchronized void addFixedIncomeInstrumentConventions(
        final ConventionBundleMaster conventionMaster) {
    Validate.notNull(conventionMaster, "convention master");
    final BusinessDayConvention modified = BusinessDayConventionFactory.INSTANCE
            .getBusinessDayConvention("Modified Following");
    final BusinessDayConvention following = BusinessDayConventionFactory.INSTANCE
            .getBusinessDayConvention("Following");
    final DayCount act365 = DayCountFactory.INSTANCE.getDayCount("Actual/365");
    final Frequency annual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.ANNUAL_NAME);
    final Frequency semiAnnual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.SEMI_ANNUAL_NAME);
    final Frequency quarterly = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.QUARTERLY_NAME);

    final ExternalId gb = ExternalSchemes.financialRegionId("GB");

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);

    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPLIBORP7D")), "GBP LIBOR 7d", act365,
            modified, Period.ofDays(7), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPLIBORP14D")), "GBP LIBOR 14d", act365,
            modified, Period.ofDays(14), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPLIBORP1M")), "GBP LIBOR 1m", act365,
            modified, Period.ofMonths(1), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPLIBORP2M")), "GBP LIBOR 2m", act365,
            modified, Period.ofMonths(2), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPLIBORP3M")), "GBP LIBOR 3m", act365,
            modified, Period.ofMonths(3), 0, false, gb);
    utils.addConventionBundle(/*from w  w w . j a  va  2 s. c  o m*/
            ExternalIdBundle.of(syntheticSecurityId("GBPLIBORP6M"), simpleNameSecurityId("GBP LIBOR 6m")),
            "GBP LIBOR 6m", act365, modified, Period.ofMonths(6), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPLIBORP12M")), "GBP LIBOR 12m", act365,
            modified, Period.ofMonths(12), 0, false, gb);

    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPCASHP1D")), "GBPCASHP1D", act365,
            following, Period.ofDays(1), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPCASHP2D")), "GBPCASHP2D", act365,
            following, Period.ofDays(2), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPCASHP1M")), "GBPCASHP1M", act365,
            modified, Period.ofMonths(1), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPCASHP2M")), "GBPCASHP2M", act365,
            modified, Period.ofMonths(2), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPCASHP3M")), "GBPCASHP3M", act365,
            modified, Period.ofMonths(3), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPCASHP4M")), "GBPCASHP4M", act365,
            modified, Period.ofMonths(4), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPCASHP5M")), "GBPCASHP5M", act365,
            modified, Period.ofMonths(5), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPCASHP6M")), "GBPCASHP6M", act365,
            modified, Period.ofMonths(6), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPCASHP7M")), "GBPCASHP7M", act365,
            modified, Period.ofMonths(7), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPCASHP8M")), "GBPCASHP8M", act365,
            modified, Period.ofMonths(8), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPCASHP9M")), "GBPCASHP9M", act365,
            modified, Period.ofMonths(9), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPCASHP10M")), "GBPCASHP10M", act365,
            modified, Period.ofMonths(10), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPCASHP11M")), "GBPCASHP11M", act365,
            modified, Period.ofMonths(11), 0, false, gb);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("GBPCASHP12M")), "GBPCASHP12M", act365,
            modified, Period.ofMonths(12), 0, false, gb);

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("GBP_SWAP")), "GBP_SWAP", act365,
            modified, semiAnnual, 0, gb, act365, modified, semiAnnual, 0, simpleNameSecurityId("GBP LIBOR 6m"),
            gb, true);

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("GBP_3M_SWAP")), "GBP_3M_SWAP", act365,
            modified, annual, 0, gb, act365, modified, quarterly, 0, simpleNameSecurityId("GBP LIBOR 3m"), gb,
            true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("GBP_6M_SWAP")), "GBP_6M_SWAP", act365,
            modified, semiAnnual, 0, gb, act365, modified, semiAnnual, 0, simpleNameSecurityId("GBP LIBOR 6m"),
            gb, true);

    final Integer publicationLagON = 0;
    utils.addConventionBundle(
            ExternalIdBundle.of(syntheticSecurityId("SONIO"), simpleNameSecurityId("GBP SONIO/N")),
            "GBP SONIO/N", act365, following, Period.ofDays(1), 0, false, gb, publicationLagON);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("GBP_OIS_SWAP")), "GBP_OIS_SWAP", act365,
            modified, annual, 2, gb, act365, modified, annual, 2, simpleNameSecurityId("GBP SONIO/N"), gb, true,
            publicationLagON);

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("GBP_3M_FRA")), "GBP_3M_FRA", act365,
            modified, annual, 0, gb, act365, modified, quarterly, 0, simpleNameSecurityId("GBP LIBOR 3m"), gb,
            true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("GBP_6M_FRA")), "GBP_6M_FRA", act365,
            modified, semiAnnual, 0, gb, act365, modified, semiAnnual, 0, simpleNameSecurityId("GBP LIBOR 6m"),
            gb, true);

}

From source file:com.opengamma.analytics.math.FunctionUtils.java

public static int[] fromTensorIndex(final int index, final int[] dimensions) {
    Validate.notNull(dimensions, "dimensions");
    final int dim = dimensions.length;
    final int[] res = new int[dim];

    int product = 1;
    final int[] products = new int[dim - 1];
    for (int i = 0; i < dim - 1; i++) {
        product *= dimensions[i];//w  w  w . j  a v  a  2 s  . com
        products[i] = product;
    }

    int a = index;
    for (int i = dim - 1; i > 0; i--) {
        res[i] = a / products[i - 1];
        a -= res[i] * products[i - 1];
    }
    res[0] = a;

    return res;
}

From source file:com.opengamma.analytics.financial.timeseries.returns.SimplyCompoundedGeometricMeanReturnCalculator.java

@Override
public Double evaluate(final double[] x) {
    Validate.notNull(x, "x");
    ArgumentChecker.notEmpty(x, "x");
    final int n = x.length;
    double mult = 1 + x[0];
    for (int i = 1; i < n; i++) {
        mult *= 1 + x[i];//from   w  ww.ja va2 s .  co m
    }
    return Math.pow(mult, 1. / n) - 1;
}

From source file:com.opengamma.financial.convention.DKConventions.java

public static void addFixedIncomeInstrumentConventions(final ConventionBundleMaster conventionMaster) {
    Validate.notNull(conventionMaster, "convention master");
    final BusinessDayConvention modified = BusinessDayConventionFactory.INSTANCE
            .getBusinessDayConvention("Modified Following");
    final BusinessDayConvention following = BusinessDayConventionFactory.INSTANCE
            .getBusinessDayConvention("Following");
    final DayCount act360 = DayCountFactory.INSTANCE.getDayCount("Actual/360");
    final DayCount thirty360 = DayCountFactory.INSTANCE.getDayCount("30/360");
    final Frequency annual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.ANNUAL_NAME);
    final Frequency semiAnnual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.SEMI_ANNUAL_NAME);
    final Frequency quarterly = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.QUARTERLY_NAME);

    final ExternalId dk = ExternalSchemes.financialRegionId("DK");

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);

    utils.addConventionBundle(/*from w  w  w  .  j av a  2s .  c  om*/
            ExternalIdBundle.of(bloombergTickerSecurityId("CIBO01W Index"),
                    simpleNameSecurityId("DKK CIBOR 1w")),
            "DKK CIBOR 1w", act360, following, Period.ofDays(7), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("CIBO02W Index"),
                    simpleNameSecurityId("DKK CIBOR 2w")),
            "DKK CIBOR 2w", act360, following, Period.ofDays(14), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("CIBO01M Index"),
                    simpleNameSecurityId("DKK CIBOR 1m")),
            "DKK CIBOR 1m", act360, following, Period.ofMonths(1), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("CIBO02M Index"),
                    simpleNameSecurityId("DKK CIBOR 2m")),
            "DKK CIBOR 2m", act360, following, Period.ofMonths(2), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("CIBO03M Index"),
                    simpleNameSecurityId("DKK CIBOR 3m")),
            "DKK CIBOR 3m", act360, following, Period.ofMonths(3), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("CIBO04M Index"),
                    simpleNameSecurityId("DKK CIBOR 4m")),
            "DKK CIBOR 4m", act360, following, Period.ofMonths(4), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("CIBO05M Index"),
                    simpleNameSecurityId("DKK CIBOR 5m")),
            "DKK CIBOR 5m", act360, following, Period.ofMonths(5), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("CIBO06M Index"),
                    simpleNameSecurityId("DKK CIBOR 6m")),
            "DKK CIBOR 6m", act360, following, Period.ofMonths(6), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("CIBO07M Index"),
                    simpleNameSecurityId("DKK CIBOR 7m")),
            "DKK CIBOR 7m", act360, following, Period.ofMonths(7), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("CIBO08M Index"),
                    simpleNameSecurityId("DKK CIBOR 8m")),
            "DKK CIBOR 8m", act360, following, Period.ofMonths(8), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("CIBO09M Index"),
                    simpleNameSecurityId("DKK CIBOR 9m")),
            "DKK CIBOR 9m", act360, following, Period.ofMonths(9), 2, false, dk);

    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDR1T Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 1d")),
            "DKK DEPOSIT 1d", act360, following, Period.ofDays(1), 0, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDR2T Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 2d")),
            "DKK DEPOSIT 2d", act360, following, Period.ofDays(1), 1, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDR3T Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 3d")),
            "DKK DEPOSIT 3d", act360, following, Period.ofDays(1), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDR1Z Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 1w")),
            "DKK DEPOSIT 1w", act360, following, Period.ofDays(7), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDR2Z Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 2w")),
            "DKK DEPOSIT 2w", act360, following, Period.ofDays(14), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDR3Z Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 3w")),
            "DKK DEPOSIT 3w", act360, following, Period.ofDays(21), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDRA Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 1m")),
            "DKK DEPOSIT 1m", act360, following, Period.ofMonths(1), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDRB Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 2m")),
            "DKK DEPOSIT 2m", act360, following, Period.ofMonths(2), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDRC Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 3m")),
            "DKK DEPOSIT 3m", act360, following, Period.ofMonths(3), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDRD Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 4m")),
            "DKK DEPOSIT 4m", act360, following, Period.ofMonths(4), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDRE Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 5m")),
            "DKK DEPOSIT 5m", act360, following, Period.ofMonths(5), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDRF Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 6m")),
            "DKK DEPOSIT 6m", act360, following, Period.ofMonths(6), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDRG Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 7m")),
            "DKK DEPOSIT 7m", act360, following, Period.ofMonths(7), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDRH Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 8m")),
            "DKK DEPOSIT 8m", act360, following, Period.ofMonths(8), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDRI Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 9m")),
            "DKK DEPOSIT 9m", act360, following, Period.ofMonths(9), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDRJ Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 10m")),
            "DKK DEPOSIT 10m", act360, following, Period.ofMonths(10), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDRK Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 11m")),
            "DKK DEPOSIT 11m", act360, following, Period.ofMonths(11), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDR1 Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 1y")),
            "DKK DEPOSIT 1y", act360, following, Period.ofYears(1), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDR2 Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 2y")),
            "DKK DEPOSIT 2y", act360, following, Period.ofYears(2), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDR3 Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 3y")),
            "DKK DEPOSIT 3y", act360, following, Period.ofYears(3), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDR4 Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 4y")),
            "DKK DEPOSIT 4y", act360, following, Period.ofYears(4), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DKDR5 Curncy"),
                    simpleNameSecurityId("DKK DEPOSIT 5y")),
            "DKK DEPOSIT 5y", act360, following, Period.ofYears(5), 2, false, dk);

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("DKK_SWAP")), "DKK_SWAP", thirty360,
            modified, annual, 1, dk, act360, modified, semiAnnual, 1, simpleNameSecurityId("DKK CIBOR 6m"), dk,
            true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("DKK_3M_SWAP")), "DKK_3M_SWAP",
            thirty360, modified, annual, 2, dk, act360, modified, quarterly, 2,
            simpleNameSecurityId("DKK CIBOR 3m"), dk, true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("DKK_6M_SWAP")), "DKK_6M_SWAP",
            thirty360, modified, annual, 2, dk, act360, modified, semiAnnual, 2,
            simpleNameSecurityId("DKK CIBOR 6m"), dk, true);

    // Overnight Index Swap Convention have additional flag, publicationLag
    final Integer publicationLagON = 0;
    // Overnight-like rate
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("DETNT/N Index"), simpleNameSecurityId("DKK T/N")),
            "DKK T/N", act360, following, Period.ofDays(1), 1, false, dk, publicationLagON);
    // OIS-like swap
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("DKK_OIS_SWAP")), "DKK_OIS_SWAP", act360,
            modified, annual, 1, dk, act360, modified, annual, 1, simpleNameSecurityId("DKK T/N"), dk, true,
            publicationLagON);

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("DKK_IBOR_INDEX")), "DKK_IBOR_INDEX",
            act360, following, 1, false);

    // FRA conventions stored as IRS
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("DKK_3M_FRA")), "DKK_3M_FRA", thirty360,
            modified, annual, 2, dk, act360, modified, quarterly, 2, simpleNameSecurityId("DKK CIBOR 3m"), dk,
            true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("DKK_6M_FRA")), "DKK_6M_FRA", thirty360,
            modified, annual, 2, dk, act360, modified, semiAnnual, 2, simpleNameSecurityId("DKK CIBOR 6m"), dk,
            true);
}

From source file:com.opengamma.analytics.financial.timeseries.analysis.IIDHypothesis.java

@Override
public Boolean evaluate(final DoubleTimeSeries<?> x) {
    Validate.notNull(x, "x");
    if (x.isEmpty()) {
        throw new IllegalArgumentException("Time series was empty");
    }/* ww w .j a  v  a 2s.  co m*/
    return testIID(x);
}

From source file:com.opengamma.analytics.financial.timeseries.returns.ContinuouslyCompoundedGeometricMeanReturnCalculator.java

@Override
public Double evaluate(final double[] x) {
    Validate.notNull(x, "x");
    ArgumentChecker.notEmpty(x, "x");
    final int n = x.length;
    double mult = Math.exp(x[0]);
    for (int i = 1; i < n; i++) {
        mult *= Math.exp(x[i]);/*from  ww w . ja v a2  s  . c o m*/
    }
    return Math.log(mult) / n;
}

From source file:com.opengamma.analytics.financial.model.finitedifference.RichardsonExtrapolationFiniteDifference.java

public RichardsonExtrapolationFiniteDifference(final ConvectionDiffusionPDESolver baseSolver) {
    Validate.notNull(baseSolver, "null baseSolver");
    _baseSolver = baseSolver;
}

From source file:com.stealthyone.mcb.stbukkitlib.utils.LocationUtils.java

/**
 * Converts a location to a string.//from   w  w w. j  a va2 s.co m
 *
 * @param location Location to convert.
 * @param ignoreYawPitch Whether or not to include the 'yaw' and 'pitch' values of the location in the output string.
 * @return Location in string form.
 */
public static String locationToString(Location location, boolean ignoreYawPitch) {
    Validate.notNull(location, "Location cannot be null.");

    return location.getWorld().getName() + "," + location.getX() + "," + location.getY() + "," + location.getZ()
            + "," + (ignoreYawPitch ? "0,0" : location.getYaw() + "," + location.getPitch());
}

From source file:com.opengamma.examples.convention.SyntheticAUConventions.java

public static synchronized void addFixedIncomeInstrumentConventions(
        final InMemoryConventionBundleMaster conventionMaster) {
    Validate.notNull(conventionMaster, "convention master");
    final BusinessDayConvention modified = BusinessDayConventionFactory.INSTANCE
            .getBusinessDayConvention("Modified Following");
    final BusinessDayConvention following = BusinessDayConventionFactory.INSTANCE
            .getBusinessDayConvention("Following");
    final DayCount act365 = DayCountFactory.INSTANCE.getDayCount("Actual/365");
    final Frequency semiAnnual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.SEMI_ANNUAL_NAME);
    final Frequency quarterly = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.QUARTERLY_NAME);
    final Frequency annual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.ANNUAL_NAME);

    //TODO holiday associated with AUD swaps is Sydney
    final ExternalId au = ExternalSchemes.financialRegionId("AU");
    final Integer overnightPublicationLag = 0;

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);

    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDCASHP1D")), "AUDCASHP1D", act365,
            following, Period.ofDays(1), 0, false, au);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDCASHP1M")), "AUDCASHP1M", act365,
            modified, Period.ofMonths(1), 2, false, au);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDCASHP2M")), "AUDCASHP2M", act365,
            modified, Period.ofMonths(2), 2, false, au);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDCASHP3M")), "AUDCASHP3M", act365,
            modified, Period.ofMonths(3), 2, false, au);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDCASHP4M")), "AUDCASHP4M", act365,
            modified, Period.ofMonths(4), 2, false, au);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDCASHP5M")), "AUDCASHP5M", act365,
            modified, Period.ofMonths(5), 2, false, au);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDCASHP6M")), "AUDCASHP6M", act365,
            modified, Period.ofMonths(6), 2, false, au);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDCASHP7M")), "AUDCASHP7M", act365,
            modified, Period.ofMonths(7), 2, false, au);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDCASHP8M")), "AUDCASHP8M", act365,
            modified, Period.ofMonths(8), 2, false, au);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDCASHP9M")), "AUDCASHP9M", act365,
            modified, Period.ofMonths(9), 2, false, au);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDCASHP10M")), "AUDCASHP10M", act365,
            modified, Period.ofMonths(10), 2, false, au);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDCASHP11M")), "AUDCASHP11M", act365,
            modified, Period.ofMonths(1), 2, false, au);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDCASHP12M")), "AUDCASHP12M", act365,
            modified, Period.ofMonths(12), 2, false, au);

    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDLIBORP3M")), "AUD LIBOR 3m", act365,
            following, Period.ofMonths(3), 2, false, au);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDLIBORP6M")), "AUD LIBOR 6m", act365,
            following, Period.ofMonths(6), 2, false, au);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("AUDLIBORP12M")), "AUD LIBOR 12m", act365,
            following, Period.ofMonths(12), 2, false, au);
    utils.addConventionBundle(/*from w ww  .  j a  v  a 2 s .  co  m*/
            ExternalIdBundle.of(syntheticSecurityId("AUDON"), simpleNameSecurityId("RBA OVERNIGHT CASH RATE")),
            "RBA OVERNIGHT CASH RATE", act365, following, Period.ofDays(1), 0, false, au,
            overnightPublicationLag);

    final DayCount swapFixedDayCount = act365;
    final BusinessDayConvention swapFixedBusinessDay = modified;

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("AUD_SWAP")), "AUD_SWAP", act365,
            modified, semiAnnual, 0, au, act365, modified, semiAnnual, 0,
            simpleNameSecurityId(IndexType.BBSW + "_AUD_P6M"), au, true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("AUD_3M_SWAP")), "AUD_3M_SWAP",
            swapFixedDayCount, swapFixedBusinessDay, quarterly, 0, au, act365, modified, quarterly, 0,
            simpleNameSecurityId(IndexType.BBSW + "_AUD_P3M"), au, true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("AUD_6M_SWAP")), "AUD_6M_SWAP",
            swapFixedDayCount, swapFixedBusinessDay, semiAnnual, 0, au, act365, modified, semiAnnual, 0,
            simpleNameSecurityId(IndexType.BBSW + "_AUD_P6M"), au, true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("AUD_OIS_SWAP")), "AUD_OIS_SWAP", act365,
            modified, annual, 0, au, act365, modified, annual, 0,
            simpleNameSecurityId("RBA OVERNIGHT CASH RATE"), au, true, overnightPublicationLag);
    utils.addConventionBundle(
            ExternalIdBundle.of(syntheticSecurityId("AUDBBP3M"),
                    simpleNameSecurityId(IndexType.BBSW + "_AUD_P3M")),
            "AUD Bank Bill 3m", act365, modified, Period.ofMonths(3), 0, true, au); // "AUD Bank Bill 3m"
    utils.addConventionBundle(
            ExternalIdBundle.of(syntheticSecurityId("AUDBBP6M"),
                    simpleNameSecurityId(IndexType.BBSW + "_AUD_P6M")),
            "AUD Bank Bill 6m", act365, modified, Period.ofMonths(6), 0, true, au); // "AUD Bank Bill 6m"
}

From source file:com.opengamma.financial.convention.NZConventions.java

public static synchronized void addFixedIncomeInstrumentConventions(
        final ConventionBundleMaster conventionMaster) {
    Validate.notNull(conventionMaster, "convention master");
    final BusinessDayConvention modified = BusinessDayConventionFactory.INSTANCE
            .getBusinessDayConvention("Modified Following");
    final BusinessDayConvention following = BusinessDayConventionFactory.INSTANCE
            .getBusinessDayConvention("Following");
    final DayCount act365 = DayCountFactory.INSTANCE.getDayCount("Actual/365");
    final Frequency quarterly = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.QUARTERLY_NAME);
    final Frequency semiAnnual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.SEMI_ANNUAL_NAME);
    final Frequency annual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.ANNUAL_NAME);
    final ExternalId nz = ExternalSchemes.financialRegionId("NZ");

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);

    utils.addConventionBundle(//from  w w w. j  a  v a  2 s . c  o m
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ00O/N Index"),
                    simpleNameSecurityId("NZD LIBOR O/N")),
            "NZD LIBOR O/N", act365, following, Period.ofDays(1), 0, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ00S/N Index"),
                    simpleNameSecurityId("NZD LIBOR S/N")),
            "NZD LIBOR S/N", act365, following, Period.ofDays(1), 0, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ00T/N Index"),
                    simpleNameSecurityId("NZD LIBOR T/N")),
            "NZD LIBOR T/N", act365, following, Period.ofDays(1), 0, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ0001W Index"),
                    simpleNameSecurityId("NZD LIBOR 1w")),
            "NZD LIBOR 1w", act365, following, Period.ofDays(1), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ0002W Index"),
                    simpleNameSecurityId("NZD LIBOR 2w")),
            "NZD LIBOR 2w", act365, following, Period.ofDays(1), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ0001M Index"),
                    simpleNameSecurityId("NZD LIBOR 1m")),
            "NZD LIBOR 1m", act365, following, Period.ofMonths(1), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ0002M Index"),
                    simpleNameSecurityId("NZD LIBOR 2m")),
            "NZD LIBOR 2m", act365, following, Period.ofMonths(2), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ0003M Index"),
                    simpleNameSecurityId("NZD LIBOR 3m")),
            "NZD LIBOR 3m", act365, following, Period.ofMonths(3), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ0004M Index"),
                    simpleNameSecurityId("NZD LIBOR 4m")),
            "NZD LIBOR 4m", act365, following, Period.ofMonths(4), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ0005M Index"),
                    simpleNameSecurityId("NZD LIBOR 5m")),
            "NZD LIBOR 5m", act365, following, Period.ofMonths(5), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ0006M Index"),
                    simpleNameSecurityId("NZD LIBOR 6m")),
            "NZD LIBOR 6m", act365, following, Period.ofMonths(6), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ0007M Index"),
                    simpleNameSecurityId("NZD LIBOR 7m")),
            "NZD LIBOR 7m", act365, following, Period.ofMonths(7), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ0008M Index"),
                    simpleNameSecurityId("NZD LIBOR 8m")),
            "NZD LIBOR 8m", act365, following, Period.ofMonths(8), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ0009M Index"),
                    simpleNameSecurityId("NZD LIBOR 9m")),
            "NZD LIBOR 9m", act365, following, Period.ofMonths(9), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ0010M Index"),
                    simpleNameSecurityId("NZD LIBOR 10m")),
            "NZD LIBOR 10m", act365, following, Period.ofMonths(10), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ0011M Index"),
                    simpleNameSecurityId("NZD LIBOR 11m")),
            "NZD LIBOR 11m", act365, following, Period.ofMonths(11), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZ0012M Index"),
                    simpleNameSecurityId("NZD LIBOR 12m")),
            "NZD LIBOR 12m", act365, following, Period.ofMonths(12), 2, false, nz);

    //TODO need to check that these are right for deposit rates
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDR1T Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 1d")),
            "NZD DEPOSIT 1d", act365, following, Period.ofDays(1), 0, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDR2T Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 2d")),
            "NZD DEPOSIT 2d", act365, following, Period.ofDays(1), 0, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDR3T Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 3d")),
            "NZD DEPOSIT 3d", act365, following, Period.ofDays(1), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDR1Z Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 1w")),
            "NZD DEPOSIT 1w", act365, following, Period.ofDays(7), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDR2Z Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 2w")),
            "NZD DEPOSIT 2w", act365, following, Period.ofDays(14), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDR3Z Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 3w")),
            "NZD DEPOSIT 3w", act365, following, Period.ofDays(21), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDRA Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 1m")),
            "NZD DEPOSIT 1m", act365, following, Period.ofMonths(1), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDRB Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 2m")),
            "NZD DEPOSIT 2m", act365, following, Period.ofMonths(2), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDRC Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 3m")),
            "NZD DEPOSIT 3m", act365, following, Period.ofMonths(3), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDRD Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 4m")),
            "NZD DEPOSIT 4m", act365, following, Period.ofMonths(4), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDRE Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 5m")),
            "NZD DEPOSIT 5m", act365, following, Period.ofMonths(5), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDRF Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 6m")),
            "NZD DEPOSIT 6m", act365, following, Period.ofMonths(6), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDRG Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 7m")),
            "NZD DEPOSIT 7m", act365, following, Period.ofMonths(7), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDRH Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 8m")),
            "NZD DEPOSIT 8m", act365, following, Period.ofMonths(8), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDRI Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 9m")),
            "NZD DEPOSIT 9m", act365, following, Period.ofMonths(9), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDRJ Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 10m")),
            "NZD DEPOSIT 10m", act365, following, Period.ofMonths(10), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDRK Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 11m")),
            "NZD DEPOSIT 11m", act365, following, Period.ofMonths(11), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDR1 Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 1y")),
            "NZD DEPOSIT 1y", act365, following, Period.ofYears(1), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDR2 Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 2y")),
            "NZD DEPOSIT 2y", act365, following, Period.ofYears(2), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDR3 Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 3y")),
            "NZD DEPOSIT 3y", act365, following, Period.ofYears(3), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDR4 Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 4y")),
            "NZD DEPOSIT 4y", act365, following, Period.ofYears(4), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NDDR5 Curncy"),
                    simpleNameSecurityId("NZD DEPOSIT 5y")),
            "NZD DEPOSIT 5y", act365, following, Period.ofYears(5), 2, false, nz);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NZOCRS Index"),
                    simpleNameSecurityId("RBNZ CASH DAILY RATE")),
            "RBNZ CASH DAILY RATE", act365, following, Period.ofDays(1), 0, false, nz, 0); // review publication lag when doing OIS.

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("NZD_SWAP")), "NZD_SWAP", act365,
            modified, semiAnnual, 2, nz, act365, modified, quarterly, 2, simpleNameSecurityId("NZD LIBOR 3m"),
            nz, true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("NZD_3M_SWAP")), "NZD_3M_SWAP", act365,
            modified, semiAnnual, 2, nz, act365, modified, quarterly, 2, simpleNameSecurityId("NZD LIBOR 3m"),
            nz, true);
    // Overnight Index Swap Convention have additional flag, publicationLag
    final Integer publicationLag = 0;
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("NZD_OIS_SWAP")), "NZD_OIS_SWAP", act365,
            modified, annual, 0, nz, act365, modified, annual, 0, simpleNameSecurityId("RBNZ CASH DAILY RATE"),
            nz, true, publicationLag);
}