static void assertEuropeanVanillaEquityOptionSecurity( EquityOptionSecurity expectedOption, Security sec) { // check specific bits we want to spot failures on quickly assertNotNull(sec); assertTrue(sec instanceof EquityOptionSecurity); final EquityOptionSecurity equitySec = (EquityOptionSecurity) sec; assertTrue(equitySec.getExerciseType() instanceof EuropeanExerciseType); assertEquityOptionSecurity(expectedOption, sec); }
public static ValueRequirement getValueRequirement( SecuritySource secMaster, final UnderlyingType underlying, final Security security) { if (security instanceof EquityOptionSecurity) { final EquityOptionSecurity option = (EquityOptionSecurity) security; switch (underlying) { case SPOT_PRICE: Security optionUnderlying = secMaster.getSecurity(ExternalIdBundle.of(option.getUnderlyingId())); return new ValueRequirement( MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.SECURITY, optionUnderlying.getUniqueId()); case SPOT_VOLATILITY: throw new NotImplementedException( "Don't know how to get spot volatility for " + option.getUniqueId()); case IMPLIED_VOLATILITY: throw new NotImplementedException( "Don't know how to get implied volatility for " + option.getUniqueId()); case INTEREST_RATE: return new ValueRequirement( ValueRequirementNames.YIELD_CURVE, ComputationTargetType.PRIMITIVE, option.getUniqueId()); case COST_OF_CARRY: throw new NotImplementedException( "Don't know how to get cost of carry for " + option.getUniqueId()); default: throw new NotImplementedException( "Don't know how to get ValueRequirement for " + underlying); } } throw new NotImplementedException( "Can only get ValueRequirements for options (was " + security + ")"); }
static void assertEquityOptionSecurity(EquityOptionSecurity expectedOption, Security sec) { assertNotNull(expectedOption); assertNotNull(sec); EquityOptionSecurity actualOption = (EquityOptionSecurity) sec; assertEquals(expectedOption.getExternalIdBundle(), actualOption.getExternalIdBundle()); assertEquals(expectedOption.getUniqueId(), actualOption.getUniqueId()); assertEquals(expectedOption.getSecurityType(), actualOption.getSecurityType()); assertEquals(expectedOption.getCurrency(), actualOption.getCurrency()); assertEquals(expectedOption.getOptionType(), actualOption.getOptionType()); assertTrue(expectedOption.getStrike() == actualOption.getStrike()); assertEquals(expectedOption.getExpiry(), actualOption.getExpiry()); assertEquals(expectedOption.getUnderlyingId(), actualOption.getUnderlyingId()); assertEquals(expectedOption.getName(), actualOption.getName()); // check the lot assertSecurity(expectedOption, sec); }
@Test public void apvEquityOptionByBbgTicker() throws Exception { Security sec = _securityProvider.getSecurity(EXPECTED_APVL_EQUITYOPTION_SEC.getExternalIdBundle()); assertAmericanVanillaEquityOptionSecurity(EXPECTED_APVL_EQUITYOPTION_SEC, sec); }
protected void addSecuritySpecificMetaData(ManageableSecurity security, FlexiBean out) { if (security.getSecurityType().equals(SwapSecurity.SECURITY_TYPE)) { SwapSecurity swapSecurity = (SwapSecurity) security; out.put("payLegType", swapSecurity.getPayLeg().accept(new SwapLegClassifierVisitor())); out.put( "receiveLegType", swapSecurity.getReceiveLeg().accept(new SwapLegClassifierVisitor())); } if (security.getSecurityType().equals(FutureSecurity.SECURITY_TYPE)) { FutureSecurity futureSecurity = (FutureSecurity) security; out.put("futureSecurityType", futureSecurity.accept(new FutureSecurityTypeVisitor())); out.put("basket", getBondFutureBasket(security)); Security underlyingSecurity = getUnderlyingFutureSecurity(futureSecurity); if (underlyingSecurity != null) { out.put("underlyingSecurity", underlyingSecurity); } } if (security.getSecurityType().equals(EquityOptionSecurity.SECURITY_TYPE)) { EquityOptionSecurity equityOption = (EquityOptionSecurity) security; addUnderlyingSecurity(out, equityOption.getUnderlyingId()); } if (security.getSecurityType().equals(IRFutureOptionSecurity.SECURITY_TYPE)) { IRFutureOptionSecurity irFutureOption = (IRFutureOptionSecurity) security; addUnderlyingSecurity(out, irFutureOption.getUnderlyingId()); } if (security.getSecurityType().equals(SwaptionSecurity.SECURITY_TYPE)) { SwaptionSecurity swaptionSecurity = (SwaptionSecurity) security; addUnderlyingSecurity(out, swaptionSecurity.getUnderlyingId()); } if (security.getSecurityType().equals(EquityBarrierOptionSecurity.SECURITY_TYPE)) { EquityBarrierOptionSecurity equityBarrierOptionSecurity = (EquityBarrierOptionSecurity) security; addUnderlyingSecurity(out, equityBarrierOptionSecurity.getUnderlyingId()); } if (security.getSecurityType().equals(CapFloorSecurity.SECURITY_TYPE)) { CapFloorSecurity capFloorSecurity = (CapFloorSecurity) security; addUnderlyingSecurity(out, capFloorSecurity.getUnderlyingId()); } if (security.getSecurityType().equals(CapFloorCMSSpreadSecurity.SECURITY_TYPE)) { CapFloorCMSSpreadSecurity capFloorCMSSpreadSecurity = (CapFloorCMSSpreadSecurity) security; Security shortUnderlying = getSecurity(capFloorCMSSpreadSecurity.getShortId()); Security longUnderlying = getSecurity(capFloorCMSSpreadSecurity.getLongId()); if (shortUnderlying != null) { out.put("shortSecurity", shortUnderlying); } if (longUnderlying != null) { out.put("longSecurity", longUnderlying); } } if (security.getSecurityType().equals(EquityIndexOptionSecurity.SECURITY_TYPE)) { EquityIndexOptionSecurity equityIndxOption = (EquityIndexOptionSecurity) security; addUnderlyingSecurity(out, equityIndxOption.getUnderlyingId()); } if (security.getSecurityType().equals(FRASecurity.SECURITY_TYPE)) { FRASecurity fraSecurity = (FRASecurity) security; addUnderlyingSecurity(out, fraSecurity.getUnderlyingId()); } if (security.getSecurityType().equals(SecurityEntryData.EXTERNAL_SENSITIVITIES_SECURITY_TYPE)) { RawSecurity rawSecurity = (RawSecurity) security; FudgeMsgEnvelope msg = OpenGammaFudgeContext.getInstance().deserialize(rawSecurity.getRawData()); SecurityEntryData securityEntryData = OpenGammaFudgeContext.getInstance() .fromFudgeMsg(SecurityEntryData.class, msg.getMessage()); out.put("securityEntryData", securityEntryData); out.put("securityAttributes", security.getAttributes()); RawSecurity underlyingRawSecurity = (RawSecurity) getSecurity(securityEntryData.getFactorSetId()); if (underlyingRawSecurity != null) { FudgeMsgEnvelope factorIdMsg = OpenGammaFudgeContext.getInstance().deserialize(underlyingRawSecurity.getRawData()); @SuppressWarnings("unchecked") List<FactorExposureData> factorExposureDataList = OpenGammaFudgeContext.getInstance().fromFudgeMsg(List.class, factorIdMsg.getMessage()); s_logger.error(factorExposureDataList.toString()); List<FactorExposure> factorExposuresList = convertToFactorExposure(factorExposureDataList); out.put("factorExposuresList", factorExposuresList); } else { s_logger.error("Couldn't find security"); } } if (security .getSecurityType() .equals(FactorExposureData.EXTERNAL_SENSITIVITIES_RISK_FACTORS_SECURITY_TYPE)) { RawSecurity rawSecurity = (RawSecurity) security; FudgeMsgEnvelope msg = OpenGammaFudgeContext.getInstance().deserialize(rawSecurity.getRawData()); @SuppressWarnings("unchecked") List<FactorExposureData> factorExposureDataList = OpenGammaFudgeContext.getInstance().fromFudgeMsg(List.class, msg.getMessage()); List<FactorExposure> factorExposuresList = convertToFactorExposure(factorExposureDataList); out.put("factorExposuresList", factorExposuresList); } }