//-------------------------------------------------------------------------
        public virtual void test_summarize()
        {
            DsfTrade             trade    = sut();
            PortfolioItemSummary expected = PortfolioItemSummary.builder().id(TRADE_INFO.Id.orElse(null)).portfolioItemType(PortfolioItemType.TRADE).productType(ProductType.DSF).currencies(Currency.USD).description("DSF x 100").build();

            assertEquals(trade.summarize(), expected);
        }
        //-------------------------------------------------------------------------
        public virtual void test_resolve()
        {
            DsfTrade         test     = sut();
            ResolvedDsfTrade expected = ResolvedDsfTrade.builder().info(TRADE_INFO).product(PRODUCT.resolve(REF_DATA)).quantity(QUANTITY).tradedPrice(TradedPrice.of(TRADE_DATE, PRICE)).build();

            assertEquals(test.resolve(REF_DATA), expected);
        }
        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);
        }
Exemplo n.º 5
0
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         DsfTrade other = (DsfTrade)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_builder()
        {
            DsfTrade test = sut();

            assertEquals(test.Info, TRADE_INFO);
            assertEquals(test.Product, PRODUCT);
            assertEquals(test.Quantity, QUANTITY);
            assertEquals(test.Price, PRICE);
            assertEquals(test.SecurityId, PRODUCT.SecurityId);
            assertEquals(test.Currency, PRODUCT.Currency);
            assertEquals(test.withInfo(TRADE_INFO).Info, TRADE_INFO);
            assertEquals(test.withQuantity(129).Quantity, 129d, 0d);
            assertEquals(test.withPrice(129).Price, 129d, 0d);
        }
        //-------------------------------------------------------------------------
        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());
 }