Package it.unimi.dsi.fastutil.doubles

Examples of it.unimi.dsi.fastutil.doubles.DoubleArrayList


    double callAboveStrike = 0;
    if (specification.getSurfaceInstrumentProvider() instanceof CallPutSurfaceInstrumentProvider) {
      callAboveStrike = ((CallPutSurfaceInstrumentProvider<?, ?>) specification.getSurfaceInstrumentProvider()).useCallAboveStrike();
    }
    final Map<Pair<Double, Double>, Double> volatilityValues = new HashMap<Pair<Double, Double>, Double>();
    final DoubleArrayList txList = new DoubleArrayList();
    final DoubleArrayList kList = new DoubleArrayList();
    final LocalDate today = now.toLocalDate();
    final Double[] futureExpiries = futurePrices.getXData();
    final int nFutures = futureExpiries.length;
    if (nFutures == 0) {
      throw new OpenGammaRuntimeException("No future prices found for surface : " + specification.getName());
    }
    for (final Number x : optionPrices.getXs()) {
      // Loop over option expiries
      final int nFutureOption = x.intValue();
      final LocalDate futureOptionExpiryDate = expiryCalculator.getExpiryDate(nFutureOption, today, calendar);
      final Double optionExpiry = TimeCalculator.getTimeBetween(today, futureOptionExpiryDate);
      int nFuture = 0;
      while (optionExpiry > futureExpiries[nFuture]) {
        nFuture++;
      }
      final Double forward = futurePrices.getYValue(futureExpiries[nFuture]);
      // Loop over strikes
      for (final Double y : optionPrices.getYs()) {
        final Double price = optionPrices.getVolatility(x, y);
        if (price != null) {
          try {
            final boolean isCall = y > callAboveStrike ? true : false;
            double volatility;
            if (forward > 60) { //TODO quick hack to allow use of PX_SETTLE
              volatility = getVolatility(surfaceQuoteType, y / 100.0, price / 100, forward / 100, optionExpiry, isCall);
            } else {
              volatility = getVolatility(surfaceQuoteType, y / 100.0, price, forward, optionExpiry, isCall);
            }
            if (!CompareUtils.closeEquals(volatility, 0.0)) {
              txList.add(optionExpiry);
              kList.add(y / 100.0);
              volatilityValues.put(Pair.of(optionExpiry, y / 100.), volatility);
            }
          } catch (final MathException e) {
            s_logger.info("Could not imply volatility for ({}, {}); error was {}", new Object[] {x, y, e.getMessage() });
          } catch (final IllegalArgumentException e) {
            s_logger.error("Could not imply volatility for future option number={}, strike={}; error was {}", new Object[] {x, y, e.getMessage() });
          }
        }
      }
    }
    return new VolatilitySurfaceData<Double, Double>(optionPrices.getDefinitionName(), optionPrices.getSpecificationName(),
        optionPrices.getTarget(), txList.toArray(new Double[0]), kList.toArray(new Double[0]), volatilityValues);
  }
View Full Code Here


    }
    @SuppressWarnings("unchecked")
    final VolatilitySurfaceData<LocalDate, Double> volatilitySurfaceData = (VolatilitySurfaceData<LocalDate, Double>) volatilitySurfaceDataObject;
    final int n = volatilitySurfaceData.getXs().length;
    final int m = volatilitySurfaceData.getYs().length;
    final DoubleArrayList t = new DoubleArrayList();
    final DoubleArrayList k = new DoubleArrayList();
    final DoubleArrayList sigma = new DoubleArrayList();
    final LocalDate[] xDates = volatilitySurfaceData.getXs();
    final Double[] y = volatilitySurfaceData.getYs();
    for (int i = 0; i < n; i++) {
      final Double time = DateUtils.getDifferenceInYears(now.toLocalDate(), xDates[i]);
      for (int j = 0; j < m; j++) {
        final Double strike = y[j];
        final Double vol = volatilitySurfaceData.getVolatility(xDates[i], y[j]);
        if (time != null && strike != null && vol != null) {
          t.add(time);
          k.add(strike);
          sigma.add(vol);
        }
      }
    }
    final Surface<Double, Double, Double> surface = InterpolatedDoublesSurface.from(t.toDoubleArray(), k.toDoubleArray(), sigma.toDoubleArray(), _interpolator);
    final VolatilitySurface volatilitySurface = new VolatilitySurface(surface);
    return Collections.singleton(new ComputedValue(_result, volatilitySurface));
  }
