Exemple #1
0
        private OrderUpdate WaitForOrderStatus(long orderId, OrderUpdate.OrderStatus status)
        {
            _logger.LogDebug($"Waiting order {orderId} to reach status {status}");
            var start = DateTimeOffset.Now.ToUnixTimeMilliseconds();

            while (true)
            {
                var now = DateTimeOffset.Now.ToUnixTimeMilliseconds();
                if (now - start > 10000)
                {
                    throw new OrderFailedException($"Order {orderId} was not reported as {status} within 10 seconds.");
                }

                var query = Implementation.WaitForOrderStatus(orderId, status);
                if (query.Success)
                {
                    return(query.Data);
                }
            }
        }
            public sealed override ResponseObject <OrderUpdate> WaitForOrderStatus(long orderId, OrderUpdate.OrderStatus status)
            {
                foreach (var order in Cache)
                {
                    if (order.OrderId == orderId && order.Status == status)
                    {
                        return(new ResponseObject <OrderUpdate>(order));
                    }
                }

                return(new ResponseObject <OrderUpdate>(ResponseCode.Error));
            }
        /// <inheritdoc />
        public override ResponseObject <OrderUpdate> WaitForOrderStatus(long orderId, OrderUpdate.OrderStatus status)
        {
            while (_orderCache.TryDequeue(out var order))
            {
                UpdateObservers(order);
                if (order.OrderId == orderId && order.Status == status)
                {
                    return(new ResponseObject <OrderUpdate>(order));
                }
            }

            return(new ResponseObject <OrderUpdate>(ResponseCode.Error, "Backtest order was not added to the cache correctly"));
        }
Exemple #4
0
 /// <summary>
 /// Search for a certain order with a certain status.
 /// This method differs from GetOrderInfo because the implementation can
 /// choose to source this information from its local cache.
 /// </summary>
 /// <param name="orderId">The id of the order.</param>
 /// <param name="status">the status of the order.</param>
 /// <returns>ResponseObject containing the order.</returns>
 public abstract ResponseObject <OrderUpdate> WaitForOrderStatus(long orderId, OrderUpdate.OrderStatus status);
        /// <inheritdoc />
        public override ResponseObject <OrderUpdate> WaitForOrderStatus(long orderId, OrderUpdate.OrderStatus status)
        {
            while (_orderCache.TryDequeue(out var order))
            {
                UpdateObservers(order);
                if (order.OrderId == orderId && order.Status == status)
                {
                    return(new ResponseObject <OrderUpdate>(order));
                }
            }

            return(new ResponseObject <OrderUpdate>(ResponseCode.NotFound));
        }