public virtual void test_equalWithTolerance_true() { PointSensitivity cs1b = DummyPointSensitivity.of(GBP, date(2015, 6, 30), 12.1d); PointSensitivities test1 = PointSensitivities.of(Lists.newArrayList(CS3, CS1)).normalized(); PointSensitivities test2 = PointSensitivities.of(Lists.newArrayList(CS3, cs1b)).normalized(); assertTrue(test1.equalWithTolerance(test2, 1.0E-1)); }
public int compareKey(PointSensitivity other) { if (other is DummyPointSensitivity) { DummyPointSensitivity otherZero = (DummyPointSensitivity)other; return(ComparisonChain.start().compare(curveCurrency, otherZero.curveCurrency).compare(currency, otherZero.currency).compare(date, otherZero.date).result()); } return(this.GetType().Name.CompareTo(other.GetType().Name)); }
public int compareKey(PointSensitivity other) { if (other is InflationRateSensitivity) { InflationRateSensitivity otherInflation = (InflationRateSensitivity)other; return(ComparisonChain.start().compare(Index.ToString(), otherInflation.Index.ToString()).compare(currency, otherInflation.currency).compare(observation.FixingMonth, otherInflation.observation.FixingMonth).result()); } return(this.GetType().Name.CompareTo(other.GetType().Name)); }
public int compareKey(PointSensitivity other) { if (other is SwaptionSensitivity) { SwaptionSensitivity otherSwpt = (SwaptionSensitivity)other; return(ComparisonChain.start().compare(volatilitiesName, otherSwpt.volatilitiesName).compare(currency, otherSwpt.currency).compare(expiry, otherSwpt.expiry).compare(tenor, otherSwpt.tenor).compare(strike, otherSwpt.strike).compare(forward, otherSwpt.forward).result()); } return(this.GetType().Name.CompareTo(other.GetType().Name)); }
public int compareKey(PointSensitivity other) { if (other is BondFutureOptionSensitivity) { BondFutureOptionSensitivity otherOption = (BondFutureOptionSensitivity)other; return(ComparisonChain.start().compare(volatilitiesName.ToString(), otherOption.volatilitiesName.ToString()).compare(expiry, otherOption.expiry).compare(futureExpiryDate, otherOption.futureExpiryDate).compare(strikePrice, otherOption.strikePrice).compare(futurePrice, otherOption.futurePrice).compare(currency, otherOption.currency).result()); } return(this.GetType().Name.CompareTo(other.GetType().Name)); }
public int compareKey(PointSensitivity other) { if (other is FxForwardSensitivity) { FxForwardSensitivity otherFx = (FxForwardSensitivity)other; return(ComparisonChain.start().compare(currencyPair.ToString(), otherFx.currencyPair.ToString()).compare(currency, otherFx.currency).compare(referenceCurrency, otherFx.referenceCurrency).compare(referenceDate, otherFx.referenceDate).result()); } return(this.GetType().Name.CompareTo(other.GetType().Name)); }
public int compareKey(PointSensitivity other) { if (other is ZeroRateSensitivity) { ZeroRateSensitivity otherZero = (ZeroRateSensitivity)other; return(ComparisonChain.start().compare(curveCurrency, otherZero.curveCurrency).compare(currency, otherZero.currency).compare(yearFraction, otherZero.yearFraction).result()); } return(this.GetType().Name.CompareTo(other.GetType().Name)); }
public int compareKey(PointSensitivity other) { if (other is FxOptionSensitivity) { FxOptionSensitivity otherOption = (FxOptionSensitivity)other; return(ComparisonChain.start().compare(volatilitiesName, otherOption.volatilitiesName).compare(currencyPair.ToString(), otherOption.currencyPair.ToString()).compare(expiry, otherOption.expiry).compare(strike, otherOption.strike).compare(forward, otherOption.forward).compare(currency, otherOption.currency).result()); } return(this.GetType().Name.CompareTo(other.GetType().Name)); }
public int compareKey(PointSensitivity other) { if (other is CreditCurveZeroRateSensitivity) { CreditCurveZeroRateSensitivity otherZero = (CreditCurveZeroRateSensitivity)other; return(ComparisonChain.start().compare(zeroRateSensitivity.YearFraction, otherZero.zeroRateSensitivity.YearFraction).compare(zeroRateSensitivity.Currency, otherZero.zeroRateSensitivity.Currency).compare(zeroRateSensitivity.CurveCurrency, otherZero.zeroRateSensitivity.CurveCurrency).compare(legalEntityId, otherZero.legalEntityId).result()); } return(this.GetType().Name.CompareTo(other.GetType().Name)); }
public int compareKey(PointSensitivity other) { if (other is FxIndexSensitivity) { FxIndexSensitivity otherFx = (FxIndexSensitivity)other; return(ComparisonChain.start().compare(Index.ToString(), otherFx.Index.ToString()).compare(currency, otherFx.currency).compare(referenceCurrency, otherFx.referenceCurrency).compare(observation.FixingDate, otherFx.observation.FixingDate).result()); } return(this.GetType().Name.CompareTo(other.GetType().Name)); }
public int compareKey(PointSensitivity other) { if (other is OvernightRateSensitivity) { OvernightRateSensitivity otherOn = (OvernightRateSensitivity)other; return(ComparisonChain.start().compare(Index.ToString(), otherOn.Index.ToString()).compare(currency, otherOn.currency).compare(observation.FixingDate, otherOn.observation.FixingDate).compare(endDate, otherOn.endDate).result()); } return(this.GetType().Name.CompareTo(other.GetType().Name)); }
public int compareKey(PointSensitivity other) { if (other is IborCapletFloorletSabrSensitivity) { IborCapletFloorletSabrSensitivity otherSwpt = (IborCapletFloorletSabrSensitivity)other; return(ComparisonChain.start().compare(volatilitiesName, otherSwpt.volatilitiesName).compare(currency, otherSwpt.currency).compare(expiry, otherSwpt.expiry).compare(sensitivityType, otherSwpt.sensitivityType).result()); } return(this.GetType().Name.CompareTo(other.GetType().Name)); }
//------------------------------------------------------------------------- public virtual void test_convertedTo_singleCurrency() { double rate = 1.5d; FxMatrix matrix = FxMatrix.of(CurrencyPair.of(GBP, USD), rate); PointSensitivities @base = PointSensitivities.of(Lists.newArrayList(CS3, CS2, CS1)); PointSensitivities test1 = @base.convertedTo(USD, matrix); PointSensitivity c1Conv = CS1.convertedTo(USD, matrix); PointSensitivity c2Conv = CS2.convertedTo(USD, matrix); PointSensitivity c3Conv = CS3.convertedTo(USD, matrix); PointSensitivities expected = PointSensitivities.of(Lists.newArrayList(c3Conv, c2Conv, c1Conv)); assertEquals(test1.normalized(), expected.normalized()); PointSensitivities test2 = @base.convertedTo(GBP, matrix); assertEquals(test2.normalized(), @base.normalized()); }
// inserts a sensitivity into the mutable list in the right location // merges the entry with an existing entry if the key matches private static void insert(IList <PointSensitivity> mutable, PointSensitivity addition) { //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: int index = Collections.binarySearch(mutable, addition, PointSensitivity::compareKey); if (index >= 0) { PointSensitivity @base = mutable[index]; double combined = @base.Sensitivity + addition.Sensitivity; mutable[index] = @base.withSensitivity(combined); } else { int insertionPoint = -(index + 1); mutable.Insert(insertionPoint, addition); } }
public virtual void test_convertedTo_multipleCurrency() { double rate = 1.5d; FxMatrix matrix = FxMatrix.of(CurrencyPair.of(GBP, USD), rate); PointSensitivities @base = PointSensitivities.of(Lists.newArrayList(CS4, CS3, CS1)); PointSensitivities test1 = @base.convertedTo(USD, matrix); PointSensitivity c1Conv = CS1.convertedTo(USD, matrix); PointSensitivity c3Conv = CS3.convertedTo(USD, matrix); PointSensitivity c3c4Usd = c3Conv.withSensitivity(c3Conv.Sensitivity + CS4.Sensitivity); PointSensitivities expected1 = PointSensitivities.of(Lists.newArrayList(c3c4Usd, c1Conv)); assertEquals(test1.normalized(), expected1.normalized()); PointSensitivities test2 = @base.convertedTo(GBP, matrix); PointSensitivity c4Conv = CS4.convertedTo(GBP, matrix); PointSensitivity c3c4GBP = CS3.withSensitivity(CS3.Sensitivity + c4Conv.Sensitivity); PointSensitivities expected2 = PointSensitivities.of(Lists.newArrayList(c3c4GBP, CS1)); assertEquals(test2.normalized(), expected2.normalized()); }
/// <summary> /// Creates an instance with the specified sensitivity. /// </summary> /// <param name="sensitivity"> the sensitivity to add </param> public MutablePointSensitivities(PointSensitivity sensitivity) { ArgChecker.notNull(sensitivity, "sensitivity"); this.sensitivities.Add(sensitivity); }