View Full Code Here

  }

  private static VolatilitySurfaceData<Double, Double> getSurfaceFromVolatilityQuote(final LocalDate valDate, final VolatilitySurfaceData<Object, Object> rawSurface) {
    // Remove empties, convert expiries from number to years, and scale vols
    final Map<Pair<Double, Double>, Double> volValues = new HashMap<>();
    final DoubleArrayList tList = new DoubleArrayList();
    final DoubleArrayList kList = new DoubleArrayList();
    final Object[] xs = rawSurface.getXs();
    for (final Object x : xs) {
      Double t;
      if (x instanceof Number) {
        t = FutureOptionExpiries.EQUITY.getFutureOptionTtm(((Number) x).intValue(), valDate);
      } else if (x instanceof LocalDate) {
        t = TimeCalculator.getTimeBetween((LocalDate) x, valDate);
      } else {
        throw new OpenGammaRuntimeException("Cannot not handle surfaces with x-axis type " + x.getClass());
      }
      if (t > 5. / 365.) { // Bootstrapping vol surface to this data causes far more trouble than any gain. The data simply isn't reliable.
        final Double[] ysAsDoubles = getYs(rawSurface.getYs());
        for (final Double strike : ysAsDoubles) {
          final Double vol = rawSurface.getVolatility(x, strike);
          if (vol != null) {
            tList.add(t);
            kList.add(strike);
            volValues.put(Pair.of(t, strike), vol / 100.);
          }
        }
      }
    }
    final VolatilitySurfaceData<Double, Double> stdVolSurface = new VolatilitySurfaceData<>(rawSurface.getDefinitionName(), rawSurface.getSpecificationName(), rawSurface.getTarget(),
        tList.toArray(new Double[0]), kList.toArray(new Double[0]), volValues);
    return stdVolSurface;
  }
View Full Code Here

    if (isAmerican) {
      americanModel = new BjerksundStenslandModel();
    }
    // Main loop: Remove empties, convert expiries from number to years, and imply vols
    final Map<Pair<Double, Double>, Double> volValues = new HashMap<>();
    final DoubleArrayList tList = new DoubleArrayList();
    final DoubleArrayList kList = new DoubleArrayList();
    final Object[] xs = rawSurface.getXs();
    for (final Object x : xs) {
      Double t;
      if (x instanceof Number) {
        t = FutureOptionExpiries.EQUITY.getFutureOptionTtm(((Number) x).intValue(), valDate);
      } else if (x instanceof LocalDate) {
        t = TimeCalculator.getTimeBetween((LocalDate) x, valDate);
      } else {
        throw new OpenGammaRuntimeException("Cannot not handle surfaces with x-axis type " + x.getClass());
      }
      final double forward = forwardCurve.getForward(t);
      final double zerobond = discountCurve.getDiscountFactor(t);
      final Double[] ysAsDoubles = getYs(rawSurface.getYs());
      for (final Double strike : ysAsDoubles) {
        final Double price = rawSurface.getVolatility(x, strike);
        if (price != null) {
          try {
            if (quoteTypeIsCallPutStrike) {
              optionIsCall = strike > callAboveStrike ? true : false;
            }
            final double vol;
            if (isAmerican) {
              vol = americanModel.impliedVolatility(price, spot, strike, -Math.log(zerobond) / t, Math.log(forward / spot) / t, t, optionIsCall);
            } else {
              final double fwdPrice = price / zerobond;
              vol = BlackFormulaRepository.impliedVolatility(fwdPrice, forward, strike, t, optionIsCall);
            }
            tList.add(t);
            kList.add(strike);
            volValues.put(Pair.of(t, strike), vol);
          } catch (final Exception e) {
            LocalDate expiry = null;
            if (x instanceof Number) {
              expiry = FutureOptionExpiries.EQUITY.getFutureOptionExpiry(((Number) x).intValue(), valDate);
            } else if (x instanceof LocalDate) {
              expiry = (LocalDate) x;
            }
            s_logger.info("Liquidity problem: input price, forward and zero bond imply negative volatility at strike, {}, and expiry, {}",
                strike, expiry);
          }
        }
      }
    }
    final VolatilitySurfaceData<Double, Double> stdVolSurface = new VolatilitySurfaceData<>(rawSurface.getDefinitionName(), rawSurface.getSpecificationName(), rawSurface.getTarget(),
        tList.toArray(new Double[0]), kList.toArray(new Double[0]), volValues);
    return stdVolSurface;
  }
