コード例 #1
0
  public void updateArchiveEODForSymbol(final String scrip) throws Exception {

    final IScripSvc eodScripSvc = ServiceMgr.getScripSvc();
    final List<ScripEOD> activeEOD = eodScripSvc.getArchivedEODData(scrip);
    double lastClosing = -1;
    for (final ScripEOD eod : activeEOD) {
      if (lastClosing != -1) {
        eod.setPrevClosePrice(lastClosing);
      }
      lastClosing = eod.getClosingPrice();
    }

    final IEODIndexDAO dao = (IEODIndexDAO) OF.getBean("EODIndexDAO");
    dao.updateArchive(activeEOD);
  }
コード例 #2
0
  /** Returns the value of the column at the specified row index. */
  @Override
  public Object getValueAt(final int rowIndex, final int columnIndex) {
    final ScripEOD eod = getScripEODForRow(rowIndex);
    Object value = null;

    if (eod != null) {

      final String symbol = eod.getSymbolId();
      final double close = eod.getClosingPrice();
      final double open = eod.getOpeningPrice();
      final double prevClose = eod.getPrevClosePrice();

      switch (columnIndex) {
        case COL_INDEX_LINKED:
          final ScripITD itd = this.itdCache.getScripITDForSymbol(eod.getSymbolId());
          value = (itd == null) ? Boolean.FALSE : Boolean.TRUE;
          break;
        case COL_PCT_CHG_HIST:
          List<SymbolPctChange> list = null;
          list = this.eodCache.getSymbolPctChangeList(symbol);
          if (list != null && !list.isEmpty()) {
            // Interesting - the cache holds the EOD pct changes
            // starting yesterday. Now since in the EOD summary
            // panel, we show the symbol name highlighted with
            // the latest %change, we remove the first element in
            // the list.
            final List<SymbolPctChange> modList = new ArrayList<SymbolPctChange>();
            modList.addAll(list);
            modList.remove(0);

            final Double[] changes = new Double[modList.size()];
            for (int i = 0; i < modList.size(); i++) {
              changes[i] = modList.get(i).getPctChange();
            }
            value = changes;
          }
          break;
        case COL_SYMBOL:
          value = eod.getSymbolId();
          break;
        case COL_ICICI:
          value = eod.getSymbol().getIciciCode();
          break;
        case COL_PRICE:
          value = close;
          break;
        case COL_PCT_E:
          value = new Double(((close - prevClose) / prevClose) * 100);
          break;
        case COL_PCT_O:
          value = new Double(((close - open) / open) * 100);
          break;
        case COL_QTY:
          value = new Long(eod.getTotalTradeQty());
          break;
        case COL_NAME:
          value = eod.getSymbol().getDescription();
          break;
      }
    }

    return value;
  }