/**
* 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();
}