View Full Code Here

  }

  private static VolatilitySurfaceData<Double, Double> getSurfaceFromVolatilityQuote(final LocalDate valDate, final VolatilitySurfaceData<Pair<Integer, Tenor>, Double> rawSurface) {
    // Remove empties, convert expiries from number to years, and scale vols
    final Map<Pair<Double, Double>, Double> volValues = new HashMap<>();
    final DoubleArrayList tList = new DoubleArrayList();
    final DoubleArrayList kList = new DoubleArrayList();
    for (final Pair<Integer, Tenor> nthExpiry : rawSurface.getXs()) {
      final double t = FutureOptionExpiries.EQUITY_FUTURE.getFutureOptionTtm(nthExpiry.getFirst(), valDate, nthExpiry.getSecond()); //TODO need information about expiry calculator
      if (t > 5. / 365.) { // Bootstrapping vol surface to this data causes far more trouble than any gain. The data simply isn't reliable.
        for (final Double strike : rawSurface.getYs()) {
          final Double vol = rawSurface.getVolatility(nthExpiry, strike);
          if (vol != null) {
            tList.add(t);
            kList.add(strike);
            volValues.put(Pair.of(t, strike), vol / 100.);
          }
        }
      }
    }
    final VolatilitySurfaceData<Double, Double> stdVolSurface = new VolatilitySurfaceData<>(rawSurface.getDefinitionName(), rawSurface.getSpecificationName(), rawSurface.getTarget(),
        tList.toArray(new Double[0]), kList.toArray(new Double[0]), volValues);
    return stdVolSurface;
  }
