private void HandleOrder(OrderResponse response)
        {
            if (response == null)
            {
                // weird state, do nothing
                return;
            }

            var orders = ConvertOrder(response);

            switch (response.OrderStatus)
            {
            case OrderStatus.Undefined:
                break;

            case OrderStatus.Active:
            case OrderStatus.Pending:
            case OrderStatus.Open:
                OrderCreatedSubject.OnNext(orders);
                break;

            case OrderStatus.Executed:
            case OrderStatus.PartiallyFilled:
            case OrderStatus.Canceled:
            case OrderStatus.All:
            case OrderStatus.Rejected:
            case OrderStatus.Done:
            case OrderStatus.Settled:
                OrderUpdatedSubject.OnNext(orders);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private void HandleOrders(OrderResponse response)
        {
            if (response?.Data == null || !response.Data.Any())
            {
                // weird state, do nothing
                return;
            }

            var orders = ConvertOrders(response.Data);

            if (response.Action == BitmexAction.Partial)
            {
                // received snapshot, stream
                OrderSnapshotSubject.OnNext(orders);
                return;
            }

            foreach (var order in orders)
            {
                if (response.Action == BitmexAction.Insert)
                {
                    OrderCreatedSubject.OnNext(order);
                }
                else
                {
                    OrderUpdatedSubject.OnNext(order);
                }
            }
        }
Exemple #3
0
        private void HandleOrder(Order response)
        {
            if (response == null)
            {
                // weird state, do nothing
                return;
            }

            var orders = ConvertOrder(response);

            switch (response.OrderStatus)
            {
            case OrderStatus.Undefined:
                break;

            case OrderStatus.Active:
                OrderCreatedSubject.OnNext(orders);
                break;

            case OrderStatus.Executed:
            case OrderStatus.PartiallyFilled:
            case OrderStatus.Canceled:
            case OrderStatus.PostOnlyCanceled:
            case OrderStatus.RsnPosReduceFlip:
            case OrderStatus.RsnPosReduceIncr:
            case OrderStatus.InsufficientBalance:
            case OrderStatus.InsufficientMargin:
                OrderUpdatedSubject.OnNext(orders);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }