Examples of Stock


Examples of models.data.Stock

     *
     * @param ticker
     * @return
     */
    public boolean stockExistInSystem(String ticker) {
        Stock stock = Stock.find.where().eq("ticker", ticker).findUnique();
        return stock != null;
    }
View Full Code Here

Examples of net.helipilot50.stocktrade.model.Stock

    Map<String, ClResultCode> rvs = DBClient.getInstance().scanAllNodes(DBClient.NAME_SPACE, "Stock", new ScanCallback() {
     
      public void scanCallback(String namespace, String set, byte[] digest,
          Map<String, Object> bins, int generation, int expirationDate,
          Object userData) {
        Stock stock = new Stock();
        stock.setStockName((String) bins.get("StockName"));
        stock.setCompanyName((String) bins.get("Company"));
        stocks.add(stock);
      }
    }, null);
    return stocks;
  }
View Full Code Here

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

public class SectorBasedQueryTargetPolicy implements QueryTargetPolicy {

  @Override
  public String[] getTargets(String query, Map<Object, Object> params,
      String language, List<String> slices, Object context) {       
    Stock stock = null;
    if (TradingService.MATCH_ASK.equals(query)) {
      stock = ((Tradable)params.get("ask")).getStock();
    } else if (TradingService.MATCH_BID.equals(query)) {
      stock = ((Tradable)params.get("bid")).getStock();
    }
        return stock != null ? new String[]{slices.get(stock.getSector().ordinal())} : null;
  }
View Full Code Here

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

     * This distribution policy determines the sector of the stock and
     * picks the slice of the given list of slices at ordinal index of the
     * enumerated Sector.
     */
    public String distribute(Object pc, List<String> slices, Object context) {
        Stock stock = null;
        if (pc instanceof Tradable) {
            stock = ((Tradable)pc).getStock();
        } else if (pc instanceof Stock) {
            stock = (Stock)pc;
        } else if (pc instanceof Trade) {
          stock = ((Trade)pc).getStock();
        } else if (pc instanceof Trader) {
            throw new IllegalArgumentException("Trader should have been replicated");
        }
        return stock != null ? slices.get(stock.getSector().ordinal()) : null;
    }
View Full Code Here

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

    private static Random rng = new Random(System.currentTimeMillis());
   
    public MockTradingService() {
        Sector[] sectors = Sector.values();
        for (int i = 0; i < 10; i++) {
            Stock stock = new Stock("Stock-"+i, "Company-"+i, sectors[rng.nextInt(sectors.length)],
                    10*rng.nextDouble());
            _stocks.add(stock);
        }
    }
View Full Code Here

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

        initialize(stocks.get(0), false);

        symbols.addChangeHandler(new ChangeHandler() {
            @Override
            public void onChange(ChangeEvent event) {
                Stock stock = getSelectedStock();
                initialize(stock, false);
            }
        });

        ask.addClickHandler(new ClickHandler() {
View Full Code Here

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

     * ---------------------------------------------------------------------------------
     * Service Event Response Management
     * ---------------------------------------------------------------------------------
     */
    public void onStockUpdated(ServiceEvent.StockUpdated event) {
        Stock updated = event.getPayload();
        Stock current = getSelectedStock();
        if (updated.equals(current)) {
            initialize(updated, true);
        }
    }
View Full Code Here

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

    }

    @Override
    public void onStockUpdated(ServiceEvent.StockUpdated event) {
        int n = getRowCount();
        Stock updatedStock = event.getPayload();
        for (int i = 0; i < n; i++) {
            Tradable t = get(i);
            if (updatedStock.equals(t.getStock())) {
                t.updateStock(updatedStock);
                update(t, new Integer[]{1,4});
            }
        }
    }
View Full Code Here

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

    }

    public Stock getStock(String symbol) {
        EntityManager em = getEntityManager();
        begin();
        Stock stock = em.find(Stock.class, symbol);
        em.refresh(stock);
        commit();
        return stock;
    }
View Full Code Here

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

        begin();
        List<Stock> stocks = em.createQuery(GET_ALL_STOCKS, Stock.class).getResultList();
        if (stocks.isEmpty()) {
            for (int i = 0; i < data.length; i++) {
                Object[] d = data[i];
                Stock stock = new Stock((String)d[0], (String)d[0], (Sector)d[1], (Double)d[2]);
                em.persist(stock);
            }
       
            for (int i = 0; i < 4; i++) {
                Trader trader = new Trader("Trader-"+i);
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.