Package com.opengamma

Examples of com.opengamma.OpenGammaRuntimeException


      return null;
    }
    try {
      return RestructuringClause.valueOf(bean.getName());
    } catch (final IllegalArgumentException e) {
      throw new OpenGammaRuntimeException("Bad value for RestructuringClause type (" + bean.getName() + ")");
    }
  }
View Full Code Here


    @Override
    public CurveInstrumentConfig buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
      final List<FudgeField> stripInstrumentTypeFields = message.getAllByName(STRIP_INSTRUMENT_FIELD);
      final List<FudgeField> curveExposureNameFields = message.getAllByName(CURVE_EXPOSURES_FIELD);
      if (stripInstrumentTypeFields.size() != curveExposureNameFields.size()) {
        throw new OpenGammaRuntimeException("Should never happen");
      }
      final Map<StripInstrumentType, String[]> exposures = new HashMap<StripInstrumentType, String[]>();
      for (int i = 0; i < stripInstrumentTypeFields.size(); i++) {
        final String stripName = deserializer.fieldValueToObject(String.class, stripInstrumentTypeFields.get(i));
        final List<FudgeField> namesField = ((FudgeMsg) curveExposureNameFields.get(i).getValue()).getAllByName(PER_INSTRUMENT_FIELD_NAME);
View Full Code Here

  }

  public static void fromFudgeMsg(FudgeDeserializer deserializer, FudgeMsg msg, NonDeliverableFXForwardSecurity object) {
    FinancialSecurityFudgeBuilder.fromFudgeMsg(deserializer, msg, object);
    if (msg.getInt(VERSION_FIELD_NAME) != VERSION) {
      throw new OpenGammaRuntimeException("Incorrect version of FXForwardSecurity persisted.  Object model has changed to not include underlying");
    }
    object.setPayCurrency(msg.getValue(Currency.class, PAY_CURRENCY_FIELD_NAME));
    object.setPayAmount(msg.getDouble(PAY_AMOUNT_FIELD_NAME));
    object.setReceiveCurrency(msg.getValue(Currency.class, RECEIVE_CURRENCY_FIELD_NAME));
    object.setReceiveAmount(msg.getDouble(RECEIVE_AMOUNT_FIELD_NAME));
View Full Code Here

      }
    } else if (id instanceof UniqueId) {
      final UniqueId uid = (UniqueId) id;
      return getFXMultiplierFromExternalId(ExternalId.of(ExternalSchemes.BLOOMBERG_TICKER, uid.getValue()), multiplier);
    }
    throw new OpenGammaRuntimeException("id was not FX rate, which shouldn't happen");
  }
View Full Code Here

  private static Pair<Currency, Currency> getFXPairFromBloombergTicker(final ExternalId id) {
    if (id.getScheme().equals(ExternalSchemes.BLOOMBERG_TICKER) || id.getScheme().equals(ExternalSchemes.BLOOMBERG_TICKER_WEAK)) {
      final String ticker = id.getValue();
      final String[] split = ticker.split(" ");
      if (split.length != 2) {
        throw new OpenGammaRuntimeException("ticker contained more than one space:" + ticker);
      }
      if (!split[1].equals("Curncy")) {
        throw new OpenGammaRuntimeException("ticker did not end with Curncy:" + ticker);
      }
      final String ccyPart = split[0];
      switch (ccyPart.length()) {
        case 3:
        {
          final Currency ccy = Currency.of(ccyPart);
          if (StandardCurrencyPairs.isSingleCurrencyNumerator(ccy)) {
            return Pair.of(ccy, Currency.USD);
          } else {
            return Pair.of(Currency.USD, ccy);
          }
        }
        case 6:
        {
          final Currency numerator = Currency.of(ccyPart.substring(0, 3));
          final Currency denominator = Currency.of(ccyPart.substring(3));
          return Pair.of(numerator, denominator);
        }
        default:
          throw new OpenGammaRuntimeException("currency part of ticker did not have 3 or 6 characters" + ticker);
      }
    } else {
      throw new OpenGammaRuntimeException("id was not bloomberg ticker or bloomberg weak ticker" + id);
    }
  }
View Full Code Here

    }
  }

  private void startJmsIfRequired(String destination) throws Exception {
    if (_jmsConnector == null) {
      throw new OpenGammaRuntimeException("JMS not configured on server");
    }
    if (_producer == null) {
      try {
        _connection = _jmsConnector.getConnectionFactory().createConnection();
        _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
View Full Code Here

      if (instance == null) {
        try {
          instance = (BusinessDayConvention) Class.forName(clazz).newInstance();
          instances.put(clazz, instance);
        } catch (final InstantiationException ex) {
          throw new OpenGammaRuntimeException("Error initialising BusinessDay conventions", ex);
        } catch (final IllegalAccessException ex) {
          throw new OpenGammaRuntimeException("Error initialising BusinessDay conventions", ex);
        } catch (final ClassNotFoundException ex) {
          throw new OpenGammaRuntimeException("Error initialising BusinessDay conventions", ex);
        }
      }
      _conventionMap.put(convention.toLowerCase(), instance);
    }
    _conventions = new ArrayList<>(instances.values());
View Full Code Here

        } else if (nameConstructor >= 0) {
          instance = (Calendar) constructors[nameConstructor].newInstance(calendarName);
        } else if (noArgConstructor >= 0) {
          instance = (Calendar) constructors[noArgConstructor].newInstance();
        } else {
          throw new OpenGammaRuntimeException("No suitable constructor for '" + calendarName + "'");
        }
        _calendarMap.put(calendarName.toLowerCase(), instance);
      } catch (final InstantiationException ex) {
        throw new OpenGammaRuntimeException("Error initialising Calendars", ex);
      } catch (final IllegalAccessException ex) {
        throw new OpenGammaRuntimeException("Error initialising Calendars", ex);
      } catch (final ClassNotFoundException ex) {
        throw new OpenGammaRuntimeException("Error initialising Calendars", ex);
      } catch (final IllegalArgumentException ex) {
        throw new OpenGammaRuntimeException("Error initialising Calendars", ex);
      } catch (final InvocationTargetException ex) {
        throw new OpenGammaRuntimeException("Error initialising Calendars", ex);
      }
    }
  }
View Full Code Here

    final ResourceBundle countries = ResourceBundle.getBundle("com.opengamma.financial.convention.calendar.Country");
    for (final String countryCode : countries.keySet()) {
      final String calendarName = countries.getString(countryCode);
      final Calendar calendar = getCalendar(calendarName);
      if (calendar == null) {
        throw new OpenGammaRuntimeException("Cannot find calendar '" + calendarName + "' for country '" + countryCode + "'");
      }
      _countryMap.put(countryCode, calendar);
    }
  }
View Full Code Here

   * Throws a suitable exception.
   * @param th  the error, not null
   * @return the exception to throw, not null
   */
  private OpenGammaRuntimeException wrap(final Throwable th) {
    return new OpenGammaRuntimeException("Unable to populate calendar from XML", th);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.OpenGammaRuntimeException

Copyright © 2018 www.massapicom. 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.