Examples of Stock


Examples of org.apache.openjpa.trader.domain.Stock

        em.getTransaction().begin();
        List<Stock> stocks = em.createQuery(GET_ALL_STOCKS, Stock.class).getResultList();
        int n = stocks.size();
        for (int i = 0; i < n; i++) {
            if (rng.nextDouble() < 0.25) {
                Stock stock = stocks.get(i);
                double oldPrice = stock.getMarketPrice();
                double delta = (rng.nextDouble() - 0.5) * MAX_CHANGE;
                double newPrice = Math.max(oldPrice + delta, 0.01);
                stock.setMarketPrice(newPrice);
            }
        }
        em.getTransaction().commit();
    }
View Full Code Here

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

Examples of org.errai.samples.stockdemo.client.shared.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

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

        /**
         * 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

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

        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

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

                            renderer.setLastTrade(Double.parseDouble(data[1]));
                            renderer.setVolume(Double.parseDouble(data[2]));
                        }
                    }
                    else if ("UpdateStockInfo".equals(message.getCommandType())) {
                        Stock stock = message.get(Stock.class, "Stock");

                        if (stock != null) {
                            EquityRenderer renderer = equities.get(stock.getTicker());

                            renderer.setCompanyName(stock.getCompanyName());
                            renderer.setOpeningPrice(stock.getOpeningPrice());
                            renderer.setLastTrade(stock.getLastTrade());
                            renderer.setVolume(stock.getVolume());
                        }
                    }
                }
            });
View Full Code Here

Examples of org.jbehave.examples.core.model.Stock

    }
    return mockTradePersister().retrieveTrader(name);
  }

  static TraderPersister mockTradePersister() {
    return new TraderPersister(new Trader("Mauro", asList(new Stock("STK1", 10.d))));
  }
View Full Code Here

Examples of org.jbehave.examples.core.model.Stock

    private Stock stock;
    private ExamplesTable table;

    @Given("l'on a une action avec symbole $symbol et un seuil de $threshold")
    public void aStock(@Named("symbol") String symbol, @Named("threshold") double threshold) {
        stock = new Stock(symbol, threshold);
    }
View Full Code Here

Examples of org.jbehave.examples.core.model.Stock

    private Stock stock;
    private ExamplesTable table;

    @Given("ho un'azione con simbolo $symbol e una soglia di $threshold")
    public void aStock(@Named("symbol") String symbol, @Named("threshold") double threshold) {
        stock = new Stock(symbol, threshold);
    }
View Full Code Here

Examples of org.jbehave.examples.core.model.Stock

    // Actually it would be spelled "symbol" in German, but
    // we want to verify that umlauts work for parameter names.
    @Given("ich habe eine Aktion mit dem Symbol $sümbol und eine Schwelle von $threshold")
    public void aStock(@Named("sümbol") String symbol, @Named("threshold") double threshold) {
        stock = new Stock(symbol, threshold);
    }
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.