//-------------------------------------------------------------------------
@Override
public ManageableSecurity[] extractSecurities() {
SwaptionTrade trade = getTrade();
SwapTrade swapTrade = trade.getUnderlyingSwapTrade();
ManageableSecurity underlying = swapTrade.getSecurityExtractor().extractSecurities()[0];
ExternalId underlyingId = underlying.getExternalIdBundle().getExternalId(ExternalScheme.of("XML_LOADER"));
List<FixedLeg> fixedLegs = Lists.newArrayList(swapTrade.getFixedLegs());
//note - these fields are resolved on a best effort basis
//since they aren't actually used by the analytics.
//see PLAT-1924
Currency currency = null;
boolean isPayer = false;
if (!fixedLegs.isEmpty()) {
currency = fixedLegs.get(0).getCurrency();
isPayer = fixedLegs.get(0).getDirection() == Direction.PAY;
}
Expiry expiry = new Expiry(convertLocalDate(trade.getExpirationDate()));
ManageableSecurity security = new SwaptionSecurity(
isPayer, underlyingId, trade.getBuySell() == BuySell.BUY,
expiry, trade.getSettlementType() == SettlementType.CASH_SETTLED,
currency,
null, trade.getExerciseType().convert(),
convertLocalDate(trade.getCashSettlementPaymentDate()));