コード例 #1
0
        /// <summary>
        /// Compares this option series to another one by its attributes.
        /// Expiration takes precedence in comparison.
        /// </summary>
        /// <param name="other">another option series to compare with.</param>
        /// <returns>result of comparison.</returns>
        public int CompareTo(OptionSeries other)
        {
            if (Expiration < other.Expiration)
            {
                return(-1);
            }
            if (Expiration > other.Expiration)
            {
                return(1);
            }
            if (LastTrade < other.LastTrade)
            {
                return(-1);
            }
            if (LastTrade > other.LastTrade)
            {
                return(1);
            }
            int i = Multiplier.CompareTo(other.Multiplier);

            if (i != 0)
            {
                return(i);
            }
            i = SPC.CompareTo(other.SPC);
            if (i != 0)
            {
                return(i);
            }
            i = AdditionalUnderlyings.CompareTo(other.AdditionalUnderlyings);
            if (i != 0)
            {
                return(i);
            }
            i = MMY.CompareTo(other.MMY);
            if (i != 0)
            {
                return(i);
            }
            i = OptionType.CompareTo(other.OptionType);
            if (i != 0)
            {
                return(i);
            }
            i = ExpirationStyle.CompareTo(other.ExpirationStyle);
            if (i != 0)
            {
                return(i);
            }
            i = SettlementStyle.CompareTo(other.SettlementStyle);
            if (i != 0)
            {
                return(i);
            }
            return(CFI.CompareTo(other.CFI));
        }
コード例 #2
0
        /// <summary>
        /// Returns a hash code value for this option series.
        /// </summary>
        /// <returns>a hash code value.</returns>
        public override int GetHashCode()
        {
            int  result;
            long temp;

            result = Expiration;
            result = 31 * result + LastTrade;
            temp   = Multiplier != +0.0d ? BitConverter.DoubleToInt64Bits(Multiplier) : 0L;
            result = 31 * result + (int)((ulong)temp ^ ((ulong)temp >> 32));
            temp   = SPC != +0.0d ? BitConverter.DoubleToInt64Bits(SPC) : 0L;
            result = 31 * result + (int)((ulong)temp ^ ((ulong)temp >> 32));
            result = 31 * result + AdditionalUnderlyings.GetHashCode();
            result = 31 * result + MMY.GetHashCode();
            result = 31 * result + OptionType.GetHashCode();
            result = 31 * result + ExpirationStyle.GetHashCode();
            result = 31 * result + SettlementStyle.GetHashCode();
            result = 31 * result + CFI.GetHashCode();
            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Indicates whether some other object is equal to this option series by its attributes.
        /// </summary>
        /// <param name="o"></param>
        /// <returns>another object to compare with.</returns>
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (!(o is OptionSeries))
            {
                return(false);
            }
            OptionSeries that = (OptionSeries)o;

            return(Expiration == that.Expiration &&
                   LastTrade == that.LastTrade &&
                   Multiplier.CompareTo(that.Multiplier) == 0 &&
                   SPC.CompareTo(that.SPC) == 0 &&
                   AdditionalUnderlyings.Equals(that.AdditionalUnderlyings) &&
                   ExpirationStyle.Equals(that.ExpirationStyle) &&
                   MMY.Equals(that.MMY) &&
                   OptionType.Equals(that.OptionType) &&
                   CFI.Equals(that.CFI) &&
                   SettlementStyle.Equals(that.SettlementStyle));
        }