public virtual void test_withPrice() { DsfTrade @base = sut(); double price = 6423d; DsfTrade computed = @base.withPrice(price); DsfTrade expected = DsfTrade.builder().info(TRADE_INFO).product(PRODUCT).quantity(QUANTITY).price(price).build(); assertEquals(computed, expected); }
//------------------------------------------------------------------------- public virtual void test_withQuantity() { DsfTrade @base = sut(); double quantity = 6423d; DsfTrade computed = @base.withQuantity(quantity); DsfTrade expected = DsfTrade.builder().info(TRADE_INFO).product(PRODUCT).quantity(quantity).price(PRICE).build(); assertEquals(computed, expected); }
//------------------------------------------------------------------------- public virtual void test_createProduct() { DsfSecurity test = sut(); assertEquals(test.createProduct(ReferenceData.empty()), PRODUCT); TradeInfo tradeInfo = TradeInfo.of(PRODUCT.LastTradeDate.minusDays(1)); DsfTrade expectedTrade = DsfTrade.builder().info(tradeInfo).product(PRODUCT).quantity(100).price(123.50).build(); assertEquals(test.createTrade(tradeInfo, 100, 123.50, ReferenceData.empty()), expectedTrade); PositionInfo positionInfo = PositionInfo.empty(); DsfPosition expectedPosition1 = DsfPosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).build(); TestHelper.assertEqualsBean(test.createPosition(positionInfo, 100, ReferenceData.empty()), expectedPosition1); DsfPosition expectedPosition2 = DsfPosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).shortQuantity(50).build(); assertEquals(test.createPosition(positionInfo, 100, 50, ReferenceData.empty()), expectedPosition2); }
internal static DsfTrade sut2() { return(DsfTrade.builder().product(PRODUCT2).quantity(QUANTITY2).price(PRICE2).build()); }
//------------------------------------------------------------------------- internal static DsfTrade sut() { return(DsfTrade.builder().info(TRADE_INFO).product(PRODUCT).quantity(QUANTITY).price(PRICE).build()); }