private static void UpdateAgent(OrderUpdate update) { var agentIndex = int.Parse(update.Order.UserID); switch (update.Order.Type) { case OrderType.LimitOrder: if (update.Matches != null) { switch (update.Order.Side) { case OrderSide.Buy: _agents[agentIndex].StockHeld += (int)update.Matches.Sum(m => m.Quantity); _agents[agentIndex].CashHeld -= update.Matches.Sum(m => m.Price * m.Quantity); break; case OrderSide.Sell: _agents[agentIndex].StockHeld -= (int)update.Matches.Sum(m => m.Quantity); _agents[agentIndex].CashHeld += update.Matches.Sum(m => m.Price * m.Quantity); break; default: break; } } break; //case OrderType.MarketOrder: // switch (update.Order.Side) // { // case OrderSide.Buy: // _agents[agentIndex].StockHeld += (int)update.Order.Quantity; // _agents[agentIndex].CashHeld -= update.Order.Quantity * update.Order.Price; // break; // case OrderSide.Sell: // _agents[agentIndex].StockHeld -= (int)update.Order.Quantity; // _agents[agentIndex].CashHeld += update.Order.Quantity * update.Order.Price; // break; // default: // break; // } // break; default: break; } }
public bool PushOrderInstructionUpdate(OrderUpdate order, string userID) { var connID = ConnectionIDs[userID]; _clientsInstance.Value.Client(connID).UpdateOrder(order); return true; }