static void assertEquityIndexOptionSecurity( EquityIndexOptionSecurity expectedOption, Security sec) { assertNotNull(expectedOption); assertNotNull(sec); EquityIndexOptionSecurity actualOption = (EquityIndexOptionSecurity) 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); }
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); } }