ManageablePosition manageablePosition = new ManageablePosition(
positionQuantity != null ? positionQuantity : tradeQuantity, security.getExternalIdBundle());
IdWrapper externalSystemId = position.getExternalSystemId();
if (externalSystemId != null) {
manageablePosition.setProviderId(externalSystemId.toExternalId());
}
List<Trade> trades = position.getTrades();
for (Trade trade : nullCheckIterable(trades)) {
manageablePosition.addTrade(convertTrade(trade, security));