Ejemplo n.º 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 = (ResolvedBill)newValue;
                    break;

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

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

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
Ejemplo n.º 2
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(ResolvedBillTrade beanToCopy)
 {
     this.info_Renamed       = beanToCopy.Info;
     this.product_Renamed    = beanToCopy.Product;
     this.quantity_Renamed   = beanToCopy.Quantity;
     this.settlement_Renamed = beanToCopy.settlement;
 }
Ejemplo n.º 3
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 ResolvedBillTrade(PortfolioItemInfo info, ResolvedBill product, double quantity, Payment settlement)
 {
     JodaBeanUtils.notNull(info, "info");
     JodaBeanUtils.notNull(product, "product");
     this.info       = info;
     this.product    = product;
     this.quantity   = quantity;
     this.settlement = settlement;
 }
Ejemplo n.º 4
0
        public ResolvedBillTrade resolve(ReferenceData refData)
        {
            ResolvedBill   resolvedProduct = product.resolve(refData);
            CurrencyAmount settleAmount    = product.Notional.Value.multipliedBy(-price * quantity);
            LocalDate      settlementDate  = calculateSettlementDate(refData);
            Payment        settlement      = Payment.of(settleAmount, settlementDate);

            return(ResolvedBillTrade.builder().info(info).product(resolvedProduct).quantity(quantity).settlement(settlement).build());
        }
Ejemplo n.º 5
0
        //-------------------------------------------------------------------------
        public virtual void test_resolve()
        {
            ResolvedBill resolved = US_BILL.resolve(REF_DATA);

            assertEquals(resolved.DayCount, DAY_COUNT);
            assertEquals(resolved.LegalEntityId, LEGAL_ENTITY);
            assertEquals(resolved.Notional, NOTIONAL.resolve(REF_DATA));
            assertEquals(resolved.SecurityId, SECURITY_ID);
            assertEquals(resolved.SettlementDateOffset, SETTLE);
            assertEquals(resolved.YieldConvention, YIELD_CONVENTION);
        }
        public virtual void yield_from_price_intatmat()
        {
            ResolvedBill bill           = BillTest.US_BILL.toBuilder().yieldConvention(BillYieldConvention.INTEREST_AT_MATURITY).build().resolve(REF_DATA);
            double       price          = 0.99;
            LocalDate    settlementDate = LocalDate.of(2018, 8, 17);
            double       af             = bill.DayCount.relativeYearFraction(settlementDate, bill.Notional.Date);
            double       yieldExpected  = (1.0d / price - 1.0d) / af;
            double       yieldComputed  = bill.yieldFromPrice(price, settlementDate);

            assertEquals(yieldExpected, yieldComputed, TOLERANCE_PRICE);
        }
        public virtual void price_from_yield_intatmat()
        {
            ResolvedBill bill           = BillTest.US_BILL.toBuilder().yieldConvention(BillYieldConvention.INTEREST_AT_MATURITY).build().resolve(REF_DATA);
            double       yield          = 0.01;
            LocalDate    settlementDate = LocalDate.of(2018, 8, 17);
            double       af             = bill.DayCount.relativeYearFraction(settlementDate, bill.Notional.Date);
            double       priceExpected  = 1.0d / (1 + yield * af);
            double       priceComputed  = bill.priceFromYield(yield, settlementDate);

            assertEquals(priceExpected, priceComputed, TOLERANCE_PRICE);
        }
        public virtual void yield_from_price_discount()
        {
            ResolvedBill bill           = sut();
            double       price          = 0.99;
            LocalDate    settlementDate = LocalDate.of(2018, 8, 17);
            double       af             = bill.DayCount.relativeYearFraction(settlementDate, bill.Notional.Date);
            double       yieldExpected  = (1.0d - price) / af;
            double       yieldComputed  = bill.yieldFromPrice(price, settlementDate);

            assertEquals(yieldExpected, yieldComputed, TOLERANCE_PRICE);
        }
        //-------------------------------------------------------------------------
        public virtual void price_from_yield_discount()
        {
            ResolvedBill bill           = sut();
            double       yield          = 0.01;
            LocalDate    settlementDate = LocalDate.of(2018, 8, 17);
            double       af             = bill.DayCount.relativeYearFraction(settlementDate, bill.Notional.Date);
            double       priceExpected  = 1.0d - yield * af;
            double       priceComputed  = bill.priceFromYield(yield, settlementDate);

            assertEquals(priceExpected, priceComputed, TOLERANCE_PRICE);
        }
        //-------------------------------------------------------------------------
        public virtual void test_getters()
        {
            ResolvedBill test = sut();

            assertEquals(test.SecurityId, BillTest.US_BILL.SecurityId);
            assertEquals(test.Currency, BillTest.US_BILL.Currency);
            assertEquals(test.Notional, BillTest.US_BILL.Notional.resolve(REF_DATA));
            assertEquals(test.DayCount, BillTest.US_BILL.DayCount);
            assertEquals(test.YieldConvention, BillTest.US_BILL.YieldConvention);
            assertEquals(test.LegalEntityId, BillTest.US_BILL.LegalEntityId);
            assertEquals(test.SettlementDateOffset, BillTest.US_BILL.SettlementDateOffset);
        }
Ejemplo n.º 11
0
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         ResolvedBill other = (ResolvedBill)obj;
         return(JodaBeanUtils.equal(securityId, other.securityId) && JodaBeanUtils.equal(notional, other.notional) && JodaBeanUtils.equal(dayCount, other.dayCount) && JodaBeanUtils.equal(yieldConvention, other.yieldConvention) && JodaBeanUtils.equal(legalEntityId, other.legalEntityId) && JodaBeanUtils.equal(settlementDateOffset, other.settlementDateOffset));
     }
     return(false);
 }
Ejemplo n.º 12
0
        public ResolvedBillTrade resolve(ReferenceData refData)
        {
            ResolvedBill resolved = product.resolve(refData);

            return(new ResolvedBillTrade(info, resolved, Quantity, null));
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Sets the resolved bill 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(ResolvedBill product)
 {
     JodaBeanUtils.notNull(product, "product");
     this.product_Renamed = product;
     return(this);
 }