コード例 #1
0
        //-------------------------------------------------------------------------
        public virtual void test_methods()
        {
            Position test = sut();

            assertEquals(test.Id, null);
            assertEquals(test.Info, PositionInfo.empty());
            assertEquals(test.Quantity, 123d);
            assertEquals(test.SecurityId, SecurityId.of(STANDARD_ID));
        }
コード例 #2
0
        public virtual void test_ofLongShort_noInfo()
        {
            GenericSecurityPosition test = GenericSecurityPosition.ofLongShort(SECURITY, LONG_QUANTITY, SHORT_QUANTITY);

            assertEquals(test.Info, PositionInfo.empty());
            assertEquals(test.Security, SECURITY);
            assertEquals(test.LongQuantity, LONG_QUANTITY);
            assertEquals(test.ShortQuantity, SHORT_QUANTITY);
            assertEquals(test.Quantity, QUANTITY);
        }
コード例 #3
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);
        }
コード例 #4
0
        //-------------------------------------------------------------------------
        public virtual void test_of()
        {
            GenericSecurity test = sut();

            assertEquals(test.Info, INFO);
            assertEquals(test.SecurityId, INFO.Id);
            assertEquals(test.Currency, INFO.PriceInfo.Currency);
            assertEquals(test.UnderlyingIds, ImmutableSet.of());
            assertEquals(test, GenericSecurity.of(INFO));
            assertEquals(test.createProduct(ReferenceData.empty()), test);
            assertEquals(test.createTrade(TradeInfo.empty(), 1, 2, ReferenceData.empty()), GenericSecurityTrade.of(TradeInfo.empty(), GenericSecurity.of(INFO), 1, 2));
            assertEquals(test.createPosition(PositionInfo.empty(), 1, ReferenceData.empty()), GenericSecurityPosition.ofNet(PositionInfo.empty(), GenericSecurity.of(INFO), 1));
            assertEquals(test.createPosition(PositionInfo.empty(), 1, 2, ReferenceData.empty()), GenericSecurityPosition.ofLongShort(PositionInfo.empty(), GenericSecurity.of(INFO), 1, 2));
        }
コード例 #5
0
        //-------------------------------------------------------------------------
        public virtual void test_ofNet_noInfo()
        {
            GenericSecurityPosition test = GenericSecurityPosition.ofNet(SECURITY, QUANTITY);

            assertEquals(test.Info, PositionInfo.empty());
            assertEquals(test.Security, SECURITY);
            assertEquals(test.LongQuantity, QUANTITY);
            assertEquals(test.ShortQuantity, 0d);
            assertEquals(test.Quantity, QUANTITY);
            assertEquals(test.Product, SECURITY);
            assertEquals(test.SecurityId, SECURITY.SecurityId);
            assertEquals(test.Currency, SECURITY.Currency);
            assertEquals(test.withInfo(POSITION_INFO).Info, POSITION_INFO);
            assertEquals(test.withQuantity(129).Quantity, 129d, 0d);
            assertEquals(test.withQuantity(-129).Quantity, -129d, 0d);
        }
コード例 #6
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance from the security and net quantity.
 /// <para>
 /// The net quantity is the long quantity minus the short quantity, which may be negative.
 /// If the quantity is positive it is treated as a long quantity.
 /// Otherwise it is treated as a short quantity.
 ///
 /// </para>
 /// </summary>
 /// <param name="security">  the underlying security </param>
 /// <param name="netQuantity">  the net quantity of the underlying security </param>
 /// <returns> the position </returns>
 public static GenericSecurityPosition ofNet(GenericSecurity security, double netQuantity)
 {
     return(ofNet(PositionInfo.empty(), security, netQuantity));
 }
コード例 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ImmutableDefaults private static void applyDefaults(Builder builder)
        private static void applyDefaults(Builder builder)
        {
            builder.info_Renamed = PositionInfo.empty();
        }
コード例 #8
0
 /// <summary>
 /// Obtains an instance from the security, long quantity and short quantity.
 /// <para>
 /// The long quantity and short quantity must be zero or positive, not negative.
 /// In many cases, only a long quantity or short quantity will be present with the other set to zero.
 /// However it is also possible for both to be non-zero, allowing long and short positions to be treated separately.
 ///
 /// </para>
 /// </summary>
 /// <param name="security">  the underlying security </param>
 /// <param name="longQuantity">  the long quantity of the underlying security </param>
 /// <param name="shortQuantity">  the short quantity of the underlying security </param>
 /// <returns> the position </returns>
 public static GenericSecurityPosition ofLongShort(GenericSecurity security, double longQuantity, double shortQuantity)
 {
     return(ofLongShort(PositionInfo.empty(), security, longQuantity, shortQuantity));
 }
コード例 #9
0
 internal static GenericSecurityPosition sut2()
 {
     return(GenericSecurityPosition.builder().info(PositionInfo.empty()).security(SECURITY2).longQuantity(LONG_QUANTITY2).shortQuantity(SHORT_QUANTITY2).build());
 }
コード例 #10
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance from the security identifier and net quantity.
 /// <para>
 /// The net quantity is the long quantity minus the short quantity, which may be negative.
 /// If the quantity is positive it is treated as a long quantity.
 /// Otherwise it is treated as a short quantity.
 ///
 /// </para>
 /// </summary>
 /// <param name="securityId">  the identifier of the underlying security </param>
 /// <param name="netQuantity">  the net quantity of the underlying security </param>
 /// <returns> the position </returns>
 public static SecurityPosition ofNet(SecurityId securityId, double netQuantity)
 {
     return(ofNet(PositionInfo.empty(), securityId, netQuantity));
 }