/// <summary> /// Initialize lists that will contain the OrderBook representations for all currency pairs /// </summary> private void InitializeOrderBooksRepresentations() { foreach (var currencyPair in _currencyPairs) { OrderRepresentationList bidRepresentationList = new OrderRepresentationList(currencyPair, OrderSide.Buy); OrderRepresentationList askRepresentationList = new OrderRepresentationList(currencyPair, OrderSide.Sell); _bidBookRepresentations.AddRecord(bidRepresentationList); _askBookRepresentations.AddRecord(askRepresentationList); } }
/// <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); }
/// <summary> /// default constructor /// </summary> /// <param name="asks"></param> /// <param name="bids"></param> public OrderBookRepresentation(OrderRepresentationList bids, OrderRepresentationList asks) { Asks = asks; Bids = bids; }