//------------------------------------------------------------------------- public virtual void test_summarize() { BondFutureTrade trade = sut(); PortfolioItemSummary expected = PortfolioItemSummary.builder().id(TRADE_INFO.Id.orElse(null)).portfolioItemType(PortfolioItemType.TRADE).productType(ProductType.BOND_FUTURE).currencies(Currency.USD).description("BondFuture x 1234").build(); assertEquals(trade.summarize(), expected); }
//------------------------------------------------------------------------- public virtual void test_getters() { ResolvedBondFutureTrade test = sut(); BondFutureTrade @base = BondFutureTradeTest.sut(); assertEquals(test.TradedPrice.get(), TradedPrice.of(@base.Info.TradeDate.get(), @base.Price)); }
public virtual void test_withPrice() { BondFutureTrade @base = sut(); double price = 1.5d; BondFutureTrade computed = @base.withPrice(price); BondFutureTrade expected = BondFutureTrade.builder().info(TRADE_INFO).product(FUTURE).quantity(QUANTITY).price(price).build(); assertEquals(computed, expected); }
//------------------------------------------------------------------------- public virtual void test_withQuantity() { BondFutureTrade @base = sut(); double quantity = 366d; BondFutureTrade computed = @base.withQuantity(quantity); BondFutureTrade expected = BondFutureTrade.builder().info(TRADE_INFO).product(FUTURE).quantity(quantity).price(PRICE).build(); assertEquals(computed, expected); }
//------------------------------------------------------------------------- public virtual void test_builder() { BondFutureTrade test = sut(); assertEquals(test.Info, TRADE_INFO); assertEquals(test.Product, FUTURE); assertEquals(test.Quantity, QUANTITY); assertEquals(test.Price, PRICE); assertEquals(test.withInfo(TRADE_INFO).Info, TRADE_INFO); assertEquals(test.withQuantity(129).Quantity, 129d, 0d); assertEquals(test.withPrice(129).Price, 129d, 0d); }
public override bool Equals(object obj) { if (obj == this) { return(true); } if (obj != null && obj.GetType() == this.GetType()) { BondFutureTrade other = (BondFutureTrade)obj; return(JodaBeanUtils.equal(info, other.info) && JodaBeanUtils.equal(product, other.product) && JodaBeanUtils.equal(quantity, other.quantity) && JodaBeanUtils.equal(price, other.price)); } 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); }
internal static BondFutureTrade sut2() { return(BondFutureTrade.builder().info(TRADE_INFO2).product(FUTURE2).quantity(QUANTITY2).price(PRICE2).build()); }