private void RemoveOrderIfComplete(UnmatchedOrder uo) { if (uo.OrderStatus == "EC") { _unmatchedOrders.Remove(uo.BetId); } }
public void Update(UnmatchedOrder unmatchedOrder) { var uo = ValidateOrder(unmatchedOrder); AddOrderToCache(uo); RemoveOrderIfComplete(uo); }
private void AddOrderToCache(UnmatchedOrder uo) { if (!_unmatchedOrders.ContainsKey(uo.BetId)) { _unmatchedOrders.Add(uo.BetId, null); } _unmatchedOrders[uo.BetId] = uo; }
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); }
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); }
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); }
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); }
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); }