Exemple #1
0
        internal static ResolvedFxSwap sut2()
        {
            ResolvedFxSingle nearLeg = ResolvedFxSingle.of(CurrencyAmount.of(GBP, 1_100), CurrencyAmount.of(USD, -1_650), DATE_2011_11_21);
            ResolvedFxSingle farLeg  = ResolvedFxSingle.of(CurrencyAmount.of(GBP, -1_100), CurrencyAmount.of(USD, 1_750), DATE_2011_12_21);

            return(ResolvedFxSwap.of(nearLeg, farLeg));
        }
 public virtual void test_of_amounts_positiveNegative()
 {
     assertThrowsIllegalArg(() => ResolvedFxSingle.of(GBP_P1000, USD_P1600, DATE_2015_06_30));
     assertThrowsIllegalArg(() => ResolvedFxSingle.of(GBP_M1000, USD_M1600, DATE_2015_06_30));
     assertThrowsIllegalArg(() => ResolvedFxSingle.of(CurrencyAmount.zero(GBP), USD_M1600, DATE_2015_06_30));
     assertThrowsIllegalArg(() => ResolvedFxSingle.of(CurrencyAmount.zero(GBP), USD_P1600, DATE_2015_06_30));
 }
 private ResolvedFxSingleTrade(TradeInfo info, ResolvedFxSingle product)
 {
     JodaBeanUtils.notNull(info, "info");
     JodaBeanUtils.notNull(product, "product");
     this.info    = info;
     this.product = product;
 }
Exemple #4
0
        public virtual void test_of_wrongCounterCurrency()
        {
            ResolvedFxSingle nearLeg = ResolvedFxSingle.of(USD_P1550, EUR_P1590.negated(), DATE_2011_11_21);
            ResolvedFxSingle farLeg  = ResolvedFxSingle.of(GBP_M1000, EUR_P1590, DATE_2011_12_21);

            assertThrowsIllegalArg(() => ResolvedFxSwap.of(nearLeg, farLeg));
        }
        public virtual void test_builder_switchOrder()
        {
            ResolvedFxSingle test = ResolvedFxSingle.meta().builder().set(ResolvedFxSingle.meta().baseCurrencyPayment(), PAYMENT_USD_M1600).set(ResolvedFxSingle.meta().counterCurrencyPayment(), PAYMENT_GBP_P1000).build();

            assertEquals(test.BaseCurrencyPayment, PAYMENT_GBP_P1000);
            assertEquals(test.CounterCurrencyPayment, PAYMENT_USD_M1600);
            assertEquals(test.PaymentDate, DATE_2015_06_30);
        }
Exemple #6
0
 private ResolvedFxSwap(ResolvedFxSingle nearLeg, ResolvedFxSingle farLeg)
 {
     JodaBeanUtils.notNull(nearLeg, "nearLeg");
     JodaBeanUtils.notNull(farLeg, "farLeg");
     this.nearLeg = nearLeg;
     this.farLeg  = farLeg;
     validate();
 }
        //-------------------------------------------------------------------------
        public virtual void test_resolve()
        {
            FxSingle         fwd  = sut();
            ResolvedFxSingle test = fwd.resolve(REF_DATA);

            assertEquals(test.BaseCurrencyPayment, Payment.of(GBP_P1000, DATE_2015_06_30));
            assertEquals(test.CounterCurrencyPayment, Payment.of(USD_M1600, DATE_2015_06_30));
            assertEquals(test.PaymentDate, DATE_2015_06_30);
        }
        public virtual void test_of_rate_bothZero()
        {
            ResolvedFxSingle test = ResolvedFxSingle.of(CurrencyAmount.zero(GBP), FxRate.of(USD, GBP, 1.6d), DATE_2015_06_30);

            assertEquals(test.BaseCurrencyPayment.Value, CurrencyAmount.zero(GBP));
            assertEquals(test.CounterCurrencyPayment.Value.Amount, CurrencyAmount.zero(USD).Amount, 1e-12);
            assertEquals(test.PaymentDate, DATE_2015_06_30);
            assertEquals(test.CurrencyPair, CurrencyPair.of(GBP, USD));
            assertEquals(test.ReceiveCurrencyAmount, CurrencyAmount.of(USD, 0d));
        }
        //-------------------------------------------------------------------------
        public virtual void test_of_rate_rightOrder()
        {
            ResolvedFxSingle test = ResolvedFxSingle.of(GBP_P1000, FxRate.of(GBP, USD, 1.6d), DATE_2015_06_30);

            assertEquals(test.BaseCurrencyPayment, Payment.of(GBP_P1000, DATE_2015_06_30));
            assertEquals(test.CounterCurrencyPayment, Payment.of(USD_M1600, DATE_2015_06_30));
            assertEquals(test.PaymentDate, DATE_2015_06_30);
            assertEquals(test.CurrencyPair, CurrencyPair.of(GBP, USD));
            assertEquals(test.ReceiveCurrencyAmount, GBP_P1000);
        }
        public virtual void test_of_amounts_bothZero()
        {
            ResolvedFxSingle test = ResolvedFxSingle.of(CurrencyAmount.zero(GBP), CurrencyAmount.zero(USD), DATE_2015_06_30);

            assertEquals(test.BaseCurrencyPayment, Payment.of(CurrencyAmount.zero(GBP), DATE_2015_06_30));
            assertEquals(test.CounterCurrencyPayment, Payment.of(CurrencyAmount.zero(USD), DATE_2015_06_30));
            assertEquals(test.PaymentDate, DATE_2015_06_30);
            assertEquals(test.CurrencyPair, CurrencyPair.of(GBP, USD));
            assertEquals(test.ReceiveCurrencyAmount, CurrencyAmount.zero(USD));
        }
        public virtual void test_of_amounts_switchOrder()
        {
            ResolvedFxSingle test = ResolvedFxSingle.of(USD_M1600, GBP_P1000, DATE_2015_06_30);

            assertEquals(test.BaseCurrencyPayment, PAYMENT_GBP_P1000);
            assertEquals(test.CounterCurrencyPayment, PAYMENT_USD_M1600);
            assertEquals(test.PaymentDate, DATE_2015_06_30);
            assertEquals(test.CurrencyPair, CurrencyPair.of(GBP, USD));
            assertEquals(test.ReceiveCurrencyAmount, GBP_P1000);
        }
