本文整理了Java中com.opengamma.strata.pricer.ZeroRateSensitivity
类的一些代码示例,展示了ZeroRateSensitivity
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZeroRateSensitivity
类的具体详情如下:
包路径:com.opengamma.strata.pricer.ZeroRateSensitivity
类名称:ZeroRateSensitivity
[英]Point sensitivity to the zero rate curve.
Holds the sensitivity to the zero rate curve at a specific date.
[中]零速率曲线的点灵敏度。
在特定日期保持对零利率曲线的敏感性。
代码示例来源:origin: OpenGamma/Strata
public void test_build() {
ZeroRateSensitivity base = ZeroRateSensitivity.of(GBP, YEARFRAC, 32d);
PointSensitivities test = base.build();
assertEquals(test.getSensitivities(), ImmutableList.of(base));
}
代码示例来源:origin: OpenGamma/Strata
public void test_combinedWith() {
ZeroRateSensitivity base1 = ZeroRateSensitivity.of(GBP, YEARFRAC, 32d);
ZeroRateSensitivity base2 = ZeroRateSensitivity.of(GBP, YEARFRAC2, 22d);
MutablePointSensitivities expected = new MutablePointSensitivities();
expected.add(base1).add(base2);
PointSensitivityBuilder test = base1.combinedWith(base2);
assertEquals(test, expected);
}
代码示例来源:origin: OpenGamma/Strata
public void test_convertedTo() {
double sensi = 32d;
ZeroRateSensitivity base = ZeroRateSensitivity.of(GBP, YEARFRAC, sensi);
double rate = 1.5d;
FxMatrix matrix = FxMatrix.of(CurrencyPair.of(GBP, USD), rate);
ZeroRateSensitivity test1 = (ZeroRateSensitivity) base.convertedTo(USD, matrix);
ZeroRateSensitivity expected = ZeroRateSensitivity.of(GBP, YEARFRAC, USD, rate * sensi);
assertEquals(test1, expected);
ZeroRateSensitivity test2 = (ZeroRateSensitivity) base.convertedTo(GBP, matrix);
assertEquals(test2, base);
}
代码示例来源:origin: OpenGamma/Strata
/**
* Obtains an instance from zero rate sensitivity and group.
*
* @param zeroRateSensitivity the zero rate sensitivity
* @param repoGroup the group
* @return the point sensitivity object
*/
public static RepoCurveZeroRateSensitivity of(ZeroRateSensitivity zeroRateSensitivity, RepoGroup repoGroup) {
return of(
zeroRateSensitivity.getCurveCurrency(),
zeroRateSensitivity.getYearFraction(),
zeroRateSensitivity.getCurrency(),
repoGroup,
zeroRateSensitivity.getSensitivity());
}
代码示例来源:origin: OpenGamma/Strata
@Override
public int compareKey(PointSensitivity other) {
if (other instanceof CreditCurveZeroRateSensitivity) {
CreditCurveZeroRateSensitivity otherZero = (CreditCurveZeroRateSensitivity) other;
return ComparisonChain.start()
.compare(zeroRateSensitivity.getYearFraction(), otherZero.zeroRateSensitivity.getYearFraction())
.compare(zeroRateSensitivity.getCurrency(), otherZero.zeroRateSensitivity.getCurrency())
.compare(zeroRateSensitivity.getCurveCurrency(), otherZero.zeroRateSensitivity.getCurveCurrency())
.compare(legalEntityId, otherZero.legalEntityId)
.result();
}
return getClass().getSimpleName().compareTo(other.getClass().getSimpleName());
}
代码示例来源:origin: OpenGamma/Strata
@Override
public CurrencyParameterSensitivities parameterSensitivity(ZeroRateSensitivity pointSensitivity) {
double yearFraction = pointSensitivity.getYearFraction();
UnitParameterSensitivity unitSens = curve.yValueParameterSensitivity(yearFraction);
CurrencyParameterSensitivity curSens =
unitSens.multipliedBy(pointSensitivity.getCurrency(), pointSensitivity.getSensitivity());
return CurrencyParameterSensitivities.of(curSens);
}
代码示例来源:origin: OpenGamma/Strata
public void test_of() {
ZeroRateSensitivity test = ZeroRateSensitivity.of(GBP, YEARFRAC, 32d);
assertEquals(test.getCurrency(), GBP);
assertEquals(test.getYearFraction(), YEARFRAC);
assertEquals(test.getSensitivity(), 32d);
assertEquals(test.getCurrency(), GBP);
}
代码示例来源:origin: OpenGamma/Strata
public void test_zeroRatePointSensitivityWithSpread_sensitivityCurrency_smallYearFraction() {
ZeroRatePeriodicDiscountFactors test = ZeroRatePeriodicDiscountFactors.of(GBP, DATE_VAL, CURVE);
ZeroRateSensitivity expected = ZeroRateSensitivity.of(GBP, 0d, USD, 0.0d);
ZeroRateSensitivity computed = test.zeroRatePointSensitivityWithSpread(DATE_VAL, USD, SPREAD, CONTINUOUS, 0);
assertTrue(computed.compareKey(expected) == 0);
assertEquals(computed.getSensitivity(), expected.getSensitivity(), TOLERANCE_DELTA_FD);
}
代码示例来源:origin: OpenGamma/Strata
@Override
public CreditCurveZeroRateSensitivity multipliedBy(double factor) {
return new CreditCurveZeroRateSensitivity(legalEntityId, zeroRateSensitivity.multipliedBy(factor));
}
代码示例来源:origin: OpenGamma/Strata
/**
* Obtains the underlying {@code ZeroRateSensitivity}.
* <p>
* This creates the zero rate sensitivity object by omitting the repo group.
*
* @return the point sensitivity object
*/
public ZeroRateSensitivity createZeroRateSensitivity() {
return ZeroRateSensitivity.of(curveCurrency, yearFraction, currency, sensitivity);
}
代码示例来源:origin: OpenGamma/Strata
public void presentValueSensitivity_beforeFixing_coupon() {
PointSensitivities pv = PRICER_CMS.presentValueSensitivity(COUPON, RATES_PROVIDER).build();
double df = RATES_PROVIDER.discountFactor(EUR, PAYMENT);
ZeroRateSensitivity dfdr = RATES_PROVIDER.discountFactors(EUR).zeroRatePointSensitivity(PAYMENT);
double forward = PRICER_SWAP.parRate(COUPON.getUnderlyingSwap(), RATES_PROVIDER);
PointSensitivities forwarddr = PRICER_SWAP.parRateSensitivity(COUPON.getUnderlyingSwap(), RATES_PROVIDER).build();
PointSensitivities expected = forwarddr.multipliedBy(df).combinedWith(dfdr.multipliedBy(forward).build())
.multipliedBy(NOTIONAL * ACC_FACTOR);
assertTrue(pv.equalWithTolerance(expected, TOLERANCE_DELTA));
}
代码示例来源:origin: OpenGamma/Strata
public void test_unitParameterSensitivity() {
ZeroRateDiscountFactors test = ZeroRateDiscountFactors.of(GBP, DATE_VAL, CURVE);
ZeroRateSensitivity sens = test.zeroRatePointSensitivity(DATE_AFTER);
double relativeYearFraction = ACT_365F.relativeYearFraction(DATE_VAL, DATE_AFTER);
CurrencyParameterSensitivities expected = CurrencyParameterSensitivities.of(
CURVE.yValueParameterSensitivity(relativeYearFraction)
.multipliedBy(sens.getCurrency(), sens.getSensitivity()));
assertEquals(test.parameterSensitivity(sens), expected);
}
代码示例来源:origin: OpenGamma/Strata
@Override
public CreditCurveZeroRateSensitivity withCurrency(Currency currency) {
if (this.zeroRateSensitivity.getCurrency().equals(currency)) {
return this;
}
return new CreditCurveZeroRateSensitivity(legalEntityId, zeroRateSensitivity.withCurrency(currency));
}
代码示例来源:origin: OpenGamma/Strata
public void test_mapSensitivity() {
ZeroRateSensitivity base = ZeroRateSensitivity.of(GBP, YEARFRAC, 32d);
ZeroRateSensitivity expected = ZeroRateSensitivity.of(GBP, YEARFRAC, 1 / 32d);
ZeroRateSensitivity test = base.mapSensitivity(s -> 1 / s);
assertEquals(test, expected);
}
代码示例来源:origin: OpenGamma/Strata
public void test_withSensitivity() {
ZeroRateSensitivity base = ZeroRateSensitivity.of(GBP, YEARFRAC, 32d);
ZeroRateSensitivity expected = ZeroRateSensitivity.of(GBP, YEARFRAC, 20d);
ZeroRateSensitivity test = base.withSensitivity(20d);
assertEquals(test, expected);
}
代码示例来源:origin: OpenGamma/Strata
public void test_multipliedBy() {
ZeroRateSensitivity base = ZeroRateSensitivity.of(GBP, YEARFRAC, 32d);
ZeroRateSensitivity expected = ZeroRateSensitivity.of(GBP, YEARFRAC, 32d * 3.5d);
ZeroRateSensitivity test = base.multipliedBy(3.5d);
assertEquals(test, expected);
}
代码示例来源:origin: OpenGamma/Strata
/**
* Gets the currency of the curve for which the sensitivity is computed.
*
* @return the curve currency
*/
public Currency getCurveCurrency() {
return zeroRateSensitivity.getCurveCurrency();
}
代码示例来源:origin: OpenGamma/Strata
public void presentValueSensitivity_afterFix() {
PointSensitivities ptsCpn = PRICER_CMS.presentValueSensitivity(COUPON, RATES_PROVIDER_AFTER_FIX).build();
PointSensitivities ptsCapletOtm = PRICER_CMS.presentValueSensitivity(CAPLET, RATES_PROVIDER_AFTER_FIX).build();
PointSensitivities ptsCapletItm = PRICER_CMS.presentValueSensitivity(CAPLET_NEGATIVE, RATES_PROVIDER_AFTER_FIX).build();
PointSensitivities ptsFloorletItm = PRICER_CMS.presentValueSensitivity(FLOORLET, RATES_PROVIDER_AFTER_FIX).build();
PointSensitivities ptsFloorletOtm = PRICER_CMS.presentValueSensitivity(FLOORLET_NEGATIVE, RATES_PROVIDER_AFTER_FIX).build();
double factor = NOTIONAL * COUPON.getYearFraction();
ZeroRateSensitivity pts = RATES_PROVIDER_AFTER_FIX.discountFactors(EUR).zeroRatePointSensitivity(PAYMENT);
assertTrue(ptsCpn.equalWithTolerance(pts.build().multipliedBy(factor * OBS_INDEX), TOLERANCE_DELTA));
assertTrue(ptsCapletOtm.equalWithTolerance(pts.build().multipliedBy(0d), TOLERANCE_DELTA));
assertTrue(ptsCapletItm.equalWithTolerance(pts.build().multipliedBy(factor * (OBS_INDEX - STRIKE_NEGATIVE)), TOLERANCE_DELTA));
assertTrue(ptsFloorletItm.equalWithTolerance(pts.build().multipliedBy(factor * (STRIKE - OBS_INDEX)), TOLERANCE_DELTA));
assertTrue(ptsFloorletOtm.equalWithTolerance(pts.build().multipliedBy(0d), TOLERANCE_DELTA));
}
代码示例来源:origin: OpenGamma/Strata
/**
* Gets the time that was queried, expressed as a year fraction.
*
* @return the year fraction
*/
public double getYearFraction() {
return zeroRateSensitivity.getYearFraction();
}
代码示例来源:origin: OpenGamma/Strata
@Override
public double getSensitivity() {
return zeroRateSensitivity.getSensitivity();
}
内容来源于网络,如有侵权,请联系作者删除!