コード例 #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is PayOrderRequest other &&
                   ((IdempotencyKey == null && other.IdempotencyKey == null) || (IdempotencyKey?.Equals(other.IdempotencyKey) == true)) &&
                   ((OrderVersion == null && other.OrderVersion == null) || (OrderVersion?.Equals(other.OrderVersion) == true)) &&
                   ((PaymentIds == null && other.PaymentIds == null) || (PaymentIds?.Equals(other.PaymentIds) == true)));
        }
コード例 #2
0
        public override int GetHashCode()
        {
            int hashCode = -320446863;

            if (IdempotencyKey != null)
            {
                hashCode += IdempotencyKey.GetHashCode();
            }

            if (OrderVersion != null)
            {
                hashCode += OrderVersion.GetHashCode();
            }

            if (PaymentIds != null)
            {
                hashCode += PaymentIds.GetHashCode();
            }

            return(hashCode);
        }
コード例 #3
0
        static string GetOrderVersionDescription(Order order, Contract contract, OrderVersion orderVersion)
        {
            string orderPrice;

            switch (orderVersion.OrderType)
            {
            case OrderVersion.OrderTypeEnum.Market:
                orderPrice = "MKT";
                break;

            case OrderVersion.OrderTypeEnum.Limit:
            case OrderVersion.OrderTypeEnum.MIT:
                orderPrice = $"{orderVersion.OrderType} {orderVersion.Price}";
                break;

            case OrderVersion.OrderTypeEnum.Stop:
                orderPrice = $"{orderVersion.OrderType} {orderVersion.StopPrice}";
                break;

            case OrderVersion.OrderTypeEnum.StopLimit:
                orderPrice = $"STOP {orderVersion.StopPrice} LIMIT {orderVersion.Price}";
                break;

            case OrderVersion.OrderTypeEnum.TrailingStop:
                orderPrice = $"TRAIL.STOP {orderVersion.StopPrice} with {orderVersion.PegDifference}";
                break;

            case OrderVersion.OrderTypeEnum.TrailingStopLimit:
                orderPrice = $"TRAIL.STOP {orderVersion.StopPrice} LIMIT {orderVersion.Price} with {orderVersion.PegDifference}";
                break;

            default:
                orderPrice = orderVersion.OrderType.ToString();
                break;
            }

            return($"{order.Action} {orderVersion.OrderQty} {contract.Name} @ {orderPrice}");
        }
コード例 #4
0
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"IdempotencyKey = {(IdempotencyKey == null ? "null" : IdempotencyKey == string.Empty ? "" : IdempotencyKey)}");
     toStringOutput.Add($"OrderVersion = {(OrderVersion == null ? "null" : OrderVersion.ToString())}");
     toStringOutput.Add($"PaymentIds = {(PaymentIds == null ? "null" : $"[{ string.Join(", ", PaymentIds)} ]")}");
 }