示例#1
0
    @Override
    public Boolean call() throws Exception {
      boolean result = false;

      final Engine e = EngineFactory.getEngine(EngineFactory.DEFAULT);

      if (e != null && securityNode.getQuoteSource() != QuoteSource.NONE) {
        final SecurityParser parser = securityNode.getQuoteSource().getParser();

        if (parser != null
            && !Thread.currentThread().isInterrupted()) { // check for thread interruption
          if (parser.parse(securityNode)) {

            final SecurityHistoryNode node =
                new SecurityHistoryNode(
                    parser.getDate(),
                    parser.getPrice(),
                    parser.getVolume(),
                    parser.getHigh(),
                    parser.getLow());

            if (!Thread.currentThread().isInterrupted()) { // check for thread interruption
              result = e.addSecurityHistory(securityNode, node);

              if (result) {
                logger.info(
                    ResourceUtils.getString("Message.UpdatedPrice", securityNode.getSymbol()));
              }
            }
          }
        }
      }

      return result;
    }
示例#2
0
    @Override
    public Boolean call() throws Exception {

      boolean result = true;

      final Engine e = EngineFactory.getEngine(EngineFactory.DEFAULT);

      final LocalDate oldest = securityNode.getHistoryNodes().get(0).getLocalDate();

      if (e != null && securityNode.getQuoteSource() != QuoteSource.NONE) {

        final Set<SecurityHistoryEvent> oldHistoryEvents =
            new HashSet<>(securityNode.getHistoryEvents());

        for (final SecurityHistoryEvent securityHistoryEvent :
            YahooEventParser.retrieveNew(securityNode)) {
          if (!Thread.currentThread().isInterrupted()) { // check for thread interruption

            if (securityHistoryEvent.getDate().isAfter(oldest)
                || securityHistoryEvent.getDate().isEqual(oldest)) {
              if (!oldHistoryEvents.contains(securityHistoryEvent)) {
                result = e.addSecurityHistoryEvent(securityNode, securityHistoryEvent);

                if (result) {
                  logger.info(
                      ResourceUtils.getString(
                          "Message.UpdatedSecurityEvent", securityNode.getSymbol()));
                }
              }
            }
          }
        }
      }

      return result;
    }