/// <summary>
 /// Initializes a new instance of the <see cref="PositionGroupKey"/> class
 /// </summary>
 /// <param name="buyingPowerModel">The group's buying power model</param>
 /// <param name="positions">The positions comprising the group</param>
 public PositionGroupKey(IPositionGroupBuyingPowerModel buyingPowerModel, IEnumerable <IPosition> positions)
 {
     BuyingPowerModel = buyingPowerModel;
     // these have to be sorted for determinism
     UnitQuantities = positions.Select(p => Tuple.Create(p.Symbol, p.UnitQuantity)).ToImmutableSortedSet();
     IsDefaultGroup = UnitQuantities.Count == 1 && BuyingPowerModel.GetType() == typeof(SecurityPositionGroupBuyingPowerModel);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PositionGroupKey"/> class for groups with a single security
 /// </summary>
 /// <param name="buyingPowerModel">The group's buying power model</param>
 /// <param name="security">The security</param>
 public PositionGroupKey(IPositionGroupBuyingPowerModel buyingPowerModel, Security security)
 {
     IsDefaultGroup   = buyingPowerModel.GetType() == typeof(SecurityPositionGroupBuyingPowerModel);
     BuyingPowerModel = buyingPowerModel;
     UnitQuantities   = new[]
     {
         Tuple.Create(security.Symbol, security.SymbolProperties.LotSize)
     };
 }
Exemple #3
0
        /// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.</returns>
        public virtual bool Equals(IPositionGroupBuyingPowerModel other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(GetType() == other.GetType());
        }