View Full Code Here

    if (specification.getSurfaceInstrumentProvider() instanceof CallPutSurfaceInstrumentProvider) {
      callAboveStrike = ((CallPutSurfaceInstrumentProvider<?, ?>) specification.getSurfaceInstrumentProvider()).useCallAboveStrike();
    }
    // Remove empties, convert expiries from number to years, and imply vols
    final Map<Pair<Double, Double>, Double> volValues = new HashMap<>();
    final DoubleArrayList tList = new DoubleArrayList();
    final DoubleArrayList kList = new DoubleArrayList();
    for (final Pair<Integer, Tenor> nthExpiry : rawSurface.getXs()) {
      final double t = FutureOptionExpiries.EQUITY_FUTURE.getFutureOptionTtm(nthExpiry.getFirst(), valDate, nthExpiry.getSecond()); //TODO need information about expiry calculator
      final double forward = forwardCurve.getForward(t);
      if (t > 5. / 365.) { // Bootstrapping vol surface to this data causes far more trouble than any gain. The data simply isn't reliable.
        for (final Double strike : rawSurface.getYs()) {
          final Double price = rawSurface.getVolatility(nthExpiry, strike);
          if (price != null) {
            try {
              final double vol;
              if (surfaceQuoteType.equals(SurfaceAndCubeQuoteType.CALL_STRIKE)) {
                vol = BlackFormulaRepository.impliedVolatility(price, forward, strike, t, true);
              } else if (surfaceQuoteType.equals(SurfaceAndCubeQuoteType.PUT_STRIKE)) {
                vol = BlackFormulaRepository.impliedVolatility(price, forward, strike, t, false);
              } else if (surfaceQuoteType.equals(SurfaceAndCubeQuoteType.CALL_AND_PUT_STRIKE)) {
                final boolean isCall = strike > callAboveStrike ? true : false;
                vol = BlackFormulaRepository.impliedVolatility(price, forward, strike, t, isCall);
              } else {
                throw new OpenGammaRuntimeException("Cannot handle surface quote type " + surfaceQuoteType);
              }
              tList.add(t);
              kList.add(strike);
              volValues.put(Pair.of(t, strike), vol);
            } catch (final Exception e) {
            }
          }
        }
      }
    }
    final VolatilitySurfaceData<Double, Double> stdVolSurface = new VolatilitySurfaceData<>(rawSurface.getDefinitionName(), rawSurface.getSpecificationName(), rawSurface.getTarget(),
        tList.toArray(new Double[0]), kList.toArray(new Double[0]), volValues);
    return stdVolSurface;
  }
View Full Code Here

    return Collections.singleton(new ValueRequirement(ValueRequirementNames.VOLATILITY_SURFACE_DATA, target.toSpecification(), surfaceProperties));
  }

  private static VolatilitySurfaceData<Double, Double> getSurface(final VolatilitySurfaceData<Tenor, Tenor> volatilities) {
    final Map<Pair<Double, Double>, Double> volatilityValues = new HashMap<Pair<Double, Double>, Double>();
    final DoubleArrayList xList = new DoubleArrayList();
    final DoubleArrayList yList = new DoubleArrayList();
    for (final Tenor x : volatilities.getUniqueXValues()) {
      final double xTime = getTime(x);
      final List<ObjectsPair<Tenor, Double>> yValuesForX = volatilities.getYValuesForX(x);
      for (final ObjectsPair<Tenor, Double> pair : yValuesForX) {
        final double yTime = getTime(pair.getFirst());
        final Double volatility = pair.getSecond();
        if (volatility != null) {
          xList.add(xTime);
          yList.add(yTime);
          volatilityValues.put(Pair.of(xTime, yTime), volatility);
        }
      }
    }
    return new VolatilitySurfaceData<Double, Double>(volatilities.getDefinitionName(), volatilities.getSpecificationName(), volatilities.getTarget(),
        xList.toArray(new Double[0]), yList.toArray(new Double[0]), volatilityValues);
  }
