//------------------------------------------------------------------------- public virtual void test_summarize() { BondFuturePosition tes = sut(); PortfolioItemSummary expected = PortfolioItemSummary.builder().id(POSITION_INFO.Id.orElse(null)).portfolioItemType(PortfolioItemType.POSITION).productType(ProductType.BOND_FUTURE).currencies(Currency.USD).description("BondFuture x 10").build(); assertEquals(tes.summarize(), expected); }
//------------------------------------------------------------------------- public virtual void test_withQuantity() { BondFuturePosition @base = sut(); double quantity = 75343d; BondFuturePosition computed = @base.withQuantity(quantity); BondFuturePosition expected = BondFuturePosition.builder().info(POSITION_INFO).product(PRODUCT).longQuantity(quantity).build(); assertEquals(computed, expected); }
//------------------------------------------------------------------------- public virtual void test_builder_resolved() { BondFuturePosition test = sut(); assertEquals(test.Product, PRODUCT); assertEquals(test.Info, POSITION_INFO); assertEquals(test.LongQuantity, QUANTITY, 0d); assertEquals(test.ShortQuantity, 0d, 0d); assertEquals(test.Quantity, QUANTITY, 0d); assertEquals(test.withInfo(POSITION_INFO).Info, POSITION_INFO); assertEquals(test.withQuantity(129).Quantity, 129d, 0d); }
public override bool Equals(object obj) { if (obj == this) { return(true); } if (obj != null && obj.GetType() == this.GetType()) { BondFuturePosition other = (BondFuturePosition)obj; return(JodaBeanUtils.equal(info, other.info) && JodaBeanUtils.equal(product, other.product) && JodaBeanUtils.equal(longQuantity, other.longQuantity) && JodaBeanUtils.equal(shortQuantity, other.shortQuantity)); } return(false); }
//------------------------------------------------------------------------- public virtual void test_createProduct() { BondFutureSecurity test = sut(); ImmutableList <FixedCouponBond> basket = PRODUCT.DeliveryBasket; FixedCouponBondSecurity bondSec0 = FixedCouponBondSecurityTest.createSecurity(PRODUCT.DeliveryBasket.get(0)); FixedCouponBondSecurity bondSec1 = FixedCouponBondSecurityTest.createSecurity(PRODUCT.DeliveryBasket.get(1)); ReferenceData refData = ImmutableReferenceData.of(ImmutableMap.of(basket.get(0).SecurityId, bondSec0, basket.get(1).SecurityId, bondSec1)); BondFuture product = test.createProduct(refData); assertEquals(product.DeliveryBasket.get(0), PRODUCT.DeliveryBasket.get(0)); assertEquals(product.DeliveryBasket.get(1), PRODUCT.DeliveryBasket.get(1)); TradeInfo tradeInfo = TradeInfo.of(date(2016, 6, 30)); BondFutureTrade expectedTrade = BondFutureTrade.builder().info(tradeInfo).product(product).quantity(100).price(123.50).build(); assertEquals(test.createTrade(tradeInfo, 100, 123.50, refData), expectedTrade); PositionInfo positionInfo = PositionInfo.empty(); BondFuturePosition expectedPosition1 = BondFuturePosition.builder().info(positionInfo).product(product).longQuantity(100).build(); TestHelper.assertEqualsBean(test.createPosition(positionInfo, 100, refData), expectedPosition1); BondFuturePosition expectedPosition2 = BondFuturePosition.builder().info(positionInfo).product(product).longQuantity(100).shortQuantity(50).build(); assertEquals(test.createPosition(positionInfo, 100, 50, refData), expectedPosition2); }
public BondFuturePosition withQuantity(double quantity) { return(BondFuturePosition.ofNet(info, product, quantity)); }
internal static BondFuturePosition sut2() { return(BondFuturePosition.builder().info(POSITION_INFO2).product(PRODUCT2).longQuantity(100).shortQuantity(50).build()); }
//------------------------------------------------------------------------- internal static BondFuturePosition sut() { return(BondFuturePosition.builder().info(POSITION_INFO).product(PRODUCT).longQuantity(QUANTITY).build()); }