Example #1
0
        /// <summary>
        /// Creates an {@code ResolvedFxSingle} using a rate.
        /// <para>
        /// This create an FX specifying a value date, notional in one currency, the second currency
        /// and the FX rate between the two.
        /// The currencies of the payments must differ.
        /// </para>
        /// <para>
        /// This factory identifies the currency pair of the exchange and assigns the payments
        /// to match the base or counter currency of the standardized currency pair.
        /// For example, a EUR/USD exchange always has EUR as the base payment and USD as the counter payment.
        /// </para>
        /// <para>
        /// No payment date adjustments apply.
        ///
        /// </para>
        /// </summary>
        /// <param name="amountCurrency1">  the amount of the near leg in the first currency </param>
        /// <param name="fxRate">  the near FX rate </param>
        /// <param name="paymentDate">  date that the FX settles </param>
        /// <returns> the resolved foreign exchange transaction </returns>
        public static ResolvedFxSingle of(CurrencyAmount amountCurrency1, FxRate fxRate, LocalDate paymentDate)
        {
            CurrencyPair pair = fxRate.Pair;

            ArgChecker.isTrue(pair.contains(amountCurrency1.Currency));
            Currency       currency2       = pair.Base.Equals(amountCurrency1.Currency) ? pair.Counter : pair.Base;
            CurrencyAmount amountCurrency2 = amountCurrency1.convertedTo(currency2, fxRate).negated();

            return(ResolvedFxSingle.of(Payment.of(amountCurrency1, paymentDate), Payment.of(amountCurrency2, paymentDate)));
        }
        //-------------------------------------------------------------------------
        public PortfolioItemSummary summarize()
        {
            // Pay USD 1mm @ USD/CNY 6.62 NDF : 21Jan18
            StringBuilder  buf      = new StringBuilder(64);
            CurrencyAmount notional = product.SettlementCurrencyNotional;
            CurrencyAmount counter  = notional.convertedTo(product.NonDeliverableCurrency, product.AgreedFxRate);

            buf.Append(SummarizerUtils.fx(notional, counter));
            buf.Append(" NDF : ");
            buf.Append(SummarizerUtils.date(product.PaymentDate));
            return(SummarizerUtils.summary(this, ProductType.FX_NDF, buf.ToString(), product.SettlementCurrency, product.NonDeliverableCurrency));
        }
Example #3
0
        // internal method where adjustment may be null
        private static FxSingle create(CurrencyAmount amount, FxRate fxRate, LocalDate paymentDate, BusinessDayAdjustment paymentDateAdjustment)
        {
            ArgChecker.notNull(amount, "amount");
            ArgChecker.notNull(fxRate, "fxRate");
            ArgChecker.notNull(paymentDate, "paymentDate");
            CurrencyPair pair = fxRate.Pair;

            if (!pair.contains(amount.Currency))
            {
                throw new System.ArgumentException(Messages.format("FxRate '{}' and CurrencyAmount '{}' must have a currency in common", fxRate, amount));
            }
            Currency       currency2       = pair.Base.Equals(amount.Currency) ? pair.Counter : pair.Base;
            CurrencyAmount amountCurrency2 = amount.convertedTo(currency2, fxRate).negated();

            return(create(amount, amountCurrency2, paymentDate, paymentDateAdjustment));
        }