Exemple #12
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)));
        }
Exemple #13
0
        public virtual void test_ofForwardPoints()
        {
            double           nearRate   = 1.6;
            double           fwdPoint   = 0.1;
            ResolvedFxSwap   test       = ResolvedFxSwap.ofForwardPoints(GBP_P1000, USD, nearRate, fwdPoint, DATE_2011_11_21, DATE_2011_12_21);
            ResolvedFxSingle nearLegExp = ResolvedFxSingle.of(GBP_P1000, CurrencyAmount.of(USD, -1000.0 * nearRate), DATE_2011_11_21);
            ResolvedFxSingle farLegExp  = ResolvedFxSingle.of(GBP_M1000, CurrencyAmount.of(USD, 1000.0 * (nearRate + fwdPoint)), DATE_2011_12_21);

            assertEquals(test.NearLeg, nearLegExp);
            assertEquals(test.FarLeg, farLegExp);
        }
Exemple #14
0
        /// <summary>
        /// Creates a {@code ResolvedFxSwap} using forward points.
        /// <para>
        /// The FX rate at the near date is specified as {@code fxRate}.
        /// The FX rate at the far date is equal to {@code fxRate + forwardPoints}
        /// </para>
        /// <para>
        /// The two currencies must not be equal.
        /// The near date must be before the far date.
        /// Conventions will be used to determine the base and counter currency.
        ///
        /// </para>
        /// </summary>
        /// <param name="amountCurrency1">  the amount of the near leg in the first currency </param>
        /// <param name="currency2">  the second currency </param>
        /// <param name="nearFxRate">  the near FX rate, where {@code (1.0 * amountCurrency1 = fxRate * amountCurrency2)} </param>
        /// <param name="forwardPoints">  the forward points, where the far FX rate is {@code (fxRate + forwardPoints)} </param>
        /// <param name="nearDate">  the near value date </param>
        /// <param name="farDate">  the far value date </param>
        /// <returns> the resolved FX swap </returns>
        public static ResolvedFxSwap ofForwardPoints(CurrencyAmount amountCurrency1, Currency currency2, double nearFxRate, double forwardPoints, LocalDate nearDate, LocalDate farDate)
        {
            Currency currency1 = amountCurrency1.Currency;

            ArgChecker.isFalse(currency1.Equals(currency2), "Currencies must not be equal");
            ArgChecker.notNegativeOrZero(nearFxRate, "fxRate");
            double           farFxRate = nearFxRate + forwardPoints;
            ResolvedFxSingle nearLeg   = ResolvedFxSingle.of(amountCurrency1, FxRate.of(currency1, currency2, nearFxRate), nearDate);
            ResolvedFxSingle farLeg    = ResolvedFxSingle.of(amountCurrency1.negated(), FxRate.of(currency1, currency2, farFxRate), farDate);

            return(of(nearLeg, farLeg));
        }
Exemple #15
0
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         ResolvedFxSingle other = (ResolvedFxSingle)obj;
         return(JodaBeanUtils.equal(baseCurrencyPayment, other.baseCurrencyPayment) && JodaBeanUtils.equal(counterCurrencyPayment, other.counterCurrencyPayment));
     }
     return(false);
 }
