/** * @param abscissas An array containing the abscissas, not null * @param weights An array containing the weights, not null, must be the same length as the abscissa array */ public GaussianQuadratureData(double[] abscissas, double[] weights) { ArgChecker.notNull(abscissas, "abscissas"); ArgChecker.notNull(weights, "weights"); ArgChecker.isTrue(abscissas.length == weights.length, "Abscissa and weight arrays must be the same length"); _weights = weights; _abscissas = abscissas; }
@Override public Double apply(Double x) { ArgChecker.notNull(x, "x"); ArgChecker.notNegative(x, "x"); return _calc.apply(0.5 + 0.5 * x); }
@ImmutableValidator private void validate() { ArgChecker.isTrue(extrapolatorLeft.equals(FLAT), "extrapolator left must be flat extrapolator"); ArgChecker.isTrue( interpolator.equals(CurveInterpolators.LINEAR) || interpolator.equals(CurveInterpolators.STEP_UPPER), "interpolator must be local interpolator"); ArgChecker.isFalse(betaCurve != null && rhoCurve != null, "Only betaCurve or rhoCurve must be set, not both"); ArgChecker.isFalse(betaCurve == null && rhoCurve == null, "Either betaCurve or rhoCurve must be set"); }
/** * Creates an instance with a sampled (parameterised) curve. * * @param samplePoints the points where we sample the curve * @param curve a parameterised curve */ public ParameterizedCurveVectorFunction(double[] samplePoints, ParameterizedCurve curve) { ArgChecker.notEmpty(samplePoints, "samplePoints"); ArgChecker.notNull(curve, "curve"); _samplePoints = Arrays.copyOf(samplePoints, samplePoints.length); _curve = curve; }
@ImmutableValidator private void validate() { int size = deliveryBasketIds.size(); ArgChecker.isTrue(size == conversionFactors.size(), "The delivery basket size should be the same as the conversion factor size"); ArgChecker.inOrderOrEqual(firstNoticeDate, lastNoticeDate, "firstNoticeDate", "lastNoticeDate"); if (firstDeliveryDate != null && lastDeliveryDate != null) { ArgChecker.inOrderOrEqual(firstDeliveryDate, lastDeliveryDate, "firstDeliveryDate", "lastDeliveryDate"); ArgChecker.inOrderOrEqual(firstNoticeDate, firstDeliveryDate, "firstNoticeDate", "firstDeliveryDate"); ArgChecker.inOrderOrEqual(lastNoticeDate, lastDeliveryDate, "lastNoticeDate", "lastDeliveryDate"); } }
/** * Sets penalty intensity parameter for expiry dimension. * @param lambdaExpiry the new value * @return this, for chaining, not null */ public Builder lambdaExpiry(double lambdaExpiry) { ArgChecker.notNegative(lambdaExpiry, "lambdaExpiry"); this.lambdaExpiry = lambdaExpiry; return this; }
/** * Sets the notional of the futures. * <p> * This is also called face value or contract value. * @param notional the new value * @return this, for chaining, not null */ public Builder notional(double notional) { ArgChecker.notNegativeOrZero(notional, "notional"); this.notional = notional; return this; }
/** * Obtains an instance of {@code Moneyness} from the strike and forward. * <p> * The moneyness is defined as {@code strike/forward}. * * @param strike the strike, not negative * @param forward the forward, not negative * @return the instance */ public static MoneynessStrike ofStrikeAndForward(double strike, double forward) { return of(ArgChecker.notNegativeOrZero(strike, "strike") / ArgChecker.notNegative(forward, "forward")); }
public void test_int_inRange() { int low = 0; int mid = 1; int high = 2; assertEquals(ArgChecker.inRange(mid, low, high, "name"), mid); assertEquals(ArgChecker.inRange(low, low, high, "name"), low); assertEquals(ArgChecker.inRangeInclusive(mid, low, high, "name"), mid); assertEquals(ArgChecker.inRangeInclusive(low, low, high, "name"), low); assertEquals(ArgChecker.inRangeInclusive(high, low, high, "name"), high); assertEquals(ArgChecker.inRangeExclusive(mid, low, high, "name"), mid); }
/** * Creates an instance. * * @param name the name */ private FxOptionVolatilitiesName(String name) { this.name = ArgChecker.notEmpty(name, "name"); }
@ImmutableValidator private void validate() { ArgChecker.isTrue( endObservation.getIndex().equals(endSecondObservation.getIndex()), "Both observations must be for the same index"); ArgChecker.inOrderNotEqual( endObservation.getFixingMonth(), endSecondObservation.getFixingMonth(), "endObservation", "endSecondObservation"); }
/** * Obtains a standard formatter configured by grouping and decimal places. * <p> * The formatter will have the specified number of decimal places. * The integer part will be grouped if the flag is set. * The decimal part will never be grouped or truncated. * The implementation uses English locale data, which uses commas as a separator and a decimal point (dot). * Numbers will be rounded using {@link RoundingMode#HALF_EVEN} * * @param grouped true to group, false to not group * @param minDecimalPlaces the minimum number of decimal places, from 0 to 9 * @param maxDecimalPlaces the minimum number of decimal places, from 0 to 9 * @return the formatter * @throws IllegalArgumentException if the decimal places is invalid */ public static NumberFormatter of(boolean grouped, int minDecimalPlaces, int maxDecimalPlaces) { ArgChecker.inRangeInclusive(minDecimalPlaces, 0, 9, "minDecimalPlaces"); ArgChecker.inRangeInclusive(maxDecimalPlaces, 0, 9, "maxDecimalPlaces"); ArgChecker.isTrue(minDecimalPlaces <= maxDecimalPlaces, "Expected minDecimalPlaces <= maxDecimalPlaces"); return create(grouped, minDecimalPlaces, maxDecimalPlaces); }
public void test_noNulls_Array_ok_empty() { Object[] array = new Object[] {}; ArgChecker.noNulls(array, "name"); }
@ImmutableValidator private void validate() { // check for unadjusted must be after firstNonNull ArgChecker.inOrderNotEqual(startDate, endDate, "startDate", "endDate"); ArgChecker.inOrderNotEqual(unadjustedStartDate, unadjustedEndDate, "unadjustedStartDate", "unadjustedEndDate"); }
public void test_inOrderOrEqual_true() { LocalDate a = LocalDate.of(2011, 7, 2); LocalDate b = LocalDate.of(2011, 7, 3); ArgChecker.inOrderOrEqual(a, b, "a", "b"); ArgChecker.inOrderOrEqual(a, a, "a", "b"); ArgChecker.inOrderOrEqual(b, b, "a", "b"); }
@Override public double getWeight(double y) { ArgChecker.inRangeInclusive(y, 0d, 1d, "y"); return y; }
@ImmutableValidator private void validate() { ArgChecker.inOrderOrEqual(expiryDate, underlyingFuture.getLastTradeDate(), "expiryDate", "lastTradeDate"); ArgChecker.isTrue( strikePrice < 2, "Strike price must be in decimal form, such as 0.993 for a 0.7% rate, but was: {}", strikePrice); }
/** * Sets penalty intensity parameter for strike dimension. * @param lambdaStrike the new value * @return this, for chaining, not null */ public Builder lambdaStrike(double lambdaStrike) { ArgChecker.notNegative(lambdaStrike, "lambdaStrike"); this.lambdaStrike = lambdaStrike; return this; }
@Override public double volatility(double expiry, LocalDate fixingDate, double strikePrice, double futurePrice) { ArgChecker.notNegativeOrZero(strikePrice, "strikePrice"); ArgChecker.notNegativeOrZero(futurePrice, "futurePrice"); double logMoneyness = Math.log(strikePrice / futurePrice); return surface.zValue(expiry, logMoneyness); }