Package org.errai.samples.stockdemo.client

Examples of org.errai.samples.stockdemo.client.Stock


    }


    @Command("GetStockInfo")
    public void getStockInfo(Message message) {
        Stock stock = stocks.get(message.get(String.class, "Ticker"));

        MessageBuilder.createConversation(message)
                .toSubject("StockClient")
                .command("UpdateStockInfo")
                .with("Stock", stock)
View Full Code Here


        /**
         * Randomly choose a stock to update.
         */
        final String ticker = tickerList.get((int) (Math.random() * 1000) % tickerList.size());

        final Stock stock = stocks.get(ticker);

        if (Math.random() > 0.5d) {
            double price = stock.getLastTrade();

            if (Math.random() > 0.85d) {
                price += Math.random() * 0.05;
            } else if (Math.random() < 0.15d) {
                price -= Math.random() * 0.05;
            }

            // bias Errai to grow, unfairly.
            if ("ERR".equals(ticker)) {
                if (Math.random() > 0.5d) {
                    price += 0.01;
                }
            }

            stock.setLastTrade(price);
        }

        double volume = stock.getVolume();
        volume += Math.random() * stock.getVolumeWeighting();
        stock.setVolume(volume);


        return ticker + ":" + stock.getLastTrade() + ":" + stock.getVolume();
    }
View Full Code Here

        return ticker + ":" + stock.getLastTrade() + ":" + stock.getVolume();
    }

    public void addEquity(String ticker, String company, double lastTrade) {
        stocks.put(ticker, new Stock(ticker, company, lastTrade));
        tickerList.add(ticker);
    }
View Full Code Here

TOP

Related Classes of org.errai.samples.stockdemo.client.Stock

Copyright © 2018 www.massapicom. 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.