Esempio n. 1
0
 //-----------------------------------------------------------------------
 /// <summary>
 /// Sets the additional position information, defaulted to an empty instance.
 /// <para>
 /// This allows additional information to be attached to the position.
 /// </para>
 /// </summary>
 /// <param name="info">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder info(PositionInfo info)
 {
     JodaBeanUtils.notNull(info, "info");
     this.info_Renamed = info;
     return(this);
 }
Esempio n. 2
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));
 }
Esempio n. 3
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();
        }
Esempio n. 4
0
 //-------------------------------------------------------------------------
 public GenericSecurityPosition withInfo(PositionInfo info)
 {
     return(new GenericSecurityPosition(info, security, longQuantity, shortQuantity));
 }
Esempio n. 5
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));
 }
Esempio n. 6
0
 /// <summary>
 /// Obtains an instance from position information, 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="positionInfo">  the position information </param>
 /// <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(PositionInfo positionInfo, GenericSecurity security, double longQuantity, double shortQuantity)
 {
     return(new GenericSecurityPosition(positionInfo, security, longQuantity, shortQuantity));
 }
Esempio n. 7
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));
        }
        public virtual void test_serialization()
        {
            PositionInfo test = PositionInfo.builder().id(ID).addAttribute(AttributeType.DESCRIPTION, "A").build();

            assertSerialization(test);
        }
 internal static GenericSecurityPosition sut2()
 {
     return(GenericSecurityPosition.builder().info(PositionInfo.empty()).security(SECURITY2).longQuantity(LONG_QUANTITY2).shortQuantity(SHORT_QUANTITY2).build());
 }
 public GenericSecurityPosition createPosition(PositionInfo positionInfo, double longQuantity, double shortQuantity, ReferenceData refData)
 {
     return(GenericSecurityPosition.ofLongShort(positionInfo, this, longQuantity, shortQuantity));
 }
 public GenericSecurityPosition createPosition(PositionInfo tradeInfo, double quantity, ReferenceData refData)
 {
     return(GenericSecurityPosition.ofNet(tradeInfo, this, quantity));
 }
 //-------------------------------------------------------------------------
 /// <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));
 }
 /// <summary>
 /// Obtains an instance from position information, security identifier, 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="positionInfo">  the position information </param>
 /// <param name="securityId">  the identifier of 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 SecurityPosition ofLongShort(PositionInfo positionInfo, SecurityId securityId, double longQuantity, double shortQuantity)
 {
     return(new SecurityPosition(positionInfo, securityId, longQuantity, shortQuantity));
 }