Package com.opengamma.analytics.math.curve

Examples of com.opengamma.analytics.math.curve.DoublesCurve


    return UserExpressionParser.resolve(ComputationTargetType.SECURITY, id);
  }

  public static Object pointShiftCurve(final Object curve, final double x, final double shift) {
    if (curve instanceof YieldCurve) {
      final DoublesCurve shifted = CurveShiftFunctionFactory.getShiftedCurve(((YieldCurve) curve).getCurve(), x, shift);
      return YieldCurve.from(shifted);
    } else {
      throw new UnsupportedOperationException("Invalid curve - " + curve);
    }
  }
View Full Code Here


    }
  }

  public static Object parallelShiftCurve(final Object curve, final double shift) {
    if (curve instanceof YieldCurve) {
      final DoublesCurve shifted = CurveShiftFunctionFactory.getShiftedCurve(((YieldCurve) curve).getCurve(), shift);
      return YieldCurve.from(shifted);
    } else {
      throw new UnsupportedOperationException("Invalid curve - " + curve);
    }
  }
View Full Code Here

  //CSOFF
  public static double y = 0.02;
  //CSON

  public static void constantYieldCurveDemo(PrintStream out) {
    DoublesCurve curve = new ConstantDoublesCurve(y);
    YieldCurve yieldCurve = YieldCurve.from(curve);

    out.println(yieldCurve.getInterestRate(1.0));
    out.println(yieldCurve.getInterestRate(2.0));
    out.println(yieldCurve.getInterestRate(10.0));
View Full Code Here

    out.println(yieldCurve.getDiscountFactor(10.0));
  }

  // @export yieldCurveBundleDemo
  public static void yieldCurveBundleDemo(PrintStream out) {
    DoublesCurve curve = new ConstantDoublesCurve(y);
    YieldCurve yieldCurve = YieldCurve.from(curve);

    YieldCurveBundle bundle = new YieldCurveBundle();
    bundle.setCurve("Constant 2% Yield Curve", yieldCurve);
View Full Code Here

    return getCurve().getYValue(t);
  }

  @Override
  public double getForwardRate(final double t) {
    final DoublesCurve curve = getCurve();
    return curve.getYValue(t) + t * curve.getDyDx(t);
  }
View Full Code Here

        }
      }
      return result;
    }
    ArgumentChecker.isTrue(curveObject instanceof DoublesCurve, "Curve not a DoublesCurve, can not computed sensitivity");
    final DoublesCurve curve = (DoublesCurve) curveObject;
    final int nbParameters = curve.size();
    final double[] result = new double[nbParameters];
    if (pointSensitivity != null && pointSensitivity.size() > 0) {
      for (final ForwardSensitivity timeAndS : pointSensitivity) {
        final Double[] sensiPtStart = curve.getYValueParameterSensitivity(timeAndS.getStartTime());
        // Implementation note: the forward rate are indexed by the start date.
        for (int loopparam = 0; loopparam < nbParameters; loopparam++) {
          result[loopparam] += timeAndS.getValue() * sensiPtStart[loopparam];
        }
      }
View Full Code Here

      }
    }
    // Forward Ibor
    final Set<IborIndex> indexForward = market.getIndexesIbor();
    for (final IborIndex index : indexForward) {
      final DoublesCurve curve = market.getCurve(index);
      ArgumentChecker.isTrue(curve instanceof InterpolatedDoublesCurve, "Forward curve should be based on InterpolatedDoublesCurve");
      final InterpolatedDoublesCurve curveInt = (InterpolatedDoublesCurve) curve;
      final int nbNodePoint = curveInt.getXDataAsPrimitive().length;
      final double[][] sensitivity = new double[nbCcy][nbNodePoint];
      for (int loopnode = 0; loopnode < nbNodePoint; loopnode++) {
        final double[] yieldBumped = curveInt.getYDataAsPrimitive().clone();
        yieldBumped[loopnode] += _shift;
        final DoublesCurve fwdBumped = new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumped, curveInt.getInterpolator(), true);
        final MulticurveProviderForward marketFwdBumped = market.withForward(index, fwdBumped);
        final MultipleCurrencyAmount pvBumped = instrument.accept(_valueCalculator, marketFwdBumped);
        final MultipleCurrencyAmount pvDiff = pvBumped.plus(pvInitMinus);
        for (int loopccypv = 0; loopccypv < nbCcy; loopccypv++) {
          sensitivity[loopccypv][loopnode] = pvDiff.getAmount(ccyList.get(loopccypv)) / _shift;
View Full Code Here

    private static final String OFFSET_FIELD_NAME = "offset";
    private static final String DATES_FIELD_NAME = "dates";

    @Override
    public ISDADateCurve buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
      final DoublesCurve curve = (DoublesCurve) deserializer.fieldValueToObject(message.getByName(CURVE_FIELD_NAME));
      final String name;
      if (message.hasField(NAME_FIELD_NAME)) {
        name = message.getString(NAME_FIELD_NAME);
      } else {
        name = curve.getName();
      }
      final double offset = message.getDouble(OFFSET_FIELD_NAME);
      final List<ZonedDateTime> dates = (List<ZonedDateTime>) deserializer.fieldValueToObject(message.getByName(DATES_FIELD_NAME));
      return new ISDADateCurve(name, dates.toArray(new ZonedDateTime[dates.size()]), ArrayUtils.toPrimitive(curve.getXData()), ArrayUtils.toPrimitive(curve.getYData()), offset);
    }
View Full Code Here

      final Map<IborIndex, DoublesCurve> forwardIborCurves = new LinkedHashMap<>();
      final List<FudgeField> indexIborFields = message.getAllByName(INDEX_IBOR_FIELD);
      final List<FudgeField> forwardIborCurveFields = message.getAllByName(FORWARD_IBOR_CURVE_FIELD);
      for (int i = 0; i < currencyFields.size(); i++) {
        final IborIndex index = deserializer.fudgeMsgToObject(IborIndex.class, (FudgeMsg) indexIborFields.get(i).getValue());
        final DoublesCurve curve = deserializer.fudgeMsgToObject(DoublesCurve.class, (FudgeMsg) forwardIborCurveFields.get(i).getValue());
        forwardIborCurves.put(index, curve);
      }
      final Map<IndexON, YieldAndDiscountCurve> forwardONCurves = new LinkedHashMap<>();
      final List<FudgeField> indexONFields = message.getAllByName(INDEX_ON_FIELD);
      final List<FudgeField> forwardONCurveFields = message.getAllByName(FORWARD_OVERNIGHT_CURVE_FIELD);
View Full Code Here

  private static final String SHIFTED_TIME_POINTS_FIELD_NAME = "shifted time points";

  @Override
  public ISDACurve buildObject(FudgeDeserializer deserializer, FudgeMsg message) {
   
    final DoublesCurve curve = (DoublesCurve) deserializer.fieldValueToObject(message.getByName(CURVE_FIELD_NAME));
   
    final String name;
    if (message.hasField(NAME_FIELD_NAME)) {
      name = message.getString(NAME_FIELD_NAME);
    } else {
      name = curve.getName();
    }
   
    final double offset = deserializer.fieldValueToObject(double.class, message.getByName(OFFSET_FIELD_NAME)).doubleValue();
    final double zeroDiscountFactor = deserializer.fieldValueToObject(double.class, message.getByName(ZERO_DISCOUNT_FACTOR_FIELD_NAME)).doubleValue();
    final double[] shiftedTimePoints = deserializer.fieldValueToObject(double[].class, message.getByName(SHIFTED_TIME_POINTS_FIELD_NAME));
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.math.curve.DoublesCurve

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.