Exemple #1
0
        //-------------------------------------------------------------------------
        public virtual void test_summarize()
        {
            SecurityPosition     trade    = sut();
            PortfolioItemSummary expected = PortfolioItemSummary.builder().id(POSITION_INFO.Id.orElse(null)).portfolioItemType(PortfolioItemType.POSITION).productType(ProductType.SECURITY).description("Id x 100").build();

            assertEquals(trade.summarize(), expected);
        }
Exemple #2
0
        //-------------------------------------------------------------------------
        public virtual void test_resolveTarget()
        {
            SecurityPosition        position         = sut();
            GenericSecurity         resolvedSecurity = GenericSecurity.of(SecurityInfo.of(SECURITY_ID, 1, CurrencyAmount.of(USD, 0.01)));
            ImmutableReferenceData  refData          = ImmutableReferenceData.of(SECURITY_ID, resolvedSecurity);
            GenericSecurityPosition expected         = GenericSecurityPosition.ofLongShort(POSITION_INFO, resolvedSecurity, LONG_QUANTITY, SHORT_QUANTITY);

            assertEquals(position.resolveTarget(refData), expected);
        }
Exemple #3
0
        public virtual void test_ofLongShort_withInfo()
        {
            SecurityPosition test = SecurityPosition.ofLongShort(POSITION_INFO, SECURITY_ID, LONG_QUANTITY, SHORT_QUANTITY);

            assertEquals(test.Info, POSITION_INFO);
            assertEquals(test.SecurityId, SECURITY_ID);
            assertEquals(test.LongQuantity, LONG_QUANTITY);
            assertEquals(test.ShortQuantity, SHORT_QUANTITY);
            assertEquals(test.Quantity, QUANTITY);
        }
Exemple #4
0
        public virtual void test_ofLongShort_noInfo()
        {
            SecurityPosition test = SecurityPosition.ofLongShort(SECURITY_ID, LONG_QUANTITY, SHORT_QUANTITY);

            assertEquals(test.Info, PositionInfo.empty());
            assertEquals(test.SecurityId, SECURITY_ID);
            assertEquals(test.LongQuantity, LONG_QUANTITY);
            assertEquals(test.ShortQuantity, SHORT_QUANTITY);
            assertEquals(test.Quantity, QUANTITY);
        }
Exemple #5
0
        public virtual void test_ofNet_withInfo_negative()
        {
            SecurityPosition test = SecurityPosition.ofNet(POSITION_INFO, SECURITY_ID, -100d);

            assertEquals(test.Info, POSITION_INFO);
            assertEquals(test.SecurityId, SECURITY_ID);
            assertEquals(test.LongQuantity, 0d);
            assertEquals(test.ShortQuantity, 100d);
            assertEquals(test.Quantity, -100d);
        }
Exemple #6
0
        public virtual void test_builder()
        {
            SecurityPosition test = sut();

            assertEquals(test.Info, POSITION_INFO);
            assertEquals(test.SecurityId, SECURITY_ID);
            assertEquals(test.LongQuantity, LONG_QUANTITY);
            assertEquals(test.ShortQuantity, SHORT_QUANTITY);
            assertEquals(test.Quantity, QUANTITY);
        }
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         SecurityPosition other = (SecurityPosition)obj;
         return(JodaBeanUtils.equal(info, other.info) && JodaBeanUtils.equal(securityId, other.securityId) && JodaBeanUtils.equal(longQuantity, other.longQuantity) && JodaBeanUtils.equal(shortQuantity, other.shortQuantity));
     }
     return(false);
 }
Exemple #8
0
        //-------------------------------------------------------------------------
        public virtual void test_ofNet_noInfo()
        {
            SecurityPosition test = SecurityPosition.ofNet(SECURITY_ID, QUANTITY);

            assertEquals(test.Info, PositionInfo.empty());
            assertEquals(test.SecurityId, SECURITY_ID);
            assertEquals(test.LongQuantity, QUANTITY);
            assertEquals(test.ShortQuantity, 0d);
            assertEquals(test.Quantity, QUANTITY);
            assertEquals(test.withInfo(POSITION_INFO).Info, POSITION_INFO);
            assertEquals(test.withQuantity(129).Quantity, 129d, 0d);
            assertEquals(test.withQuantity(-129).Quantity, -129d, 0d);
        }
 public SecurityPosition withQuantity(double quantity)
 {
     return(SecurityPosition.ofNet(info, securityId, quantity));
 }
Exemple #10
0
 internal static SecurityPosition sut2()
 {
     return(SecurityPosition.builder().info(PositionInfo.empty()).securityId(SECURITY_ID2).longQuantity(LONG_QUANTITY2).shortQuantity(SHORT_QUANTITY2).build());
 }
Exemple #11
0
 //-------------------------------------------------------------------------
 internal static SecurityPosition sut()
 {
     return(SecurityPosition.builder().info(POSITION_INFO).securityId(SECURITY_ID).longQuantity(LONG_QUANTITY).shortQuantity(SHORT_QUANTITY).build());
 }