예제 #1
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 3237038:         // info
                    this.info_Renamed = (PortfolioItemInfo)newValue;
                    break;

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

                case -1285004149:         // quantity
                    this.quantity_Renamed = (double?)newValue.Value;
                    break;

                case 73828649:         // settlement
                    this.settlement_Renamed = (ResolvedFixedCouponBondSettlement)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
        //-------------------------------------------------------------------------
        public virtual void test_yearFraction()
        {
            ResolvedFixedCouponBond      test   = sut();
            FixedCouponBondPaymentPeriod period = test.PeriodicPayments.get(0);

            assertEquals(test.yearFraction(period.UnadjustedStartDate, period.UnadjustedEndDate), period.YearFraction);
        }
예제 #3
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(ResolvedFixedCouponBondTrade beanToCopy)
 {
     this.info_Renamed       = beanToCopy.Info;
     this.product_Renamed    = beanToCopy.Product;
     this.quantity_Renamed   = beanToCopy.Quantity;
     this.settlement_Renamed = beanToCopy.settlement;
 }
        public ResolvedFixedCouponBondTrade resolve(ReferenceData refData)
        {
            ResolvedFixedCouponBond resolved = Product.resolve(refData);
            LocalDate settlementDate         = calculateSettlementDate(refData);

            return(ResolvedFixedCouponBondTrade.builder().info(info).product(resolved).quantity(quantity).settlement(ResolvedFixedCouponBondSettlement.of(settlementDate, price)).build());
        }
예제 #5
0
        public virtual void test_resolve()
        {
            FixedCouponBond         @base    = sut();
            ResolvedFixedCouponBond resolved = @base.resolve(REF_DATA);

            assertEquals(resolved.LegalEntityId, LEGAL_ENTITY);
            assertEquals(resolved.SettlementDateOffset, DATE_OFFSET);
            assertEquals(resolved.YieldConvention, YIELD_CONVENTION);
            ImmutableList <FixedCouponBondPaymentPeriod> periodicPayments = resolved.PeriodicPayments;
            int expNum = 20;

            assertEquals(periodicPayments.size(), expNum);
            LocalDate unadjustedEnd = END_DATE;
            Schedule  unadjusted    = PERIOD_SCHEDULE.createSchedule(REF_DATA).toUnadjusted();

            for (int i = 0; i < expNum; ++i)
            {
                FixedCouponBondPaymentPeriod payment = periodicPayments.get(expNum - 1 - i);
                assertEquals(payment.Currency, EUR);
                assertEquals(payment.Notional, NOTIONAL);
                assertEquals(payment.FixedRate, FIXED_RATE);
                assertEquals(payment.UnadjustedEndDate, unadjustedEnd);
                assertEquals(payment.EndDate, BUSINESS_ADJUST.adjust(unadjustedEnd, REF_DATA));
                assertEquals(payment.PaymentDate, payment.EndDate);
                LocalDate unadjustedStart = unadjustedEnd.minusMonths(6);
                assertEquals(payment.UnadjustedStartDate, unadjustedStart);
                assertEquals(payment.StartDate, BUSINESS_ADJUST.adjust(unadjustedStart, REF_DATA));
                assertEquals(payment.YearFraction, unadjusted.getPeriod(expNum - 1 - i).yearFraction(DAY_COUNT, unadjusted));
                assertEquals(payment.DetachmentDate, EX_COUPON.adjust(payment.PaymentDate, REF_DATA));
                unadjustedEnd = unadjustedStart;
            }
            Payment expectedPayment = Payment.of(CurrencyAmount.of(EUR, NOTIONAL), BUSINESS_ADJUST.adjust(END_DATE, REF_DATA));

            assertEquals(resolved.NominalPayment, expectedPayment);
        }
