@Test(enabled = true)
/**
* Analyzes incoherence between curve inerpolation and forward points interpolation.
*/
public void forwardPointsInterpolation() {
final MulticurveProviderDiscount multicurves = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(0).getFirst();
// FX swap description
final double notionalEUR = 1E8; //100m
final double fxEURUSDFwdInit = FX_EURUSD + 0.0010; // Should have no impact
final Period startTenor = Period.ofMonths(0);
final Period endTenor = Period.ofMonths(12);
final ZonedDateTime spot = ScheduleCalculator.getAdjustedDate(NOW, USDLIBOR3M.getSpotLag(), TARGET);
final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(spot, startTenor, USDLIBOR3M, NYC);
final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(spot, endTenor, USDLIBOR3M, NYC);
final double[] points = DSC_EUR_MARKET_QUOTES;
final double[] time = ((InterpolatedDoublesCurve) ((YieldCurve) multicurves.getCurve(EUR)).getCurve()).getXDataAsPrimitive();
final InterpolatedDoublesCurve pointsCurve = new InterpolatedDoublesCurve(time, points, INTERPOLATOR_LINEAR, true, "Points curve");
ZonedDateTime loopdate = startDate;
final List<Double> pvUSDCurve = new ArrayList<>();
final List<Double> pvUSDPts = new ArrayList<>();
final List<Double> pvUSDDiff = new ArrayList<>();
final List<Double> ptsCurve = new ArrayList<>();
final List<Double> ptsInt = new ArrayList<>();
final List<Double> ptsDiff = new ArrayList<>();
final List<Double> payTime = new ArrayList<>();
while (!loopdate.isAfter(endDate)) {
final ForexDefinition fxSwapDefinition = new ForexDefinition(EUR, USD, loopdate, notionalEUR, fxEURUSDFwdInit);
final Forex fxSwap = fxSwapDefinition.toDerivative(NOW);
final MultipleCurrencyAmount pvFxSwap = fxSwap.accept(PVDC, multicurves);
final double pvUSDCurved = FX_MATRIX.convert(pvFxSwap, USD).getAmount();
pvUSDCurve.add(pvUSDCurved);
final double pvUSDPtsd = -(fxEURUSDFwdInit - FX_EURUSD - pointsCurve.getYValue(fxSwap.getPaymentTime()))
* multicurves.getDiscountFactor(USD, fxSwap.getPaymentTime()) * notionalEUR;
pvUSDPts.add(pvUSDPtsd);
pvUSDDiff.add(pvUSDCurved - pvUSDPtsd);
// double testUSDI = (fxEURUSDFwdInit)
// * multicurves.getDiscountFactor(USD, fxSwap.getPaymentTime()) * notionalEUR;
// double testUSDC = (FX_EURUSD + pointsCurve.getYValue(fxSwap.getPaymentTime()))
// * multicurves.getDiscountFactor(USD, fxSwap.getPaymentTime()) * notionalEUR;
// double testEURUSD = pvFxSwap.getAmount(EUR) * FX_EURUSD;
final double ptC = (multicurves.getDiscountFactor(EUR, fxSwap.getPaymentTime()) / multicurves.getDiscountFactor(USD, fxSwap.getPaymentTime()) - 1) * FX_EURUSD;
ptsCurve.add(ptC);
ptsInt.add(pointsCurve.getYValue(fxSwap.getPaymentTime()));
ptsDiff.add((ptC - pointsCurve.getYValue(fxSwap.getPaymentTime())) * 10000);
payTime.add(fxSwap.getPaymentTime());
loopdate = ScheduleCalculator.getAdjustedDate(loopdate, 1, TARGET);