/// <summary> /// Returns true if CurrencyPortfolio instances are equal /// </summary> /// <param name="other">Instance of CurrencyPortfolio to be compared</param> /// <returns>Boolean</returns> public bool Equals(CurrencyPortfolio other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( MaintenanceMargin == other.MaintenanceMargin || MaintenanceMargin != null && MaintenanceMargin.Equals(other.MaintenanceMargin) ) && ( AvailableWithdrawalFunds == other.AvailableWithdrawalFunds || AvailableWithdrawalFunds != null && AvailableWithdrawalFunds.Equals(other.AvailableWithdrawalFunds) ) && ( InitialMargin == other.InitialMargin || InitialMargin != null && InitialMargin.Equals(other.InitialMargin) ) && ( AvailableFunds == other.AvailableFunds || AvailableFunds != null && AvailableFunds.Equals(other.AvailableFunds) ) && ( Currency == other.Currency || Currency.Equals(other.Currency) ) && ( MarginBalance == other.MarginBalance || MarginBalance != null && MarginBalance.Equals(other.MarginBalance) ) && ( Equity == other.Equity || Equity != null && Equity.Equals(other.Equity) ) && ( Balance == other.Balance || Balance != null && Balance.Equals(other.Balance) )); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (MaintenanceMargin != null) { hashCode = hashCode * 59 + MaintenanceMargin.GetHashCode(); } if (AvailableWithdrawalFunds != null) { hashCode = hashCode * 59 + AvailableWithdrawalFunds.GetHashCode(); } if (InitialMargin != null) { hashCode = hashCode * 59 + InitialMargin.GetHashCode(); } if (AvailableFunds != null) { hashCode = hashCode * 59 + AvailableFunds.GetHashCode(); } hashCode = hashCode * 59 + Currency.GetHashCode(); if (MarginBalance != null) { hashCode = hashCode * 59 + MarginBalance.GetHashCode(); } if (Equity != null) { hashCode = hashCode * 59 + Equity.GetHashCode(); } if (Balance != null) { hashCode = hashCode * 59 + Balance.GetHashCode(); } return(hashCode); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) hashCode = hashCode * 59 + Direction.GetHashCode(); if (AveragePriceUsd != null) { hashCode = hashCode * 59 + AveragePriceUsd.GetHashCode(); } if (EstimatedLiquidationPrice != null) { hashCode = hashCode * 59 + EstimatedLiquidationPrice.GetHashCode(); } if (FloatingProfitLoss != null) { hashCode = hashCode * 59 + FloatingProfitLoss.GetHashCode(); } if (FloatingProfitLossUsd != null) { hashCode = hashCode * 59 + FloatingProfitLossUsd.GetHashCode(); } if (OpenOrdersMargin != null) { hashCode = hashCode * 59 + OpenOrdersMargin.GetHashCode(); } if (TotalProfitLoss != null) { hashCode = hashCode * 59 + TotalProfitLoss.GetHashCode(); } if (RealizedProfitLoss != null) { hashCode = hashCode * 59 + RealizedProfitLoss.GetHashCode(); } if (Delta != null) { hashCode = hashCode * 59 + Delta.GetHashCode(); } if (InitialMargin != null) { hashCode = hashCode * 59 + InitialMargin.GetHashCode(); } if (Size != null) { hashCode = hashCode * 59 + Size.GetHashCode(); } if (MaintenanceMargin != null) { hashCode = hashCode * 59 + MaintenanceMargin.GetHashCode(); } hashCode = hashCode * 59 + Kind.GetHashCode(); if (MarkPrice != null) { hashCode = hashCode * 59 + MarkPrice.GetHashCode(); } if (AveragePrice != null) { hashCode = hashCode * 59 + AveragePrice.GetHashCode(); } if (SettlementPrice != null) { hashCode = hashCode * 59 + SettlementPrice.GetHashCode(); } if (IndexPrice != null) { hashCode = hashCode * 59 + IndexPrice.GetHashCode(); } if (InstrumentName != null) { hashCode = hashCode * 59 + InstrumentName.GetHashCode(); } if (SizeCurrency != null) { hashCode = hashCode * 59 + SizeCurrency.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if Position instances are equal /// </summary> /// <param name="other">Instance of Position to be compared</param> /// <returns>Boolean</returns> public bool Equals(Position other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Direction == other.Direction || Direction.Equals(other.Direction) ) && ( AveragePriceUsd == other.AveragePriceUsd || AveragePriceUsd != null && AveragePriceUsd.Equals(other.AveragePriceUsd) ) && ( EstimatedLiquidationPrice == other.EstimatedLiquidationPrice || EstimatedLiquidationPrice != null && EstimatedLiquidationPrice.Equals(other.EstimatedLiquidationPrice) ) && ( FloatingProfitLoss == other.FloatingProfitLoss || FloatingProfitLoss != null && FloatingProfitLoss.Equals(other.FloatingProfitLoss) ) && ( FloatingProfitLossUsd == other.FloatingProfitLossUsd || FloatingProfitLossUsd != null && FloatingProfitLossUsd.Equals(other.FloatingProfitLossUsd) ) && ( OpenOrdersMargin == other.OpenOrdersMargin || OpenOrdersMargin != null && OpenOrdersMargin.Equals(other.OpenOrdersMargin) ) && ( TotalProfitLoss == other.TotalProfitLoss || TotalProfitLoss != null && TotalProfitLoss.Equals(other.TotalProfitLoss) ) && ( RealizedProfitLoss == other.RealizedProfitLoss || RealizedProfitLoss != null && RealizedProfitLoss.Equals(other.RealizedProfitLoss) ) && ( Delta == other.Delta || Delta != null && Delta.Equals(other.Delta) ) && ( InitialMargin == other.InitialMargin || InitialMargin != null && InitialMargin.Equals(other.InitialMargin) ) && ( Size == other.Size || Size != null && Size.Equals(other.Size) ) && ( MaintenanceMargin == other.MaintenanceMargin || MaintenanceMargin != null && MaintenanceMargin.Equals(other.MaintenanceMargin) ) && ( Kind == other.Kind || Kind.Equals(other.Kind) ) && ( MarkPrice == other.MarkPrice || MarkPrice != null && MarkPrice.Equals(other.MarkPrice) ) && ( AveragePrice == other.AveragePrice || AveragePrice != null && AveragePrice.Equals(other.AveragePrice) ) && ( SettlementPrice == other.SettlementPrice || SettlementPrice != null && SettlementPrice.Equals(other.SettlementPrice) ) && ( IndexPrice == other.IndexPrice || IndexPrice != null && IndexPrice.Equals(other.IndexPrice) ) && ( InstrumentName == other.InstrumentName || InstrumentName != null && InstrumentName.Equals(other.InstrumentName) ) && ( SizeCurrency == other.SizeCurrency || SizeCurrency != null && SizeCurrency.Equals(other.SizeCurrency) )); }