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 = (CapitalIndexedBond)newValue;
                    break;

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

                case 106934601:         // price
                    this.price_Renamed = (double?)newValue.Value;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
 public virtual void test_builder_fail()
 {
     // negative settlement date offset
     assertThrowsIllegalArg(() => CapitalIndexedBond.builder().securityId(SECURITY_ID).notional(NOTIONAL).currency(USD).dayCount(ACT_ACT_ISDA).rateCalculation(RATE_CALC).exCouponPeriod(EX_COUPON).legalEntityId(LEGAL_ENTITY).yieldConvention(US_IL_REAL).settlementDateOffset(DaysAdjustment.ofBusinessDays(-2, USNY)).accrualSchedule(SCHEDULE).build());
     // positive ex-coupon days
     assertThrowsIllegalArg(() => CapitalIndexedBond.builder().securityId(SECURITY_ID).notional(NOTIONAL).currency(USD).dayCount(ACT_ACT_ISDA).rateCalculation(RATE_CALC).exCouponPeriod(DaysAdjustment.ofCalendarDays(7, BusinessDayAdjustment.of(BusinessDayConventions.FOLLOWING, USNY))).legalEntityId(LEGAL_ENTITY).yieldConvention(US_IL_REAL).settlementDateOffset(SETTLE_OFFSET).accrualSchedule(SCHEDULE).build());
 }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(CapitalIndexedBondTrade beanToCopy)
 {
     this.info_Renamed     = beanToCopy.Info;
     this.product_Renamed  = beanToCopy.Product;
     this.quantity_Renamed = beanToCopy.Quantity;
     this.price_Renamed    = beanToCopy.Price;
 }
Пример #4
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 3237038:         // info
                    this.info_Renamed = (PositionInfo)newValue;
                    break;

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

                case 611668775:         // longQuantity
                    this.longQuantity_Renamed = (double?)newValue.Value;
                    break;

                case -2094395097:         // shortQuantity
                    this.shortQuantity_Renamed = (double?)newValue.Value;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
