private HoldingDataBean createHolding(AccountDataBean account, QuoteDataBean quote, double quantity, BigDecimal purchasePrice) throws Exception { HoldingDataBean newHolding = new HoldingDataBean(quantity, purchasePrice, new Timestamp(System.currentTimeMillis()), account, quote); entityManager.persist(newHolding); return newHolding; }
public String toString() { return "\n\tHolding Data for holding: " + getHoldingID() + "\n\t\t quantity:" + getQuantity() + "\n\t\t purchasePrice:" + getPurchasePrice() + "\n\t\t purchaseDate:" + getPurchaseDate() + "\n\t\t quoteID:" + getQuoteID() ; }
public HoldingDataBean(double quantity, BigDecimal purchasePrice, Date purchaseDate, AccountDataBean account, QuoteDataBean quote) { setQuantity(quantity); setPurchasePrice(purchasePrice); setPurchaseDate(purchaseDate); setAccount(account); setQuote(quote); }
public HoldingDataBean(Integer holdingID, double quantity, BigDecimal purchasePrice, Date purchaseDate, String quoteID) { setHoldingID(holdingID); setQuantity(quantity); setPurchasePrice(purchasePrice); setPurchaseDate(purchaseDate); setQuoteID(quoteID); }
QuoteDataBean quote = holding.getQuote(); double quantity = holding.getQuantity(); holding.setPurchaseDate(new java.sql.Timestamp(0));
QuoteDataBean quoteData = null; if (holdingData != null) quoteData = getQuoteData(conn, holdingData.getQuoteID()); double quantity = holdingData.getQuantity(); updateHoldingStatus(conn, holdingData.getHoldingID(), holdingData.getQuoteID());
QuoteDataBean quote = holding.getQuote(); double quantity = holding.getQuantity(); holding.setPurchaseDate(new java.sql.Timestamp(0)); this.soldholdingID = holding.getHoldingID(); completeOrder(order.getOrderID(), false);
public static BigDecimal computeHoldingsTotal(Collection holdingDataBeans) { BigDecimal holdingsTotal = new BigDecimal(0.0).setScale(SCALE); if (holdingDataBeans == null) return holdingsTotal; Iterator it = holdingDataBeans.iterator(); while (it.hasNext()) { HoldingDataBean holdingData = (HoldingDataBean) it.next(); BigDecimal total = holdingData.getPurchasePrice().multiply(new BigDecimal(holdingData.getQuantity())); holdingsTotal = holdingsTotal.add(total); } return holdingsTotal.setScale(SCALE); }
private OrderDataBean createOrder(Connection conn, AccountDataBean accountData, QuoteDataBean quoteData, HoldingDataBean holdingData, String orderType, double quantity) throws Exception { OrderDataBean orderData = null; Timestamp currentDate = new Timestamp(System.currentTimeMillis()); PreparedStatement stmt = getStatement(conn, createOrderSQL); Integer orderID = KeySequenceDirect.getNextID(conn, "order", inSession, getInGlobalTxn()); stmt.setInt(1, orderID.intValue()); stmt.setString(2, orderType); stmt.setString(3, "open"); stmt.setTimestamp(4, currentDate); stmt.setDouble(5, quantity); stmt.setBigDecimal(6, quoteData.getPrice().setScale(FinancialUtils.SCALE, FinancialUtils.ROUND)); stmt.setBigDecimal(7, TradeConfig.getOrderFee(orderType)); stmt.setInt(8, accountData.getAccountID().intValue()); if (holdingData == null) stmt.setNull(9, java.sql.Types.INTEGER); else stmt.setInt(9, holdingData.getHoldingID().intValue()); stmt.setString(10, quoteData.getSymbol()); int rowCount = stmt.executeUpdate(); stmt.close(); return getOrderData(conn, orderID.intValue()); }
public Collection<HoldingDataBean> getHoldings(String userID) { if (Log.doTrace()) Log.trace("TradeSLSBBean:getHoldings", userID); Query query = entityManager.createNamedQuery("holdingejb.holdingsByUserID"); query.setParameter("userID", userID); Collection<HoldingDataBean> holdings = query.getResultList(); /* * Inflate the lazy data memebers */ Iterator itr = holdings.iterator(); while (itr.hasNext()) { ((HoldingDataBean) itr.next()).getQuote(); } return holdings; }
QuoteDataBean quote = holding.getQuote(); double quantity = holding.getQuantity(); order = createOrder(account, quote, holding, "sell", quantity); holding.setPurchaseDate(new java.sql.Timestamp(0));
QuoteDataBean quoteData = null; if (holdingData != null) quoteData = getQuoteData(conn, holdingData.getQuoteID()); double quantity = holdingData.getQuantity(); updateHoldingStatus(conn, holdingData.getHoldingID(), holdingData.getQuoteID());
public HoldingDataBean(Integer holdingID, double quantity, BigDecimal purchasePrice, Date purchaseDate, String quoteID) { setHoldingID(holdingID); setQuantity(quantity); setPurchasePrice(purchasePrice); setPurchaseDate(purchaseDate); setQuoteID(quoteID); }
public static BigDecimal computeHoldingsTotal(Collection holdingDataBeans) { BigDecimal holdingsTotal = new BigDecimal(0.0).setScale(SCALE); if (holdingDataBeans == null) return holdingsTotal; Iterator it = holdingDataBeans.iterator(); while (it.hasNext()) { HoldingDataBean holdingData = (HoldingDataBean) it.next(); BigDecimal total = holdingData.getPurchasePrice().multiply(new BigDecimal(holdingData.getQuantity())); holdingsTotal = holdingsTotal.add(total); } return holdingsTotal.setScale(SCALE); }
private OrderDataBean createOrder(Connection conn, AccountDataBean accountData, QuoteDataBean quoteData, HoldingDataBean holdingData, String orderType, double quantity) throws Exception { OrderDataBean orderData = null; Timestamp currentDate = new Timestamp(System.currentTimeMillis()); PreparedStatement stmt = getStatement(conn, createOrderSQL); Integer orderID = KeySequenceDirect.getNextID(conn, "order", inSession, getInGlobalTxn()); stmt.setInt(1, orderID.intValue()); stmt.setString(2, orderType); stmt.setString(3, "open"); stmt.setTimestamp(4, currentDate); stmt.setDouble(5, quantity); stmt.setBigDecimal(6, quoteData.getPrice().setScale(FinancialUtils.SCALE, FinancialUtils.ROUND)); stmt.setBigDecimal(7, TradeConfig.getOrderFee(orderType)); stmt.setInt(8, accountData.getAccountID().intValue()); if (holdingData == null) stmt.setNull(9, java.sql.Types.INTEGER); else stmt.setInt(9, holdingData.getHoldingID().intValue()); stmt.setString(10, quoteData.getSymbol()); int rowCount = stmt.executeUpdate(); stmt.close(); return getOrderData(conn, orderID.intValue()); }
public Collection<HoldingDataBean> getHoldings(String userID) { if (Log.doTrace()) Log.trace("TradeSLSBBean:getHoldings", userID); Query query = entityManager.createNamedQuery("holdingejb.holdingsByUserID"); query.setParameter("userID", userID); Collection<HoldingDataBean> holdings = query.getResultList(); /* * Inflate the lazy data memebers */ Iterator itr = holdings.iterator(); while (itr.hasNext()) { ((HoldingDataBean) itr.next()).getQuote(); } return holdings; }
public String toHTML() { return "<BR>Holding Data for holding: " + getHoldingID() + "</B>" + "<LI> quantity:" + getQuantity() + "</LI>" + "<LI> purchasePrice:" + getPurchasePrice() + "</LI>" + "<LI> purchaseDate:" + getPurchaseDate() + "</LI>" + "<LI> quoteID:" + getQuoteID() + "</LI>" ; }
QuoteDataBean quote = holding.getQuote(); double quantity = holding.getQuantity(); order = createOrder(account, quote, holding, "sell", quantity); holding.setPurchaseDate(new java.sql.Timestamp(0));
QuoteDataBean quoteData = null; if (holdingData != null) quoteData = getQuoteData(conn, holdingData.getQuoteID()); double quantity = holdingData.getQuantity(); updateHoldingStatus(conn, holdingData.getHoldingID(), holdingData.getQuoteID());
private HoldingDataBean createHolding(AccountDataBean account, QuoteDataBean quote, double quantity, BigDecimal purchasePrice, EntityManager entityManager) throws Exception { HoldingDataBean newHolding = new HoldingDataBean(quantity, purchasePrice, new Timestamp(System.currentTimeMillis()), account, quote); entityManager.persist(newHolding); return newHolding; }