Exemple #16
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 1825755334:         // nearLeg
                    this.nearLeg = (ResolvedFxSingle)newValue;
                    break;

                case -1281739913:         // farLeg
                    this.farLeg = (ResolvedFxSingle)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 3237038:         // info
                    this.info_Renamed = (TradeInfo)newValue;
                    break;

                case -309474065:         // product
                    this.product_Renamed = (ResolvedFxSingle)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(ResolvedFxSingleTrade beanToCopy)
 {
     this.info_Renamed    = beanToCopy.Info;
     this.product_Renamed = beanToCopy.Product;
 }
 public virtual void test_builder_sameCurrency()
 {
     assertThrowsIllegalArg(() => ResolvedFxSingle.meta().builder().set(ResolvedFxSingle.meta().baseCurrencyPayment(), PAYMENT_GBP_P1000).set(ResolvedFxSingle.meta().counterCurrencyPayment(), PAYMENT_GBP_M1000).build());
 }
Exemple #20
0
 /// <summary>
 /// Creates an {@code ResolvedFxSingle} from two amounts and the value date.
 /// <para>
 /// The amounts must be of the correct type, one pay and one receive.
 /// 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>
 /// </summary>
 /// <param name="amount1">  the amount in the first currency </param>
 /// <param name="amount2">  the amount in the second currency </param>
 /// <param name="valueDate">  the value date </param>
 /// <returns> the resolved foreign exchange transaction </returns>
 public static ResolvedFxSingle of(CurrencyAmount amount1, CurrencyAmount amount2, LocalDate valueDate)
 {
     return(ResolvedFxSingle.of(Payment.of(amount1, valueDate), Payment.of(amount2, valueDate)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance of a resolved single FX trade.
 /// </summary>
 /// <param name="info">  the trade info </param>
 /// <param name="product">  the product </param>
 /// <returns> the resolved trade </returns>
 public static ResolvedFxSingleTrade of(TradeInfo info, ResolvedFxSingle product)
 {
     return(new ResolvedFxSingleTrade(info, product));
 }
        //-------------------------------------------------------------------------
        public virtual void test_inverse()
        {
            ResolvedFxSingle test = sut();

            assertEquals(test.inverse(), ResolvedFxSingle.of(GBP_M1000, USD_P1600, DATE_2015_06_30));
        }
Exemple #23
0
        public virtual void test_of_wrongBaseCurrency()
        {
            ResolvedFxSingle nearLeg = ResolvedFxSingle.of(EUR_P1590, USD_M1600, DATE_2011_11_21);

            assertThrowsIllegalArg(() => ResolvedFxSwap.of(nearLeg, FAR_LEG));
        }
 //-------------------------------------------------------------------------
 internal static ResolvedFxSingle sut()
 {
     return(ResolvedFxSingle.of(GBP_P1000, USD_M1600, DATE_2015_06_30));
 }
 internal static ResolvedFxSingle sut2()
 {
     return(ResolvedFxSingle.of(GBP_M1000, EUR_P1600, DATE_2015_06_29));
 }
 internal static ResolvedFxSingle sut3()
 {
     return(ResolvedFxSingle.of(USD_M1600, EUR_P1600, DATE_2015_06_30));
 }
 /// <summary>
 /// Sets the resolved single FX product.
 /// <para>
 /// The product captures the contracted financial details of the trade.
 /// </para>
 /// </summary>
 /// <param name="product">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder product(ResolvedFxSingle product)
 {
     JodaBeanUtils.notNull(product, "product");
     this.product_Renamed = product;
     return(this);
 }
Exemple #28
0
        public virtual void test_of_sameSign()
        {
            ResolvedFxSingle farLeg = ResolvedFxSingle.of(GBP_M1000.negated(), USD_P1550.negated(), DATE_2011_12_21);

            assertThrowsIllegalArg(() => ResolvedFxSwap.of(NEAR_LEG, farLeg));
        }
Exemple #29
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Creates a {@code ResolvedFxSwap} from two legs.
 /// <para>
 /// The transactions must be passed in with payment dates in the correct order.
 /// The currency pair of each leg must match and have amounts flowing in opposite directions.
 ///
 /// </para>
 /// </summary>
 /// <param name="nearLeg">  the earlier leg </param>
 /// <param name="farLeg">  the later leg </param>
 /// <returns> the resolved FX swap </returns>
 public static ResolvedFxSwap of(ResolvedFxSingle nearLeg, ResolvedFxSingle farLeg)
 {
     return(new ResolvedFxSwap(nearLeg, farLeg));
 }
 public virtual void test_of_payments_sameCurrency()
 {
     assertThrowsIllegalArg(() => ResolvedFxSingle.of(PAYMENT_GBP_P1000, PAYMENT_GBP_M1000));
 }