Examples of QuoteDataBeanImpl


Examples of org.apache.aries.samples.ariestrader.beans.QuoteDataBeanImpl

            stmt.executeUpdate();
            stmt.close();
            commit(conn);

            quoteData = new QuoteDataBeanImpl(symbol, companyName, volume, price, price, price, price, change);
            if (Log.doTrace())
                Log.traceExit("TradeJdbc:createQuote");
        } catch (Exception e) {
            Log.error("TradeJdbc:createQuote -- error creating quote", e);
        } finally {
View Full Code Here

Examples of org.apache.aries.samples.ariestrader.beans.QuoteDataBeanImpl

        if ((symbol == null) || (symbol.length() == 0) || (symbol.length() > 10)) {
            if (Log.doTrace()) {
                Log.trace("TradeJdbc:getQuote   ---  primitive workload");
            }
            return new QuoteDataBeanImpl("Invalid symbol", "", 0.0, FinancialUtils.ZERO, FinancialUtils.ZERO, FinancialUtils.ZERO, FinancialUtils.ZERO, 0.0);
        }

        try {
            if (Log.doTrace())
                Log.trace("TradeJdbc:getQuote - inSession(" + this.inSession + ")", symbol);
View Full Code Here

Examples of org.apache.aries.samples.ariestrader.beans.QuoteDataBeanImpl

     */
    public QuoteDataBean updateQuotePriceVolumeInt(String symbol, BigDecimal changeFactor, double sharesTraded,
        boolean publishQuotePriceChange) throws Exception {

        if (TradeConfig.getUpdateQuotePrices() == false)
            return new QuoteDataBeanImpl();

        QuoteDataBean quoteData = null;
        Connection conn = null;

        try {
View Full Code Here

Examples of org.apache.aries.samples.ariestrader.beans.QuoteDataBeanImpl

    private QuoteDataBean getQuoteDataFromResultSet(ResultSet rs) throws Exception {
        QuoteDataBean quoteData = null;

        quoteData =
            new QuoteDataBeanImpl(rs.getString("symbol"), rs.getString("companyName"), rs.getDouble("volume"), rs
                .getBigDecimal("price"), rs.getBigDecimal("open1"), rs.getBigDecimal("low"), rs.getBigDecimal("high"),
                rs.getDouble("change1"));
        return quoteData;
    }
View Full Code Here

Examples of org.apache.aries.samples.ariestrader.entities.QuoteDataBeanImpl

                Log.trace("TradeJpaCm:buy", userID, symbol, quantity, orderProcessingMode);

            AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class, userID);
            AccountDataBean account = profile.getAccount();

            QuoteDataBeanImpl quote = entityManager.find(QuoteDataBeanImpl.class, symbol);

            HoldingDataBeanImpl holding = null; // The holding will be created by this buy order

            order = createOrder( account, (QuoteDataBean) quote, (HoldingDataBean) holding, "buy", quantity);

            // 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));
View Full Code Here

Examples of org.apache.aries.samples.ariestrader.entities.QuoteDataBeanImpl

    }

    public QuoteDataBean createQuote(String symbol, String companyName, BigDecimal price) throws Exception {

        try {
            QuoteDataBeanImpl quote = new QuoteDataBeanImpl(symbol, companyName, 0, price, price, price, price, 0);
            entityManager.persist(quote);

            if (Log.doTrace())
                Log.trace("TradeJpaCm:createQuote-->" + quote);
View Full Code Here

Examples of org.apache.aries.samples.ariestrader.entities.QuoteDataBeanImpl

    public QuoteDataBean getQuote(String symbol) {
        if (Log.doTrace())
            Log.trace("TradeJpaCm:getQuote", symbol);

        QuoteDataBeanImpl qdb = entityManager.find(QuoteDataBeanImpl.class, symbol);

        return qdb;
    }
View Full Code Here

Examples of org.apache.aries.samples.ariestrader.entities.QuoteDataBeanImpl

        return query.getResultList();
    }

    public QuoteDataBean updateQuotePriceVolume(String symbol, BigDecimal changeFactor, double sharesTraded) throws Exception {
        if (!TradeConfig.getUpdateQuotePrices()) {
            return new QuoteDataBeanImpl();
        }

        if (Log.doTrace())
            Log.trace("TradeJpaCm:updateQuote", symbol, changeFactor);

        /*
         * Add logic to determine JPA layer, because JBoss5' Hibernate 3.3.1GA
         * DB2Dialect and MySQL5Dialect do not work with annotated query
         * "quoteejb.quoteForUpdate" defined in QuoteDataBeanImpl
         */
        QuoteDataBeanImpl quote = null;
        if (TradeConfig.jpaLayer == TradeConfig.HIBERNATE) {
            quote = entityManager.find(QuoteDataBeanImpl.class, symbol);
        } else if (TradeConfig.jpaLayer == TradeConfig.OPENJPA) {
 
            Query q = entityManager.createNamedQuery("quoteejb.quoteForUpdate");
            q.setParameter(1, symbol);
 
            quote = (QuoteDataBeanImpl) q.getSingleResult();
        }

        BigDecimal oldPrice = quote.getPrice();

        if (quote.getPrice().equals(TradeConfig.PENNY_STOCK_PRICE)) {
            changeFactor = TradeConfig.PENNY_STOCK_RECOVERY_MIRACLE_MULTIPLIER;
        }

        BigDecimal newPrice = changeFactor.multiply(oldPrice).setScale(2, BigDecimal.ROUND_HALF_UP);

        quote.setPrice(newPrice);
        quote.setVolume(quote.getVolume() + sharesTraded);
        quote.setChange((newPrice.subtract(quote.getOpen()).doubleValue()));
        if (newPrice.compareTo(quote.getHigh()) == 1) quote.setHigh(newPrice);
        else if (newPrice.compareTo(quote.getLow()) == -1) quote.setLow(newPrice);

        entityManager.merge(quote);

        this.publishQuotePriceChange(quote, oldPrice, changeFactor, sharesTraded);

View Full Code Here

Examples of org.apache.aries.samples.ariestrader.entities.QuoteDataBeanImpl

            entityManager.getTransaction().begin();

            AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class, userID);
            AccountDataBean account = profile.getAccount();

            QuoteDataBeanImpl quote = entityManager.find(QuoteDataBeanImpl.class, symbol);

            HoldingDataBeanImpl holding = null; // The holding will be created by this buy order

            order = createOrder( account, (QuoteDataBean) quote, (HoldingDataBean) holding, "buy", quantity, entityManager);

            // 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));
View Full Code Here

Examples of org.apache.aries.samples.ariestrader.entities.QuoteDataBeanImpl

    public QuoteDataBean createQuote(String symbol, String companyName, BigDecimal price) {

        EntityManager entityManager = emf.createEntityManager();
        try {
            QuoteDataBeanImpl quote = new QuoteDataBeanImpl(symbol, companyName, 0, price, price, price, price, 0);
            /*
             * managed transaction
             */
            try {
                entityManager.getTransaction().begin();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.