Ejemplo n.º 1
0
        public virtual void test_resolve_noRebate()
        {
            FxSingleBarrierOption         @base    = FxSingleBarrierOption.of(VANILLA_OPTION, BARRIER);
            ResolvedFxSingleBarrierOption expected = ResolvedFxSingleBarrierOption.of(VANILLA_OPTION.resolve(REF_DATA), BARRIER);

            assertEquals(@base.resolve(REF_DATA), expected);
        }
Ejemplo n.º 2
0
        public virtual void test_of_noRebate()
        {
            FxSingleBarrierOption test = FxSingleBarrierOption.of(VANILLA_OPTION, BARRIER);

            assertEquals(test.Barrier, BARRIER);
            assertFalse(test.Rebate.Present);
            assertEquals(test.UnderlyingOption, VANILLA_OPTION);
        }
Ejemplo n.º 3
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            FxSingleBarrierOption test1 = FxSingleBarrierOption.of(VANILLA_OPTION, BARRIER, REBATE);
            FxSingleBarrierOption test2 = FxSingleBarrierOption.of(FxVanillaOption.builder().longShort(SHORT).expiryDate(EXPIRY_DATE).expiryTime(EXPIRY_TIME).expiryZone(EXPIRY_ZONE).underlying(FX).build(), SimpleConstantContinuousBarrier.of(BarrierType.UP, KnockType.KNOCK_IN, 1.5));

            coverImmutableBean(test1);
            coverBeanEquals(test1, test2);
        }
 private FxSingleBarrierOptionTrade(TradeInfo info, FxSingleBarrierOption product, AdjustablePayment premium)
 {
     JodaBeanUtils.notNull(info, "info");
     JodaBeanUtils.notNull(product, "product");
     JodaBeanUtils.notNull(premium, "premium");
     this.info    = info;
     this.product = product;
     this.premium = premium;
 }
Ejemplo n.º 5
0
        public virtual void test_of_fail()
        {
            CurrencyAmount negative = CurrencyAmount.of(USD, -5.0e4);

            assertThrowsIllegalArg(() => FxSingleBarrierOption.of(VANILLA_OPTION, BARRIER, negative));
            CurrencyAmount other = CurrencyAmount.of(GBP, 5.0e4);

            assertThrowsIllegalArg(() => FxSingleBarrierOption.of(VANILLA_OPTION, BARRIER, other));
        }
Ejemplo n.º 6
0
        public virtual void test_builder()
        {
            FxSingleBarrierOption test = FxSingleBarrierOption.builder().underlyingOption(VANILLA_OPTION).barrier(BARRIER).rebate(REBATE).build();

            assertEquals(test.Barrier, BARRIER);
            assertEquals(test.Rebate.get(), REBATE);
            assertEquals(test.UnderlyingOption, VANILLA_OPTION);
            assertEquals(test.CurrencyPair, VANILLA_OPTION.CurrencyPair);
        }
Ejemplo n.º 7
0
        public virtual void test_of()
        {
            FxSingleBarrierOption test = FxSingleBarrierOption.of(VANILLA_OPTION, BARRIER, REBATE);

            assertEquals(test.Barrier, BARRIER);
            assertEquals(test.Rebate.get(), REBATE);
            assertEquals(test.UnderlyingOption, VANILLA_OPTION);
            assertEquals(test.CurrencyPair, VANILLA_OPTION.CurrencyPair);
            assertEquals(test.CrossCurrency, true);
            assertEquals(test.allPaymentCurrencies(), ImmutableSet.of(EUR, USD));
            assertEquals(test.allCurrencies(), ImmutableSet.of(EUR, USD));
        }
Ejemplo n.º 8
0
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         FxSingleBarrierOption other = (FxSingleBarrierOption)obj;
         return(JodaBeanUtils.equal(underlyingOption, other.underlyingOption) && JodaBeanUtils.equal(barrier, other.barrier) && JodaBeanUtils.equal(rebate, other.rebate));
     }
     return(false);
 }
            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 = (FxSingleBarrierOption)newValue;
                    break;

                case -318452137:         // premium
                    this.premium_Renamed = (AdjustablePayment)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
 /// <summary>
 /// Sets the FX option 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(FxSingleBarrierOption product)
 {
     JodaBeanUtils.notNull(product, "product");
     this.product_Renamed = product;
     return(this);
 }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(FxSingleBarrierOptionTrade beanToCopy)
 {
     this.info_Renamed    = beanToCopy.Info;
     this.product_Renamed = beanToCopy.Product;
     this.premium_Renamed = beanToCopy.Premium;
 }
Ejemplo n.º 12
0
        public virtual void test_serialization()
        {
            FxSingleBarrierOption test = FxSingleBarrierOption.of(VANILLA_OPTION, BARRIER, REBATE);

            assertSerialization(test);
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            FxSingleBarrierOptionTrade test1 = sut();
            FxSingleBarrierOptionTrade test2 = FxSingleBarrierOptionTrade.builder().product(FxSingleBarrierOption.of(VANILLA_OPTION, BARRIER)).premium(AdjustablePayment.of(CurrencyAmount.of(EUR, NOTIONAL * 0.01), date(2014, 11, 13))).build();

            coverImmutableBean(test1);
            coverBeanEquals(test1, test2);
        }