protected ExternalIdBundle mapSecurityKey(final ExternalIdBundle securityKey) {
return null;
}
protected ManageablePosition createManageablePosition(final Position position) {
final ManageablePosition manageablePosition = new ManageablePosition();
manageablePosition.setQuantity(position.getQuantity());
manageablePosition.setSecurityLink(new ManageableSecurityLink(position.getSecurityLink()));
manageablePosition.setAttributes(position.getAttributes());
final Collection<Trade> trades = position.getTrades();
final List<ManageableTrade> manageableTrades = new ArrayList<ManageableTrade>(trades.size());
for (Trade trade : trades) {
final ManageableTrade mtrade = new ManageableTrade(trade);
final ExternalIdBundle replacementKey = mapSecurityKey(mtrade.getSecurityLink().getExternalId());
if (replacementKey != null) {
mtrade.getSecurityLink().setExternalId(replacementKey);
}
mtrade.setAttributes(trade.getAttributes());
manageableTrades.add(mtrade);
}
manageablePosition.setTrades(manageableTrades);
final String providerIdFieldName = manageablePosition.providerId().name();
if (position.getAttributes().containsKey(providerIdFieldName)) {
// this is here to preserve the provider id when round-tripping to and from the resolved vs managed positions.
manageablePosition.setProviderId(ExternalId.parse(position.getAttributes().get(providerIdFieldName)));
} else {
manageablePosition.setProviderId(position.getUniqueId().toExternalId());
}
return manageablePosition;
}