예제 #1
0
파일: IBTrader.java 프로젝트: klon/jtrade
  @Override
  public void updateAccountValue(String key, String value, String currency, String accountName) {
    try {
      if (logger.isDebugEnabled())
        logger.debug(
            "updateAccountValue: {} {} {} {}", new Object[] {key, value, currency, accountName});

      if ("AccountCode".equals(key)) {
        synchronized (this) {
          this.accountCode = value;
          notifyAll();
        }
      } else if ("AvailableFunds".equalsIgnoreCase(key)
          && isCurrencyCode(currency)
          && Util.isDouble(value)) {
        portfolio.setCash(currency, Double.parseDouble(value));
      } else if ("BuyingPower".equalsIgnoreCase(key)
          && isCurrencyCode(currency)
          && Util.isDouble(value)) {
        portfolio.setBaseCurrency(currency);
      } else if ("ExchangeRate".equalsIgnoreCase(key)
          && isCurrencyCode(currency)
          && Util.isDouble(value)) {
        portfolio.setExchangeRate(currency, Double.parseDouble(value));
      }

    } catch (Throwable t) {
      logger.error(t.getMessage(), t);
    }
  }