View Full Code Here

    LocalDate valuationDate = startDate;
    while (!valuationDate.isAfter(endDate)) {
      final ZonedDateTime valuationDateTime = ZonedDateTime.of(valuationDate, now.toLocalTime(), now.getZone());
      final YieldCurveBundle knownCurves = getKnownCurves(curveCalculationConfig, targetSpec, inputs);
      final List<InstrumentDerivative> derivatives = new ArrayList<>();
      final DoubleArrayList marketValues = new DoubleArrayList();
      final DoubleArrayList initialRatesGuess = new DoubleArrayList();
      final LinkedHashMap<String, double[]> curveNodes = new LinkedHashMap<>();
      final LinkedHashMap<String, Interpolator1D> interpolators = new LinkedHashMap<>();
      final Map<String, Integer> nodesPerCurve = new HashMap<>();
      for (final String curveName : curveNames) {
        final HistoricalTimeSeriesBundle timeSeries = getTimeSeriesBundle(inputs, targetSpec, curveName);
        final InterpolatedYieldCurveSpecificationWithSecurities spec = getYieldCurveSpecification(inputs, targetSpec, curveName);
        int nInstruments = 0;
        final Interpolator1D interpolator = spec.getInterpolator();
        final HistoricalTimeSeriesBundle marketData = getHistoricalMarketData(inputs, targetSpec, curveName);
        final DoubleArrayList nodeTimes = new DoubleArrayList();
        FixedIncomeStripWithSecurity previousStrip = null;
        for (final FixedIncomeStripWithSecurity strip : spec.getStrips()) {
          //TODO a lot of this can be moved outside the date loop
          final HistoricalTimeSeries historicalTimeSeries = marketData.get(MarketDataRequirementNames.MARKET_VALUE, strip.getSecurityIdentifier());
          if (historicalTimeSeries == null) {
            throw new OpenGammaRuntimeException("Could not get historical time series for " + strip);
          }
          final LocalDateDoubleTimeSeries ts = historicalTimeSeries.getTimeSeries();
          final Double marketValue = ts.getValue(valuationDate);
          if (marketValue == null) {
            break;
          }
          final Security security = strip.getSecurity();
          final String[] curveNamesForSecurity = curveCalculationConfig.getCurveExposureForInstrument(curveName, strip.getInstrumentType());
          final InstrumentDefinition<?> definition = _securityConverter.visit(security);
          InstrumentDerivative derivative = _definitionConverter.convert(security, definition, now, curveNamesForSecurity, timeSeries);
          if (derivative != null) {
            if (strip.getInstrumentType() == StripInstrumentType.FUTURE) {
              final InterestRateFutureSecurityDefinition securityDefinition = (InterestRateFutureSecurityDefinition) definition;
              InterestRateFutureTransactionDefinition unitNotional = new InterestRateFutureTransactionDefinition(securityDefinition, now, marketValue, 1);
              unitNotional = unitNotional.withNewNotionalAndTransactionPrice(1, marketValue);
              InstrumentDerivative unitNotionalDerivative = _definitionConverter.convert(security, unitNotional, now, curveNamesForSecurity, timeSeries);
              unitNotionalDerivative = unitNotionalDerivative.accept(RateReplacingInterestRateDerivativeVisitor.getInstance(), marketValue);
              derivatives.add(unitNotionalDerivative);
              initialRatesGuess.add(1 - marketValue);
            } else {
              derivative = derivative.accept(RateReplacingInterestRateDerivativeVisitor.getInstance(), marketValue);
              derivatives.add(derivative);
              initialRatesGuess.add(marketValue);
            }
            final double t = derivative.accept(LAST_TIME_CALCULATOR);
            if (nInstruments > 0 && CompareUtils.closeEquals(nodeTimes.get(nInstruments - 1), t, 1e-12)) {
              throw new OpenGammaRuntimeException("Strip " + strip + " has same maturity as one already added (" + previousStrip + ") - will lead to" +
                  "equal nodes in the curve. Remove one of these strips.");
            }
            nodeTimes.add(Math.abs(t));
            marketValues.add(0.0);
            previousStrip = strip;
            nInstruments++;
          }
        }
        nodesPerCurve.put(curveName, nInstruments);
        curveNodes.put(curveName, nodeTimes.toDoubleArray());
        interpolators.put(curveName, interpolator);
      }
      if (marketValues.size() != totalStrips) {
        s_logger.info("Could not get market values for {}", valuationDate);
        valuationDate = valuationDate.plusDays(1);
View Full Code Here

        final String curveSpecificationName = curveName;
        final FuturePriceCurveDefinition<Object> priceCurveDefinition = getCurveDefinition(curveDefinitionSource, target, curveDefinitionName);
        final FuturePriceCurveSpecification priceCurveSpecification = getCurveSpecification(curveSpecificationSource, target, curveSpecificationName);
        final Clock snapshotClock = executionContext.getValuationClock();
        final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
        final DoubleArrayList xList = new DoubleArrayList();
        final DoubleArrayList prices = new DoubleArrayList();
        final FuturePriceCurveInstrumentProvider<Number> futurePriceCurveProvider = (FuturePriceCurveInstrumentProvider<Number>) priceCurveSpecification.getCurveInstrumentProvider();
        final ExchangeTradedInstrumentExpiryCalculator expiryCalc = futurePriceCurveProvider.getExpiryRuleCalculator();
        final LocalDate valDate = now.toLocalDate();
        if (inputs.getAllValues().isEmpty()) {
          throw new OpenGammaRuntimeException("Could not get any data for future price curve called " + curveSpecificationName);
        }
        for (final Object x : priceCurveDefinition.getXs()) {
          final Number xNum = (Number) x;
          final ExternalId identifier = futurePriceCurveProvider.getInstrument(xNum, valDate);
          final ValueRequirement requirement = new ValueRequirement(futurePriceCurveProvider.getDataFieldName(), ComputationTargetType.PRIMITIVE, identifier);
          Double futurePrice = null;
          if (inputs.getValue(requirement) != null) {
            futurePrice = (Double) inputs.getValue(requirement);
            if (futurePrice != null) {
              LocalDate expiry = expiryCalc.getExpiryDate(xNum.intValue(), valDate, calendar);
              final Double ttm = TimeCalculator.getTimeBetween(valDate, expiry);
              xList.add(ttm);
              prices.add(futurePrice);
            }
          }
        }
        final ValueSpecification futurePriceCurveResult = new ValueSpecification(ValueRequirementNames.FUTURE_PRICE_CURVE_DATA,
            target.toSpecification(),
            createValueProperties()
            .with(ValuePropertyNames.CURVE, curveName)
            .with(InstrumentTypeProperties.PROPERTY_SURFACE_INSTRUMENT_TYPE, getInstrumentType()).get());
        final NodalDoublesCurve curve = NodalDoublesCurve.from(xList.toDoubleArray(), prices.toDoubleArray());
        final ComputedValue futurePriceCurveResultValue = new ComputedValue(futurePriceCurveResult, curve);
        return Sets.newHashSet(futurePriceCurveResultValue);
      }

    };
