Example #1
0
        //-------------------------------------------------------------------------
        public virtual void test_summarize()
        {
            OvernightFuturePosition test     = OvernightFuturePosition.builder().info(POSITION_INFO).product(PRODUCT).longQuantity(QUANTITY).build();
            PortfolioItemSummary    expected = PortfolioItemSummary.builder().id(POSITION_INFO.Id.orElse(null)).portfolioItemType(PortfolioItemType.POSITION).productType(ProductType.OVERNIGHT_FUTURE).currencies(Currency.USD).description("OnFuture x 10").build();

            assertEquals(test.summarize(), expected);
        }
Example #2
0
        //-------------------------------------------------------------------------
        public virtual void test_resolve()
        {
            OvernightFuturePosition      @base    = OvernightFuturePosition.builder().info(POSITION_INFO).product(PRODUCT).longQuantity(QUANTITY).build();
            ResolvedOvernightFutureTrade expected = ResolvedOvernightFutureTrade.builder().info(POSITION_INFO).product(PRODUCT.resolve(REF_DATA)).quantity(QUANTITY).build();

            assertEquals(@base.resolve(REF_DATA), expected);
        }
Example #3
0
        //-------------------------------------------------------------------------
        public virtual void test_withQuantity()
        {
            OvernightFuturePosition @base = OvernightFuturePosition.builder().info(POSITION_INFO).product(PRODUCT).longQuantity(QUANTITY).build();
            double quantity = 75343d;
            OvernightFuturePosition computed = @base.withQuantity(quantity);
            OvernightFuturePosition expected = OvernightFuturePosition.builder().info(POSITION_INFO).product(PRODUCT).longQuantity(quantity).build();

            assertEquals(computed, expected);
        }
Example #4
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            OvernightFuturePosition test1 = OvernightFuturePosition.builder().info(POSITION_INFO).product(PRODUCT).longQuantity(QUANTITY).build();

            coverImmutableBean(test1);
            OvernightFuturePosition test2 = OvernightFuturePosition.builder().info(POSITION_INFO2).product(PRODUCT2).longQuantity(100).shortQuantity(50).build();

            coverBeanEquals(test1, test2);
        }
Example #5
0
        //-------------------------------------------------------------------------
        public virtual void test_builder()
        {
            OvernightFuturePosition test = OvernightFuturePosition.builder().info(POSITION_INFO).product(PRODUCT).longQuantity(QUANTITY).build();

            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())
     {
         OvernightFuturePosition other = (OvernightFuturePosition)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()
        {
            OvernightFutureSecurity test = sut();

            assertEquals(test.createProduct(ReferenceData.empty()), PRODUCT);
            TradeInfo            tradeInfo     = TradeInfo.of(date(2016, 6, 30));
            OvernightFutureTrade expectedTrade = OvernightFutureTrade.builder().info(tradeInfo).product(PRODUCT).quantity(100).price(0.995).build();

            assertEquals(test.createTrade(tradeInfo, 100, 0.995, ReferenceData.empty()), expectedTrade);

            PositionInfo            positionInfo      = PositionInfo.empty();
            OvernightFuturePosition expectedPosition1 = OvernightFuturePosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).build();

            TestHelper.assertEqualsBean(test.createPosition(positionInfo, 100, ReferenceData.empty()), expectedPosition1);
            OvernightFuturePosition expectedPosition2 = OvernightFuturePosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).shortQuantity(50).build();

            assertEquals(test.createPosition(positionInfo, 100, 50, ReferenceData.empty()), expectedPosition2);
        }
Example #8
0
        public virtual void test_serialization()
        {
            OvernightFuturePosition test = OvernightFuturePosition.builder().info(POSITION_INFO).product(PRODUCT).longQuantity(QUANTITY).build();

            assertSerialization(test);
        }
Example #9
0
 public OvernightFuturePosition createPosition(PositionInfo positionInfo, double longQuantity, double shortQuantity, ReferenceData refData)
 {
     return(OvernightFuturePosition.ofLongShort(positionInfo, createProduct(refData), longQuantity, shortQuantity));
 }
Example #10
0
 public OvernightFuturePosition createPosition(PositionInfo positionInfo, double quantity, ReferenceData refData)
 {
     return(OvernightFuturePosition.ofNet(positionInfo, createProduct(refData), quantity));
 }
 public OvernightFuturePosition withQuantity(double quantity)
 {
     return(OvernightFuturePosition.ofNet(info, product, quantity));
 }