BigDecimal balance = account.getBalance(); total = (new BigDecimal(quantity).multiply(price)).add(orderFee); account.setBalance(balance.subtract(total));
BigDecimal balance = account.getBalance(); total = (new BigDecimal(quantity).multiply(price)).add(orderFee); account.setBalance(balance.subtract(total));
BigDecimal balance = account.getBalance(); total = (new BigDecimal(quantity).multiply(price)).subtract(orderFee);
public OrderDataBean buy(String userID, String symbol, double quantity, int orderProcessingMode) { OrderDataBean order; BigDecimal total; try { if (Log.doTrace()) Log.trace("TradeSLSBBean:buy", userID, symbol, quantity, orderProcessingMode); AccountProfileDataBean profile = entityManager.find(AccountProfileDataBean.class, userID); AccountDataBean account = profile.getAccount(); QuoteDataBean quote = entityManager.find(QuoteDataBean.class, symbol); HoldingDataBean holding = null; // The holding will be created by this buy order order = createOrder(account, quote, holding, "buy", quantity); // UPDATE - account should be credited during completeOrder BigDecimal price = quote.getPrice(); BigDecimal orderFee = order.getOrderFee(); BigDecimal balance = account.getBalance(); total = (new BigDecimal(quantity).multiply(price)).add(orderFee); account.setBalance(balance.subtract(total)); if (orderProcessingMode == TradeConfig.SYNCH) completeOrder(order.getOrderID(), false); else if (orderProcessingMode == TradeConfig.ASYNCH_2PHASE) queueOrder(order.getOrderID(), true); } catch (Exception e) { Log.error("TradeSLSBBean:buy(" + userID + "," + symbol + "," + quantity + ") --> failed", e); /* On exception - cancel the order */ // TODO figure out how to do this with JPA // if (order != null) order.cancel(); throw new EJBException(e); } return order; }
public OrderDataBean buy(String userID, String symbol, double quantity, int orderProcessingMode) { OrderDataBean order; BigDecimal total; try { if (Log.doTrace()) Log.trace("TradeSLSBBean:buy", userID, symbol, quantity, orderProcessingMode); AccountProfileDataBean profile = entityManager.find(AccountProfileDataBean.class, userID); AccountDataBean account = profile.getAccount(); QuoteDataBean quote = entityManager.find(QuoteDataBean.class, symbol); HoldingDataBean holding = null; // The holding will be created by this buy order order = createOrder(account, quote, holding, "buy", quantity); // UPDATE - account should be credited during completeOrder BigDecimal price = quote.getPrice(); BigDecimal orderFee = order.getOrderFee(); BigDecimal balance = account.getBalance(); total = (new BigDecimal(quantity).multiply(price)).add(orderFee); account.setBalance(balance.subtract(total)); if (orderProcessingMode == TradeConfig.SYNCH) completeOrder(order.getOrderID(), false); else if (orderProcessingMode == TradeConfig.ASYNCH_2PHASE) queueOrder(order.getOrderID(), true); } catch (Exception e) { Log.error("TradeSLSBBean:buy(" + userID + "," + symbol + "," + quantity + ") --> failed", e); /* On exception - cancel the order */ // TODO figure out how to do this with JPA // if (order != null) order.cancel(); throw new EJBException(e); } return order; }
BigDecimal balance = account.getBalance(); total = (new BigDecimal(quantity).multiply(price)).subtract(orderFee);
public String toHTML() { return "<BR>Account Data for account: <B>" + getAccountID() + "</B>" + "<LI> loginCount:" + getLoginCount() + "</LI>" + "<LI> logoutCount:" + getLogoutCount() + "</LI>" + "<LI> lastLogin:" + getLastLogin() + "</LI>" + "<LI> creationDate:" + getCreationDate() + "</LI>" + "<LI> balance:" + getBalance() + "</LI>" + "<LI> openBalance:" + getOpenBalance() + "</LI>" + "<LI> profileID:" + getProfileID() + "</LI>" ; }
public String toString() { return "\n\tAccount Data for account: " + getAccountID() + "\n\t\t loginCount:" + getLoginCount() + "\n\t\t logoutCount:" + getLogoutCount() + "\n\t\t lastLogin:" + getLastLogin() + "\n\t\t creationDate:" + getCreationDate() + "\n\t\t balance:" + getBalance() + "\n\t\t openBalance:" + getOpenBalance() + "\n\t\t profileID:" + getProfileID() ; }
public String toHTML() { return "<BR>Account Data for account: <B>" + getAccountID() + "</B>" + "<LI> loginCount:" + getLoginCount() + "</LI>" + "<LI> logoutCount:" + getLogoutCount() + "</LI>" + "<LI> lastLogin:" + getLastLogin() + "</LI>" + "<LI> creationDate:" + getCreationDate() + "</LI>" + "<LI> balance:" + getBalance() + "</LI>" + "<LI> openBalance:" + getOpenBalance() + "</LI>" + "<LI> profileID:" + getProfileID() + "</LI>" ; }
public String toString() { return "\n\tAccount Data for account: " + getAccountID() + "\n\t\t loginCount:" + getLoginCount() + "\n\t\t logoutCount:" + getLogoutCount() + "\n\t\t lastLogin:" + getLastLogin() + "\n\t\t creationDate:" + getCreationDate() + "\n\t\t balance:" + getBalance() + "\n\t\t openBalance:" + getOpenBalance() + "\n\t\t profileID:" + getProfileID() ; }
BigDecimal balance = account.getBalance(); total = (new BigDecimal(quantity).multiply(price)).add(orderFee); account.setBalance(balance.subtract(total));
BigDecimal balance = account.getBalance(); total = (new BigDecimal(quantity).multiply(price)).add(orderFee); account.setBalance(balance.subtract(total));
BigDecimal balance = account.getBalance(); total = (new BigDecimal(quantity).multiply(price)).subtract(orderFee); account.setBalance(balance.add(total));
BigDecimal balance = account.getBalance(); total = (new BigDecimal(quantity).multiply(price)).subtract(orderFee); account.setBalance(balance.add(total));
BigDecimal balance = account.getBalance(); total = (new BigDecimal(quantity).multiply(price)).subtract(orderFee);
BigDecimal balance = account.getBalance(); total = (new BigDecimal(quantity).multiply(price)).subtract(orderFee);
static AccountDataBean convertAccountDataBean(org.apache.geronimo.samples.daytrader.beans.AccountDataBean bean) { AccountDataBean wsBean = new AccountDataBean(); wsBean.setAccountID(bean.getAccountID()); wsBean.setLoginCount(bean.getLoginCount()); wsBean.setLogoutCount(bean.getLogoutCount()); wsBean.setLastLogin(toCalendar(bean.getLastLogin())); wsBean.setCreationDate(toCalendar(bean.getCreationDate())); wsBean.setBalance(bean.getBalance()); wsBean.setOpenBalance(bean.getOpenBalance()); wsBean.setProfileID(bean.getProfileID()); return wsBean; }
static AccountDataBean convertAccountDataBean(org.apache.geronimo.samples.daytrader.beans.AccountDataBean bean) { AccountDataBean wsBean = new AccountDataBean(); wsBean.setAccountID(bean.getAccountID()); wsBean.setLoginCount(bean.getLoginCount()); wsBean.setLogoutCount(bean.getLogoutCount()); wsBean.setLastLogin(toCalendar(bean.getLastLogin())); wsBean.setCreationDate(toCalendar(bean.getCreationDate())); wsBean.setBalance(bean.getBalance()); wsBean.setOpenBalance(bean.getOpenBalance()); wsBean.setProfileID(bean.getProfileID()); return wsBean; }