Package com.opengamma.util.money

Examples of com.opengamma.util.money.Currency


  private ValueProperties.Builder createCurrencyValueProperties(final ComputationTarget target) {
    final Security security = target.getPosition().getSecurity();
    if (FXUtils.isFXSecurity(security)) {
      return createValueProperties(); //TODO what to do in this case?
    }
    final Currency ccy = FinancialSecurityUtils.getCurrency(security);
    if (ccy == null) {
      return createValueProperties(); //TODO a problem when using externally-provided securities
    }
    final ValueProperties.Builder properties = createValueProperties();
    properties.with(ValuePropertyNames.CURRENCY, ccy.getCode());
    return properties;
  }
View Full Code Here


  public MutableFudgeMsg buildMessage(final FudgeSerializer serializer, final VolatilitySurfaceDefinition<?, ?> object) {
    final MutableFudgeMsg message = serializer.newMessage();
    // the following forces it not to use a secondary type if one is available.
    message.add(TARGET_FIELD, FudgeSerializer.addClassHeader(serializer.objectToFudgeMsg(object.getTarget()), object.getTarget().getClass()));
    if (object.getTarget() instanceof Currency) {
      final Currency ccy = (Currency) object.getTarget();
      message.add(CURRENCY_FIELD, null, ccy.getCode());
    } else {
      // just for now...
      message.add(CURRENCY_FIELD, null, Currency.USD.getCode());
    }
    message.add(NAME_FIELD, object.getName());
View Full Code Here

    return bean;
  }

  @Override
  public FRASecurity createSecurity(final OperationContext context, FRASecurityBean bean) {
    Currency currency = currencyBeanToCurrency(bean.getCurrency());
    ExternalId regionId = externalIdBeanToExternalId(bean.getRegion());
    ZonedDateTime startDate = zonedDateTimeBeanToDateTimeWithZone(bean.getStartDate());
    ZonedDateTime endDate = zonedDateTimeBeanToDateTimeWithZone(bean.getEndDate());
    double rate = bean.getRate();
    double amount = bean.getAmount();
View Full Code Here

          return NO_CURRENCY;
        case 1:
          return currencies.iterator().next().getCode();
        case 2: {
          final Iterator<Currency> iter = currencies.iterator();
          final Currency base = iter.next();
          final Currency counter = iter.next();
          final UnorderedCurrencyPair unordered = UnorderedCurrencyPair.of(base, counter);
          final StringBuilder sb = new StringBuilder();
          sb.append(unordered.getFirstCurrency().getCode());
          sb.append("/");
          sb.append(unordered.getSecondCurrency().getCode());
View Full Code Here

    public OvernightIndexConvention buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
      final String name = message.getString(NAME_FIELD);
      final ExternalIdBundle externalIdBundle = deserializer.fieldValueToObject(ExternalIdBundle.class, message.getByName(EXTERNAL_ID_BUNDLE_FIELD));
      final DayCount dayCount = DayCountFactory.INSTANCE.getDayCount(message.getString(DAY_COUNT_FIELD));
      final int publicationLag = message.getInt(PUBLICATION_LAG_FIELD);
      final Currency currency = Currency.of(message.getString(CURRENCY_FIELD));
      final ExternalId region = deserializer.fieldValueToObject(ExternalId.class, message.getByName(REGION_FIELD));
      final OvernightIndexConvention convention = new OvernightIndexConvention(name, externalIdBundle, dayCount, publicationLag, currency, region);
      final FudgeField uniqueIdMsg = message.getByName(UNIQUE_ID_FIELD);
      if (uniqueIdMsg != null) {
        convention.setUniqueId(deserializer.fieldValueToObject(UniqueId.class, uniqueIdMsg));
View Full Code Here

    @Override
    public PriceIndexConvention buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
      final String name = message.getString(NAME_FIELD);
      final ExternalIdBundle externalIdBundle = deserializer.fieldValueToObject(ExternalIdBundle.class, message.getByName(EXTERNAL_ID_BUNDLE_FIELD));
      final Currency currency = Currency.of(message.getString(CURRENCY_FIELD));
      final ExternalId region = deserializer.fieldValueToObject(ExternalId.class, message.getByName(REGION_FIELD));
      final ExternalId priceIndexId = deserializer.fieldValueToObject(ExternalId.class, message.getByName(PRICE_INDEX_ID_FIELD));
      final PriceIndexConvention convention = new PriceIndexConvention(name, externalIdBundle, currency, region, priceIndexId);
      final FudgeField uniqueIdMsg = message.getByName(UNIQUE_ID_FIELD);
      if (uniqueIdMsg != null) {
View Full Code Here

  }
 
  private static Set<Currency> getCurrencyCalendars(FudgeDeserializer deserializer, FudgeMsg message) {
    Set<Currency> currencies = new HashSet<Currency>();
    for (FudgeField ccyField : message.getAllByName(CURRENCY_CALENDAR_FIELD)) {
      Currency ccy = deserializer.fieldValueToObject(Currency.class, ccyField);
      currencies.add(ccy);
    }
    return !currencies.isEmpty() ? currencies : null;
  }
View Full Code Here

    final ComputationTargetTypeMap<Function1<ComputationTarget, ValueProperties>> map = new ComputationTargetTypeMap<>();
    map.put(ComputationTargetType.POSITION, new Function1<ComputationTarget, ValueProperties>() {
      @Override
      public ValueProperties execute(final ComputationTarget target) {
        final Security security = target.getPosition().getSecurity();
        final Currency ccy = getCurrency(security);
        if (ccy != null) {
          return ValueProperties.with(ValuePropertyNames.CURRENCY, ccy.getCode()).get();
        } else {
          return ValueProperties.none();
        }
      }
    });
    map.put(ComputationTargetType.SECURITY, new Function1<ComputationTarget, ValueProperties>() {
      @Override
      public ValueProperties execute(final ComputationTarget target) {
        final Security security = target.getSecurity();
        final Currency ccy = getCurrency(security);
        if (ccy != null) {
          return ValueProperties.with(ValuePropertyNames.CURRENCY, ccy.getCode()).get();
        } else {
          return ValueProperties.none();
        }
      }
    });
    map.put(ComputationTargetType.TRADE, new Function1<ComputationTarget, ValueProperties>() {
      @Override
      public ValueProperties execute(final ComputationTarget target) {
        final Security security = target.getTrade().getSecurity();
        final Currency ccy = getCurrency(security);
        if (ccy != null) {
          return ValueProperties.with(ValuePropertyNames.CURRENCY, ccy.getCode()).get();
        } else {
          return ValueProperties.none();
        }
      }
    });
View Full Code Here

      final Tenor paymentTenor = Tenor.of(Period.parse(message.getString(PAYMENT_TENOR)));
      final DayCount dayCount = DayCountFactory.INSTANCE.getDayCount(message.getString(DAY_COUNT_FIELD));
      final BusinessDayConvention businessDayConvention = BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention(message.getString(BUSINESS_DAY_CONVENTION_FIELD));
      final int settlementDays = message.getInt(SETTLEMENT_DAYS_FIELD);
      final boolean isEOM = message.getBoolean(IS_EOM_FIELD);
      final Currency currency = Currency.of(message.getString(CURRENCY_FIELD));
      final ExternalId regionCalendar = deserializer.fieldValueToObject(ExternalId.class, message.getByName(REGION_FIELD));
      final StubType stubType = StubType.valueOf(message.getString(STUB_TYPE_FIELD));
      final boolean exchangeNotional = message.getBoolean(EXCHANGE_NOTIONAL_FIELD);
      final int paymentLag = message.getInt(PAYMENT_LAG_FIELD);
      final SwapFixedLegConvention convention = new SwapFixedLegConvention(name, externalIdBundle, paymentTenor, dayCount, businessDayConvention, currency,
View Full Code Here

   */
  public static Currency getCurrency(final Security security) {  // CSIGNORE
    if (security instanceof FinancialSecurity) {
      final FinancialSecurity finSec = (FinancialSecurity) security;

      final Currency ccy = finSec.accept(new FinancialSecurityVisitor<Currency>() {

        @Override
        public Currency visitGovernmentBondSecurity(final GovernmentBondSecurity security) {
          return security.getCurrency();
        }
View Full Code Here

TOP

Related Classes of com.opengamma.util.money.Currency

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.