class PortofolioService {

	protected AssetInfo getAsset(AssetEntity ae) {

		SymbolEntity currency = ae.getCurrency();

		AssetInfo asset = new AssetInfo(ae.getSymbol(), currency, ae.getQuantity().doubleValue());

		Rate q = rateService.getLatest(ae.getSymbol().getCode(), currency.getCode());

		if (!equalsByComparingTo(ae.getQuantity(), ZERO)) {
			BigDecimal currentValue = q.getValue().multiply(ae.getQuantity());
			double percentChange = percentChange(ae.getCurrencyAmount(), currentValue);

			asset.setValue(ae.getCurrencyAmount().doubleValue());
			asset.setCurrentValue(currentValue.doubleValue());
			asset.setValueChange(currentValue.subtract(ae.getCurrencyAmount()).doubleValue());
			asset.setPercentChange(percentChange);
		}
		asset.setCurrentRate(q.getValue().doubleValue());

		return asset;
	}

}