<%@ page import="java.util.Collection, java.util.Iterator, java.util.HashMap, java.math.BigDecimal, org.apache.geronimo.daytrader.javaee6.core.direct.*, org.apache.geronimo.daytrader.javaee6.entities.*, org.apache.geronimo.daytrader.javaee6.utils.*" session="true" isThreadSafe="true" isErrorPage="false"%> <% Collection closedOrders = (Collection)request.getAttribute("closedOrders"); if ( (closedOrders != null) && (closedOrders.size()>0) ) { %> <% } %>
DayTrader Portfolio DayTrader

<%= new java.util.Date() %>
Alert: The following Order(s) have completed.
<% Iterator it = closedOrders.iterator(); while (it.hasNext() ) { OrderDataBean closedOrderData = (OrderDataBean)it.next(); %> <% } %>
order ID order status creation date completion date txn fee type symbol quantity
<%= closedOrderData.getOrderID()%> <%= closedOrderData.getOrderStatus()%> <%= closedOrderData.getOpenDate()%> <%= closedOrderData.getCompletionDate()%> <%= closedOrderData.getOrderFee()%> <%= closedOrderData.getOrderType()%> <%= FinancialUtils.printQuoteLink(closedOrderData.getSymbol())%> <%= closedOrderData.getQuantity()%>
Portfolio Number of Holdings: <%= holdingDataBeans.size() %>
<% // Create Hashmap for quick lookup of quote values Iterator it = quoteDataBeans.iterator(); HashMap quoteMap = new HashMap(); while ( it.hasNext() ) { QuoteDataBean quoteData = (QuoteDataBean) it.next(); quoteMap.put(quoteData.getSymbol(), quoteData); } //Step through and printout Holdings it = holdingDataBeans.iterator(); BigDecimal totalGain = new BigDecimal(0.0); BigDecimal totalBasis = new BigDecimal(0.0); BigDecimal totalValue = new BigDecimal(0.0); try { while (it.hasNext()) { HoldingDataBean holdingData = (HoldingDataBean) it.next(); QuoteDataBean quoteData = (QuoteDataBean) quoteMap.get(holdingData.getQuoteID()); BigDecimal basis = holdingData.getPurchasePrice().multiply(new BigDecimal(holdingData.getQuantity())); BigDecimal marketValue = quoteData.getPrice().multiply(new BigDecimal(holdingData.getQuantity())); totalBasis = totalBasis.add(basis); totalValue = totalValue.add(marketValue); BigDecimal gain = marketValue.subtract(basis); totalGain = totalGain.add(gain); BigDecimal gainPercent = null; if (basis.doubleValue() == 0.0) { gainPercent = new BigDecimal(0.0); Log.error("portfolio.jsp: Holding with zero basis. holdingID="+holdingData.getHoldingID() + " symbol=" + holdingData.getQuoteID() + " purchasePrice=" + holdingData.getPurchasePrice()); } else gainPercent = marketValue.divide(basis, BigDecimal.ROUND_HALF_UP).subtract(new BigDecimal(1.0)).multiply(new BigDecimal(100.0)); %> <% } } catch (Exception e) { Log.error("portfolio.jsp: error displaying user holdings", e); } %>
Portfolio
holding ID purchase date symbol quantity purchase price current price purchase basis market value gain/(loss) trade
<%= holdingData.getHoldingID() %> <%= holdingData.getPurchaseDate() %> <%= FinancialUtils.printQuoteLink(holdingData.getQuoteID()) %> <%= holdingData.getQuantity() %> <%= holdingData.getPurchasePrice() %> <%= quoteData.getPrice() %> <%= basis %> <%= marketValue %> <%= FinancialUtils.printGainHTML(gain) %> <%= "sell"%>
Total $<%= totalBasis %> $<%= totalValue %> $<%= FinancialUtils.printGainHTML(totalGain) %> <%= FinancialUtils.printGainPercentHTML(FinancialUtils.computeGainPercent(totalValue, totalBasis)) %>

Note: Click any symbol for a quote or to trade.
DayTrader Portfolio DayTrader