Пример #5
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(CapitalIndexedBondPosition beanToCopy)
 {
     this.info_Renamed          = beanToCopy.Info;
     this.product_Renamed       = beanToCopy.Product;
     this.longQuantity_Renamed  = beanToCopy.LongQuantity;
     this.shortQuantity_Renamed = beanToCopy.ShortQuantity;
 }
        public virtual void test_builder_min()
        {
            CapitalIndexedBond test = CapitalIndexedBond.builder().securityId(SECURITY_ID).notional(NOTIONAL).currency(USD).dayCount(ACT_ACT_ISDA).rateCalculation(RATE_CALC).legalEntityId(LEGAL_ENTITY).yieldConvention(US_IL_REAL).settlementDateOffset(SETTLE_OFFSET).accrualSchedule(SCHEDULE).build();

            assertEquals(test.SecurityId, SECURITY_ID);
            assertEquals(test.Currency, USD);
            assertEquals(test.DayCount, ACT_ACT_ISDA);
            assertEquals(test.ExCouponPeriod, DaysAdjustment.NONE);
            assertEquals(test.LegalEntityId, LEGAL_ENTITY);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.AccrualSchedule, SCHEDULE);
            assertEquals(test.RateCalculation, RATE_CALC);
            assertEquals(test.SettlementDateOffset, SETTLE_OFFSET);
            assertEquals(test.YieldConvention, US_IL_REAL);
        }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(T target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            CapitalIndexedBond product       = target.Product;
            Currency           currency      = product.Currency;
            SecurityId         securityId    = product.SecurityId;
            LegalEntityId      legalEntityId = product.LegalEntityId;

            // use lookup to build requirements
            RatesMarketDataLookup ratesLookup = parameters.getParameter(typeof(RatesMarketDataLookup));
            FunctionRequirements  ratesReqs   = ratesLookup.requirements(ImmutableSet.of(), ImmutableSet.of(product.RateCalculation.Index));
            LegalEntityDiscountingMarketDataLookup ledLookup = parameters.getParameter(typeof(LegalEntityDiscountingMarketDataLookup));
            FunctionRequirements ledReqs = ledLookup.requirements(securityId, legalEntityId, currency);

            return(ratesReqs.combinedWith(ledReqs));
        }
        public virtual void test_builder_full()
        {
            CapitalIndexedBond test = sut();

            assertEquals(test.SecurityId, SECURITY_ID);
            assertEquals(test.Currency, USD);
            assertEquals(test.DayCount, ACT_ACT_ISDA);
            assertEquals(test.ExCouponPeriod, EX_COUPON);
            assertEquals(test.LegalEntityId, LEGAL_ENTITY);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.AccrualSchedule, SCHEDULE);
            assertEquals(test.RateCalculation, RATE_CALC);
            assertEquals(test.FirstIndexValue, RATE_CALC.FirstIndexValue.Value);
            assertEquals(test.SettlementDateOffset, SETTLE_OFFSET);
            assertEquals(test.YieldConvention, US_IL_REAL);
        }
        public virtual void test_resolve()
        {
            CapitalIndexedBond @base = sut();

            LocalDate[] unAdjDates = new LocalDate[] { LocalDate.of(2008, 1, 13), LocalDate.of(2008, 7, 13), LocalDate.of(2009, 1, 13), LocalDate.of(2009, 7, 13), LocalDate.of(2010, 1, 13) };
            CapitalIndexedBondPaymentPeriod[] periodic = new CapitalIndexedBondPaymentPeriod[4];
            for (int i = 0; i < 4; ++i)
            {
                LocalDate       start      = SCHEDULE_ADJ.adjust(unAdjDates[i], REF_DATA);
                LocalDate       end        = SCHEDULE_ADJ.adjust(unAdjDates[i + 1], REF_DATA);
                LocalDate       detachment = EX_COUPON.adjust(end, REF_DATA);
                RateComputation comp       = RATE_CALC.createRateComputation(end);
                periodic[i] = CapitalIndexedBondPaymentPeriod.builder().currency(USD).startDate(start).endDate(end).unadjustedStartDate(unAdjDates[i]).unadjustedEndDate(unAdjDates[i + 1]).detachmentDate(detachment).realCoupon(COUPONS[i]).rateComputation(comp).notional(NOTIONAL).build();
            }
            CapitalIndexedBondPaymentPeriod nominalExp = periodic[3].withUnitCoupon(periodic[0].StartDate, periodic[0].UnadjustedStartDate);
            ResolvedCapitalIndexedBond      expected   = ResolvedCapitalIndexedBond.builder().securityId(SECURITY_ID).dayCount(ACT_ACT_ISDA).legalEntityId(LEGAL_ENTITY).nominalPayment(nominalExp).periodicPayments(periodic).frequency(SCHEDULE.Frequency).rollConvention(SCHEDULE.calculatedRollConvention()).settlementDateOffset(SETTLE_OFFSET).yieldConvention(US_IL_REAL).rateCalculation(@base.RateCalculation).build();

            assertEquals(@base.resolve(REF_DATA), expected);
        }
 internal static CapitalIndexedBondSecurity createSecurity(CapitalIndexedBond product)
 {
     return(CapitalIndexedBondSecurity.builder().info(SecurityInfo.of(product.SecurityId, INFO.PriceInfo)).currency(product.Currency).notional(product.Notional).accrualSchedule(product.AccrualSchedule).rateCalculation(product.RateCalculation).dayCount(product.DayCount).yieldConvention(product.YieldConvention).legalEntityId(product.LegalEntityId).settlementDateOffset(product.SettlementDateOffset).exCouponPeriod(product.ExCouponPeriod).build());
 }
 /// <summary>
 /// Sets the bond that was traded.
 /// <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(CapitalIndexedBond product)
 {
     JodaBeanUtils.notNull(product, "product");
     this.product_Renamed = product;
     return(this);
 }
 internal static CapitalIndexedBond sut2()
 {
     return(CapitalIndexedBond.builder().securityId(SECURITY_ID2).notional(5.0e7).currency(GBP).dayCount(NL_365).rateCalculation(InflationRateCalculation.builder().index(GB_RPI).lag(Period.ofMonths(2)).indexCalculationMethod(INTERPOLATED).firstIndexValue(124.556).build()).exCouponPeriod(EX_COUPON).legalEntityId(LegalEntityId.of("OG-Ticker", "US-Govt-1")).yieldConvention(GB_IL_FLOAT).settlementDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).accrualSchedule(PeriodicSchedule.of(START, END, FREQUENCY, BusinessDayAdjustment.of(BusinessDayConventions.FOLLOWING, GBLO), StubConvention.NONE, RollConventions.NONE)).build());
 }
 internal static CapitalIndexedBond sut1()
 {
     return(CapitalIndexedBond.builder().securityId(SECURITY_ID).notional(NOTIONAL).currency(USD).dayCount(ACT_ACT_ISDA).rateCalculation(RATE_CALC).exCouponPeriod(EX_COUPON).legalEntityId(LEGAL_ENTITY).yieldConvention(GB_IL_FLOAT).settlementDateOffset(SETTLE_OFFSET).accrualSchedule(SCHEDULE).build());
 }