/**
 * Copyright (C) 2009 - 2010 by OpenGamma Inc.
 *
 * Please see distribution for license.
 */
package com.opengamma.financial.analytics.model.riskfactor.option;

import org.apache.commons.lang.NotImplementedException;

import com.opengamma.engine.ComputationTargetType;
import com.opengamma.engine.security.Security;
import com.opengamma.engine.value.ValueRequirement;
import com.opengamma.engine.value.ValueRequirementNames;
import com.opengamma.financial.pnl.Underlying;
import com.opengamma.financial.security.option.OptionSecurity;

public class UnderlyingToValueRequirementMapper {

  public static ValueRequirement getValueRequirement(final Underlying underlying, final Security security) {
    if (security instanceof OptionSecurity) {
      final OptionSecurity option = (OptionSecurity) security;
      switch (underlying) {
        case SPOT_PRICE:
          return new ValueRequirement(ValueRequirementNames.MARKET_DATA_HEADER, ComputationTargetType.SECURITY,
              option.getUnderlyingIdentityKey());
        case SPOT_VOLATILITY:
          throw new NotImplementedException("Don't know how to get spot volatility for " + option.getIdentityKey());
        case IMPLIED_VOLATILITY:
          throw new NotImplementedException("Don't know how to get implied volatility for " + option.getIdentityKey());
        case INTEREST_RATE:
          return new ValueRequirement(ValueRequirementNames.DISCOUNT_CURVE, ComputationTargetType.PRIMITIVE, option
              .getIdentityKey());
        case COST_OF_CARRY:
          throw new NotImplementedException("Don't know how to get cost of carry for " + option.getIdentityKey());
        default:
          throw new NotImplementedException("Don't know how to get ValueRequirement for " + underlying);
      }
    }
    throw new NotImplementedException("Can only get ValueRequirements for options");
  }
}

@@ -967,30 +967,16 @@
 ECURITY,
-%0A             
  option.
@@ -988,26 +988,23 @@
 derlying
-IdentityKe
+Securit
 y());%0A  
@@ -1128,35 +1128,40 @@
 + option.get
+Unique
 Identi
-tyKey
+fier
 ());%0A       
@@ -1286,35 +1286,40 @@
 + option.get
+Unique
 Identi
-tyKey
+fier
 ());%0A       
@@ -1458,38 +1458,28 @@
 tion
-%0A              .get
+.getUnique
 Identi
-tyKey
+fier
 ());
@@ -1610,19 +1610,24 @@
 .get
+Unique
 Identi
-tyKey
+fier
 ());

Refactor security master