Package org.errai.samples.stockdemo.client.shared

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


    }
  }

  @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.shared.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.