Пример #1
0
 private void RemoveOrderIfComplete(UnmatchedOrder uo)
 {
     if (uo.OrderStatus == "EC")
     {
         _unmatchedOrders.Remove(uo.BetId);
     }
 }
Пример #2
0
        public void Update(UnmatchedOrder unmatchedOrder)
        {
            var uo = ValidateOrder(unmatchedOrder);

            AddOrderToCache(uo);
            RemoveOrderIfComplete(uo);
        }
Пример #3
0
 private void AddOrderToCache(UnmatchedOrder uo)
 {
     if (!_unmatchedOrders.ContainsKey(uo.BetId))
     {
         _unmatchedOrders.Add(uo.BetId, null);
     }
     _unmatchedOrders[uo.BetId] = uo;
 }
Пример #4
0
        private void AddUnmatchedOrder(string betId, string side, string orderStatus, double sizeRemaining)
        {
            var uo = new UnmatchedOrder
            {
                BetId         = betId,
                Side          = side,
                OrderStatus   = orderStatus,
                SizeRemaining = sizeRemaining,
            };

            _unmatchedOrders.Update(uo);
        }
Пример #5
0
 private static void AssertOrderIsEqual(
     string betId,
     string side,
     string orderStatus,
     double sizeRemaining,
     UnmatchedOrder order)
 {
     Assert.Equal(betId, order.BetId);
     Assert.Equal(side, order.Side);
     Assert.Equal(orderStatus, order.OrderStatus);
     Assert.Equal(sizeRemaining, order.SizeRemaining);
 }
Пример #6
0
        private static UnmatchedOrder ValidateOrder(UnmatchedOrder unmatchedOrder)
        {
            if (unmatchedOrder is null)
            {
                throw new ArgumentNullException(nameof(unmatchedOrder));
            }
            if (unmatchedOrder.BetId is null)
            {
                throw new ArgumentNullException(nameof(unmatchedOrder), "BetId should not be null.");
            }

            return(unmatchedOrder);
        }
Пример #7
0
        public OrderRunnerChangeStub WithUnmatchedLay(
            double?price, double?size, string betId = "1", long?placedDate = 0)
        {
            UnmatchedOrders ??= new List <UnmatchedOrder>();
            var uo = new UnmatchedOrder
            {
                BetId         = betId,
                Side          = "L",
                Price         = price,
                SizeRemaining = size,
                PlacedDate    = placedDate,
            };

            UnmatchedOrders.Add(uo);
            return(this);
        }
Пример #8
0
        private void UpdateUnmatchedLiability(UnmatchedOrder uo)
        {
            if (uo.SizeRemaining is null)
            {
                return;
            }
            var sr = (double)uo.SizeRemaining;

            if (uo.Price is null)
            {
                return;
            }
            var price = (double)uo.Price;

            UnmatchedLiability +=
                uo.Side == "B" ? sr : Math.Round((price * sr) - sr, 2);
        }