예제 #6
0
 /// <summary>
 /// Creates an instance. </summary>
 /// <param name="info">  the value of the property, not null </param>
 /// <param name="product">  the value of the property, not null </param>
 /// <param name="quantity">  the value of the property </param>
 /// <param name="settlement">  the value of the property </param>
 internal ResolvedFixedCouponBondTrade(PortfolioItemInfo info, ResolvedFixedCouponBond product, double quantity, ResolvedFixedCouponBondSettlement settlement)
 {
     JodaBeanUtils.notNull(info, "info");
     JodaBeanUtils.notNull(product, "product");
     this.info       = info;
     this.product    = product;
     this.quantity   = quantity;
     this.settlement = settlement;
 }
        //-------------------------------------------------------------------------
        public virtual void test_findPeriod()
        {
            ResolvedFixedCouponBond test = sut();
            ImmutableList <FixedCouponBondPaymentPeriod> payments = test.PeriodicPayments;

            assertEquals(test.findPeriod(test.UnadjustedStartDate), payments.get(0));
            assertEquals(test.findPeriod(test.UnadjustedEndDate.minusDays(1)), payments.get(payments.size() - 1));
            assertEquals(test.findPeriod(LocalDate.MIN), null);
            assertEquals(test.findPeriod(LocalDate.MAX), null);
        }
        //-------------------------------------------------------------------------
        public virtual void test_getters()
        {
            ResolvedFixedCouponBond test = sut();
            ImmutableList <FixedCouponBondPaymentPeriod> payments = test.PeriodicPayments;

            assertEquals(test.StartDate, payments.get(0).StartDate);
            assertEquals(test.EndDate, payments.get(payments.size() - 1).EndDate);
            assertEquals(test.UnadjustedStartDate, payments.get(0).UnadjustedStartDate);
            assertEquals(test.UnadjustedEndDate, payments.get(payments.size() - 1).UnadjustedEndDate);
            assertEquals(test.hasExCouponPeriod(), true);
        }
        public virtual void test_yearFraction_scheduleInfo()
        {
            ResolvedFixedCouponBond      @base  = sut();
            FixedCouponBondPaymentPeriod period = @base.PeriodicPayments.get(0);
            AtomicBoolean           eom         = new AtomicBoolean(false);
            DayCount                dc          = new DayCountAnonymousInnerClass(this, @base, period, eom);
            ResolvedFixedCouponBond test        = @base.toBuilder().dayCount(dc).build();

            assertEquals(test.yearFraction(period.UnadjustedStartDate, period.UnadjustedEndDate), 0.5);
            // test with EOM=true
            ResolvedFixedCouponBond test2 = test.toBuilder().rollConvention(RollConventions.EOM).build();

            eom.set(true);
            assertEquals(test2.yearFraction(period.UnadjustedStartDate, period.UnadjustedEndDate), 0.5);
        }
        public virtual void test_builder_fail()
        {
            ResolvedBondFuture @base = sut();

            // wrong size
            assertThrowsIllegalArg(() => ResolvedBondFuture.builder().securityId(@base.SecurityId).deliveryBasket(@base.DeliveryBasket.subList(0, 1)).conversionFactors(@base.ConversionFactors).firstNoticeDate(@base.FirstNoticeDate).lastNoticeDate(@base.LastNoticeDate).lastTradeDate(@base.LastTradeDate).build());
            // first notice date missing
            assertThrowsIllegalArg(() => ResolvedBondFuture.builder().securityId(@base.SecurityId).deliveryBasket(@base.DeliveryBasket).conversionFactors(@base.ConversionFactors).lastNoticeDate(@base.LastNoticeDate).lastTradeDate(@base.LastTradeDate).build());
            // last notice date missing
            assertThrowsIllegalArg(() => ResolvedBondFuture.builder().securityId(@base.SecurityId).deliveryBasket(@base.DeliveryBasket).conversionFactors(@base.ConversionFactors).firstNoticeDate(@base.FirstNoticeDate).lastTradeDate(@base.LastTradeDate).build());
            // basket list empty
            assertThrowsIllegalArg(() => ResolvedBondFuture.builder().securityId(@base.SecurityId).firstNoticeDate(@base.FirstNoticeDate).lastNoticeDate(@base.LastNoticeDate).lastTradeDate(@base.LastTradeDate).build());
            // notional mismatch
            ResolvedFixedCouponBond bond0 = @base.DeliveryBasket.get(0);
            ResolvedFixedCouponBond bond1 = bond0.toBuilder().nominalPayment(Payment.of(USD, 100, date(2016, 6, 30))).build();

            assertThrowsIllegalArg(() => ResolvedBondFuture.builder().securityId(@base.SecurityId).deliveryBasket(bond0, bond1).conversionFactors(1d, 2d).firstNoticeDate(@base.FirstNoticeDate).firstDeliveryDate(@base.FirstDeliveryDate).lastNoticeDate(@base.LastNoticeDate).lastDeliveryDate(@base.LastDeliveryDate).lastTradeDate(@base.LastTradeDate).rounding(@base.Rounding).build());
        }
        public virtual void coverage_builder()
        {
            ResolvedFixedCouponBond test = sut();

            test.toBuilder().periodicPayments(test.PeriodicPayments.toArray(new FixedCouponBondPaymentPeriod[0])).build();
        }
        public ResolvedFixedCouponBondTrade resolve(ReferenceData refData)
        {
            ResolvedFixedCouponBond resolved = product.resolve(refData);

            return(new ResolvedFixedCouponBondTrade(info, resolved, Quantity, null));
        }
예제 #13
0
 /// <summary>
 /// Sets the resolved fixed coupon bond 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(ResolvedFixedCouponBond product)
 {
     JodaBeanUtils.notNull(product, "product");
     this.product_Renamed = product;
     return(this);
 }