本文整理了Java中com.opengamma.strata.pricer.ZeroRateSensitivity.build()
方法的一些代码示例,展示了ZeroRateSensitivity.build()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZeroRateSensitivity.build()
方法的具体详情如下:
包路径:com.opengamma.strata.pricer.ZeroRateSensitivity
类名称:ZeroRateSensitivity
方法名:build
暂无
代码示例来源: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 presentValueSensitivity_onFix_ts() {
PointSensitivities ptsCpn = PRICER_CMS.presentValueSensitivity(COUPON, RATES_PROVIDER_ON_FIX_TS).build();
PointSensitivities ptsCapletOtm = PRICER_CMS.presentValueSensitivity(CAPLET, RATES_PROVIDER_ON_FIX_TS).build();
PointSensitivities ptsCapletItm = PRICER_CMS.presentValueSensitivity(CAPLET_NEGATIVE, RATES_PROVIDER_ON_FIX_TS).build();
PointSensitivities ptsFloorletItm = PRICER_CMS.presentValueSensitivity(FLOORLET, RATES_PROVIDER_ON_FIX_TS).build();
PointSensitivities ptsFloorletOtm = PRICER_CMS.presentValueSensitivity(FLOORLET_NEGATIVE, RATES_PROVIDER_ON_FIX_TS).build();
double factor = NOTIONAL * COUPON.getYearFraction();
ZeroRateSensitivity pts = RATES_PROVIDER_ON_FIX_TS.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
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
public void test_curveParameterSensitivity_noSensi() {
ImmutableLegalEntityDiscountingProvider test = ImmutableLegalEntityDiscountingProvider.builder()
.issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), DSC_FACTORS_ISSUER))
.issuerCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_ISSUER))
.repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO_ISSUER, GBP), DSC_FACTORS_REPO))
.repoCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_REPO_ISSUER))
.valuationDate(DATE)
.build();
ZeroRateSensitivity sensi =
ZeroRateSensitivity.of(USD, DSC_FACTORS_ISSUER.relativeYearFraction(date(2018, 11, 24)), 25d);
CurrencyParameterSensitivities computed = test.parameterSensitivity(sensi.build());
assertEquals(computed, CurrencyParameterSensitivities.empty());
}
代码示例来源:origin: OpenGamma/Strata
public void presentValueSensitivity_onFix_nots() {
PointSensitivities pv = PRICER_CMS.presentValueSensitivity(COUPON, RATES_PROVIDER_ON_FIX).build();
double df = RATES_PROVIDER_ON_FIX.discountFactor(EUR, PAYMENT);
ZeroRateSensitivity dfdr = RATES_PROVIDER_ON_FIX.discountFactors(EUR).zeroRatePointSensitivity(PAYMENT);
double forward = PRICER_SWAP.parRate(COUPON.getUnderlyingSwap(), RATES_PROVIDER_ON_FIX);
PointSensitivities forwarddr = PRICER_SWAP.parRateSensitivity(COUPON.getUnderlyingSwap(), RATES_PROVIDER_ON_FIX).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 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
/**
* Calculates the par spread sensitivity to the curves.
* <p>
* The sensitivity is reported in the counter currency of the product, but is actually dimensionless.
*
* @param swap the product
* @param provider the rates provider
* @return the spread curve sensitivity
*/
public PointSensitivities parSpreadSensitivity(ResolvedFxSwap swap, RatesProvider provider) {
Payment counterPaymentNear = swap.getNearLeg().getCounterCurrencyPayment();
MultiCurrencyAmount pv = presentValue(swap, provider);
double pvCounterCcy = pv.convertedTo(counterPaymentNear.getCurrency(), provider).getAmount();
double dfEnd = provider.discountFactor(counterPaymentNear.getCurrency(), swap.getFarLeg().getPaymentDate());
double notionalBaseCcy = swap.getNearLeg().getBaseCurrencyPayment().getAmount();
double ps = -pvCounterCcy / (notionalBaseCcy * dfEnd);
// backward sweep
double psBar = 1d;
double pvCounterCcyBar = -1d / (notionalBaseCcy * dfEnd) * psBar;
double dfEndBar = -ps / dfEnd * psBar;
ZeroRateSensitivity ddfEnddr = provider.discountFactors(counterPaymentNear.getCurrency())
.zeroRatePointSensitivity(swap.getFarLeg().getPaymentDate());
PointSensitivities result = ddfEnddr.multipliedBy(dfEndBar).build();
PointSensitivities dpvdr = presentValueSensitivity(swap, provider);
PointSensitivities dpvdrConverted = dpvdr.convertedTo(counterPaymentNear.getCurrency(), provider);
return result.combinedWith(dpvdrConverted.multipliedBy(pvCounterCcyBar));
}
内容来源于网络,如有侵权,请联系作者删除!