/// <summary>
 /// Default Constructor
 /// </summary>
 public OrderBookMemoryImage()
 {
     _bidBookRepresentations = new OrderRepresentationBookList();
     _askBookRepresentations = new OrderRepresentationBookList();
     InitializeCurrencyPairs();
     InitializeOrderBooksRepresentations();
     LimitOrderBookEvent.LimitOrderBookChanged += OnOrderBookChanged;
 }
 /// <summary>
 /// Updates the OrderBookRepresentation. Used by both bid and aask representations
 /// </summary>
 private OrderRepresentationList GetOrderRepresentationList(OrderRepresentationBookList orderBookRepresentations, OrderList orderList)
 {
     foreach (OrderRepresentationList orderRepresentationList in orderBookRepresentations)
     {
         if (orderRepresentationList.CurrencyPair == orderList.CurrencyPair)
         {
             return(orderRepresentationList);
         }
     }
     return(null);
 }
        /// <summary>
        /// Updates the OrderRepresentationlist with new values
        /// </summary>
        /// <returns></returns>
        private void UpdateOrderRepresentationList(OrderRepresentationBookList orderRepresentationBook, OrderRepresentationList orderRepresentationList, OrderList orderList)
        {
            // If the orderRepresentationLst for this currencyPair is already present, remove it
            if (orderRepresentationList != null)
            {
                orderRepresentationBook.Remove(orderRepresentationList.CurrencyPair);
            }
            // Initialize the Orderlist for this currencyPair
            orderRepresentationList = new OrderRepresentationList(orderList.CurrencyPair, orderList.OrderSide);

            // Add each order(Bid or Ask) in the correponding order list (Bids list or Asks list)
            foreach (Order order in orderList)
            {
                orderRepresentationList.AddRecord(order.OpenQuantity.Value, order.Price.Value, order.DateTime);
                Log.Debug("Order Representation added to Currency Pair : " + order.CurrencyPair +
                          ". OpenQuantity: " + order.OpenQuantity.Value + " | Price: " + order.Price.Value);
            }
            // Add the new orderList (order book for bids or asks) to the OrderBooksList of this memory image
            orderRepresentationBook.AddRecord(orderRepresentationList);
        }