Package com.opengamma.analytics.financial.sensitivity

Examples of com.opengamma.analytics.financial.sensitivity.ValueGreek


    final Map<UnderlyingType, Double> underlyingData = data.getUnderlyingData();
    final OptionTradeData tradeData = data.getOptionTradeData();
    for (final Pair<Greek, Double> entry : greeks) {
      final Greek key = entry.getFirst();
      final Double value = entry.getSecond();
      riskFactors.put(new ValueGreek(key), getValueGreek(key, value, underlyingData, tradeData));
    }
    return riskFactors;
  }
View Full Code Here


    }
    return AVAILABLE_VALUE_GREEKS.get(valueName);
  }

  public static String getGreekRequirementNameForValueGreekName(final String valueName) {
    final ValueGreek valueGreek = AVAILABLE_VALUE_GREEKS.get(valueName);
    if (valueGreek == null) {
      throw new IllegalArgumentException("Could not get value greek for ValueRequirementName " + valueName);
    }
    return AvailableGreeks.getValueRequirementNameForGreek(valueGreek.getUnderlyingGreek());
  }
View Full Code Here

    new SensitivityAndReturnDataBundle(S1, VALUE_GAMMA, m);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testWrongUnderlyings1() {
    final Sensitivity<ValueGreek> s = new ValueGreekSensitivity(new ValueGreek(Greek.VANNA), "ValueVanna");
    new SensitivityAndReturnDataBundle(s, VALUE_DELTA, M1);
  }
View Full Code Here

    new SensitivityAndReturnDataBundle(s, VALUE_DELTA, M1);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testWrongUnderlyings2() {
    final Sensitivity<ValueGreek> s = new ValueGreekSensitivity(new ValueGreek(Greek.VEGA), "ValueVega");
    new SensitivityAndReturnDataBundle(s, VALUE_DELTA, M1);
  }
View Full Code Here

      }
    }
    final GreekDataBundle dataBundle = new GreekDataBundle(greekResultCollection, underlyingData, tradeData);
    final Map<ValueGreek, Double> sensitivities = _converter.evaluate(dataBundle);
    final Set<ComputedValue> results = new HashSet<ComputedValue>();
    ValueGreek valueGreek;
    Double valueGreekResult;
    ValueSpecification resultSpecification;
    ComputedValue resultValue;
    final ComputationTargetSpecification targetSpec = target.toSpecification();
    for (final ValueRequirement dV : desiredValues) {
View Full Code Here

    final Set<String> samplingFunctionName = desiredValue.getConstraints().getValues(ValuePropertyNames.SAMPLING_FUNCTION);
    final Set<String> returnCalculatorName = desiredValue.getConstraints().getValues(ValuePropertyNames.RETURN_CALCULATOR);
    final HistoricalTimeSeries timeSeries = (HistoricalTimeSeries) inputs.getValue(ValueRequirementNames.HISTORICAL_TIME_SERIES);
    final SensitivityAndReturnDataBundle[] dataBundleArray = new SensitivityAndReturnDataBundle[1];
    final Double value = (Double) inputs.getValue(REQUIREMENT_NAME);
    final ValueGreek valueGreek = AvailableValueGreeks.getValueGreekForValueRequirementName(REQUIREMENT_NAME);
    final Sensitivity<?> sensitivity = new ValueGreekSensitivity(valueGreek, position.getUniqueId().toString());
    final Map<UnderlyingType, DoubleTimeSeries<?>> tsReturns = new HashMap<UnderlyingType, DoubleTimeSeries<?>>();
    final Period samplingPeriod = getSamplingPeriod(samplingPeriodName);
    final LocalDate startDate = now.minus(samplingPeriod);
    final Schedule scheduleCalculator = getScheduleCalculator(scheduleCalculatorName);
    final TimeSeriesSamplingFunction samplingFunction = getSamplingFunction(samplingFunctionName);
    final TimeSeriesReturnCalculator returnCalculator = getTimeSeriesReturnCalculator(returnCalculatorName);
    final LocalDate[] schedule = HOLIDAY_REMOVER.getStrippedSchedule(scheduleCalculator.getSchedule(startDate, now, true, false), WEEKEND_CALENDAR); //REVIEW emcleod should "fromEnd" be hard-coded?
    final LocalDateDoubleTimeSeries sampledTS = samplingFunction.getSampledTimeSeries(timeSeries.getTimeSeries(), schedule);
    for (final UnderlyingType underlyingType : valueGreek.getUnderlyingGreek().getUnderlying().getUnderlyings()) {
      if (underlyingType != UnderlyingType.SPOT_PRICE) {
        throw new OpenGammaRuntimeException("Have hard-coded to only use delta; should not have anything with " + underlyingType + " as the underlying type");
      }
      tsReturns.put(underlyingType, returnCalculator.evaluate(sampledTS));
    }
View Full Code Here

    CALC.evaluate(new SensitivityAndReturnDataBundle[] {null});
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testThirdOrderSensitivity() {
    final SensitivityAndReturnDataBundle data = new SensitivityAndReturnDataBundle(new ValueGreekSensitivity(new ValueGreek(Greek.SPEED), "A"), 10,
        Collections.<UnderlyingType, DoubleTimeSeries<?>> singletonMap(UnderlyingType.SPOT_PRICE, ImmutableInstantDoubleTimeSeries.of(new long[] {1},
            new double[] {1})));
    CALC.evaluate(data);
  }
View Full Code Here

    assertEquals(DELTA * N, positionGreeks.get(new PositionGreek(Greek.DELTA)), EPS);
    assertEquals(GAMMA * N, positionGreeks.get(new PositionGreek(Greek.GAMMA)), EPS);
    assertEquals(VANNA * N, positionGreeks.get(new PositionGreek(Greek.VANNA)), EPS);

    final Map<ValueGreek, Double> valueGreeks = G_TO_VG_CONVERTER.evaluate(GREEKS_DATA);
    assertEquals(DELTA * N * PV * SPOT_PRICE, valueGreeks.get(new ValueGreek(Greek.DELTA)), EPS);
    assertEquals(GAMMA * N * PV * SPOT_PRICE * SPOT_PRICE, valueGreeks.get(new ValueGreek(Greek.GAMMA)), EPS);
    assertEquals(VANNA * N * PV * SPOT_PRICE * IMPLIED_VOLATILITY, valueGreeks.get(new ValueGreek(Greek.VANNA)), EPS);

  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.sensitivity.ValueGreek

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.