View Full Code Here

      if (spotValue == null) {
        continue;
      }
      final double spotFX = invertFXQuotes ? 1 / spotValue : spotValue;
      final YieldAndDiscountCurve foreignCurve = entry.getValue();
      final DoubleArrayList marketValues = new DoubleArrayList();
      final DoubleArrayList nodeTimes = new DoubleArrayList();
      final DoubleArrayList initialRatesGuess = new DoubleArrayList();
      final String fullDomesticCurveName = domesticCurveName + "_" + domesticCurrency.getCode();
      final String fullForeignCurveName = foreignCurveName + "_" + foreignCurrency.getCode();
      final List<InstrumentDerivative> derivatives = new ArrayList<>();
      int nInstruments = 0;
      ZonedDateTime spotDate;
      if (spotLag == 0 && conventionSettlementRegion == null) {
        spotDate = valuationDateTime;
      } else {
        spotDate = ScheduleCalculator.getAdjustedDate(valuationDateTime, spotLag, calendar);
      }
      for (final Tenor tenor : definition.getTenors()) {
        final ExternalId identifier = provider.getInstrument(valuationDate, tenor);
        final HistoricalTimeSeries forwardFXTS = timeSeriesBundle.get(provider.getMarketDataField(), identifier);
        if (forwardFXTS == null) {
          throw new OpenGammaRuntimeException("Could not get time series for " + identifier);
        }
        final LocalDateDoubleTimeSeries forwardTS = forwardFXTS.getTimeSeries();
        final ZonedDateTime paymentDate;

        if (spotLag == 0 && conventionSettlementRegion == null) {
          paymentDate = now.plus(tenor.getPeriod()); //This preserves the old behaviour that ignored holidays and settlement days.
        } else {
          paymentDate = ScheduleCalculator.getAdjustedDate(now, tenor.getPeriod(), MOD_FOL, calendar, true);
        }

        final Double forwardValue = forwardTS.getValue(valuationDate);
        if (forwardValue == null) {
          break;
        }
        double forwardFX;
        switch (specification.getQuoteType()) {
          case Points:
            forwardFX = isRegular ? spotFX + forwardValue : 1 / (spotFX + forwardValue);
            break;
          case Outright:
            forwardFX = isRegular ? forwardValue : 1 / forwardValue;
            break;
          default:
            throw new OpenGammaRuntimeException("Cannot handle quote type " + specification.getQuoteType());
        }
        forwardFX = invertFXQuotes ? 1 / forwardFX : forwardFX;
        final double quotedSpotFX = invertFXQuotes ? 1 / spotFX : spotFX;
        final double paymentTime = TimeCalculator.getTimeBetween(now, paymentDate);
        derivatives.add(getFXForward(domesticCurrency, foreignCurrency, paymentTime, quotedSpotFX, forwardFX, fullDomesticCurveName, fullForeignCurveName));
        marketValues.add(forwardFX);
        nodeTimes.add(paymentTime);
        if (nInstruments > 1 && CompareUtils.closeEquals(nodeTimes.get(nInstruments - 1), paymentTime, 1e-12)) {
          throw new OpenGammaRuntimeException("FX forward with tenor " + tenor + " has already been added - will lead to equal nodes in the curve. Remove one of these tenors.");
        }
        nInstruments++;
        initialRatesGuess.add(0.02);
      }
      if (marketValues.size() == 0) {
        s_logger.error("Could not get market values for {}", valuationDate);
        continue;
      }
      final YieldCurveBundle knownCurve = new YieldCurveBundle(new String[] {fullForeignCurveName }, new YieldAndDiscountCurve[] {foreignCurve });
      final LinkedHashMap<String, double[]> curveKnots = new LinkedHashMap<>();
      curveKnots.put(fullDomesticCurveName, nodeTimes.toDoubleArray());
      final LinkedHashMap<String, double[]> curveNodes = new LinkedHashMap<>();
      final LinkedHashMap<String, Interpolator1D> interpolators = new LinkedHashMap<>();
      final CombinedInterpolatorExtrapolator interpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(interpolatorName, leftExtrapolatorName,
          rightExtrapolatorName);
      curveNodes.put(fullDomesticCurveName, nodeTimes.toDoubleArray());
      interpolators.put(fullDomesticCurveName, interpolator);
      final FXMatrix fxMatrix = new FXMatrix();
      fxMatrix.addCurrency(foreignCurrency, domesticCurrency, invertFXQuotes ? spotFX : 1 / spotFX);
      final MultipleYieldCurveFinderDataBundle data = new MultipleYieldCurveFinderDataBundle(derivatives, marketValues.toDoubleArray(), knownCurve, curveNodes,
          interpolators, useFiniteDifference, fxMatrix);
      final NewtonVectorRootFinder rootFinder = new BroydenVectorRootFinder(absoluteTolerance, relativeTolerance, iterations, decomposition);
      final Function1D<DoubleMatrix1D, DoubleMatrix1D> curveCalculator = new MultipleYieldCurveFinderFunction(data, PAR_RATE_CALCULATOR);
      final Function1D<DoubleMatrix1D, DoubleMatrix2D> jacobianCalculator = new MultipleYieldCurveFinderJacobian(data, PAR_RATE_SENSITIVITY_CALCULATOR);
      final double[] fittedYields = rootFinder.getRoot(curveCalculator, jacobianCalculator, new DoubleMatrix1D(initialRatesGuess.toDoubleArray())).getData();
      final YieldCurve curve = YieldCurve.from(InterpolatedDoublesCurve.from(nodeTimes.toDoubleArray(), fittedYields, interpolator));

      domesticCurves.put(valuationDate, curve);
    }
    final Set<ComputedValue> result = new HashSet<>();
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.doubles.DoubleArrayList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.