Exemplo n.º 1
0
        public virtual void test_ofForwardPoints()
        {
            double   nearRate   = 1.6;
            double   fwdPoint   = 0.1;
            FxSwap   test       = FxSwap.ofForwardPoints(GBP_P1000, FxRate.of(GBP, USD, nearRate), fwdPoint, DATE_2011_11_21, DATE_2011_12_21);
            FxSingle nearLegExp = FxSingle.of(GBP_P1000, CurrencyAmount.of(USD, -1000.0 * nearRate), DATE_2011_11_21);
            FxSingle farLegExp  = FxSingle.of(GBP_M1000, CurrencyAmount.of(USD, 1000.0 * (nearRate + fwdPoint)), DATE_2011_12_21);

            assertEquals(test.NearLeg, nearLegExp);
            assertEquals(test.FarLeg, farLegExp);
        }
Exemplo n.º 2
0
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         FxSwap other = (FxSwap)obj;
         return(JodaBeanUtils.equal(nearLeg, other.nearLeg) && JodaBeanUtils.equal(farLeg, other.farLeg));
     }
     return(false);
 }
Exemplo n.º 3
0
            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 = (FxSwap)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
Exemplo n.º 4
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance of an FX swap trade.
 /// </summary>
 /// <param name="info">  the trade info </param>
 /// <param name="product">  the product </param>
 /// <returns> the trade </returns>
 public static FxSwapTrade of(TradeInfo info, FxSwap product)
 {
     return(new FxSwapTrade(info, product));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Sets the FX swap product that was agreed when the trade occurred.
 /// <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(FxSwap product)
 {
     JodaBeanUtils.notNull(product, "product");
     this.product_Renamed = product;
     return(this);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(FxSwapTrade beanToCopy)
 {
     this.info_Renamed    = beanToCopy.Info;
     this.product_Renamed = beanToCopy.Product;
 }
Exemplo n.º 7
0
 public virtual void test_of_ratesCurrencyAmountMismatch()
 {
     assertThrowsIllegalArg(() => FxSwap.of(GBP_P1000, FxRate.of(EUR, USD, 1.1), date(2018, 6, 1), FxRate.of(EUR, USD, 1.15), date(2018, 7, 1)));
 }
Exemplo n.º 8
0
        public virtual void test_of_sameSign()
        {
            FxSingle farLeg = FxSingle.of(GBP_M1000.negated(), USD_P1550.negated(), DATE_2011_12_21);

            assertThrowsIllegalArg(() => FxSwap.of(NEAR_LEG, farLeg));
        }
Exemplo n.º 9
0
        public virtual void test_of_wrongBaseCurrency()
        {
            FxSingle nearLeg = FxSingle.of(EUR_P1590, USD_M1600, DATE_2011_11_21);

            assertThrowsIllegalArg(() => FxSwap.of(nearLeg, FAR_LEG));
        }
Exemplo n.º 10
0
 public virtual void test_of_wrongOrder()
 {
     assertThrowsIllegalArg(() => FxSwap.of(FAR_LEG, NEAR_LEG));
 }
Exemplo n.º 11
0
 //-------------------------------------------------------------------------
 internal static FxSwap sut()
 {
     return(FxSwap.of(NEAR_LEG, FAR_LEG));
 }