diff --git a/src/client/spark/view/Spark/Orders/IOrderBook.cs b/src/client/spark/view/Spark/Orders/IOrderBook.cs index 70313b8d7..71b0f8b52 100644 --- a/src/client/spark/view/Spark/Orders/IOrderBook.cs +++ b/src/client/spark/view/Spark/Orders/IOrderBook.cs @@ -13,14 +13,13 @@ namespace mbts.spark static class OrderBookExtensions { - public static IDictionary> get_order_sec_map(this IOrderBook ob) { return ob.get_all_orders().Map(e => e.sec_key()); } + public static IDictionary> get_order_sec_map(this IOrderBook ob) { return new Dictionary>(); } - public static IEnumerable get_active_orders_for_security(this IOrderBook ob, uint security) { return ob.get_all_orders().Where(e => e.sec_key() == security && e.is_active()); } + public static IEnumerable get_active_orders_for_security(this IOrderBook ob, uint security) { return Enumerable.Empty(); } - public static IEnumerable get_all_fills(this IOrderBook ob) { return ob.get_all_orders().SelectMany(e => e.Fills); } - public static IDictionary> get_fill_sec_map(this IOrderBook ob) { return ob.get_all_fills().Map(f => f.Order.Security.Id); } + public static IDictionary> get_fill_sec_map(this IOrderBook ob) { return new Dictionary>(); } - public static IDictionary> get_fill_tuple_sec_map(this IOrderBook ob) { return ob.get_all_orders().Map(o => o.sec_key(), o => o.Fills.Select(f => new FillTuple(f, o))); } + public static IDictionary> get_fill_tuple_sec_map(this IOrderBook ob) { return new Dictionary>(); } } } \ No newline at end of file diff --git a/src/client/spark/view/Spark/Orders/OrderBook.cs b/src/client/spark/view/Spark/Orders/OrderBook.cs index 567ca2332..28bf47762 100644 --- a/src/client/spark/view/Spark/Orders/OrderBook.cs +++ b/src/client/spark/view/Spark/Orders/OrderBook.cs @@ -8,102 +8,15 @@ namespace mbts.spark { public class OrderBook : IOrderBook { - private static OrderID _null_id = new OrderID() { Id = String.Empty }; - private List _orderbook = new List(); - public OrderBook() { } - #region Mutators - - public void update_entry(OrderStatus order_status) { - OrderBookEntry curr = get_order(order_status.Order.Id); - if (curr == null) { - /// new order - curr = new OrderBookEntry() { OrderStatus = order_status }; - if (curr.parent_id() == null) { - /// Does not have a parent => its a "Root" order - _orderbook.Add(curr); - } - else { - /// Add it to an existing Entry - OrderBookEntry parent_order = get_order(order_status.ParentId); - Logger.assert(parent_order != null); - parent_order.ChildOrders.Add(curr); - } - } - else { - /// order exists - if ((curr.parent_id() ?? _null_id).Equals(order_status.ParentId ?? _null_id)) { - /// just update the order, parent has not changed - curr.OrderStatus = order_status; - } else { - /// parents have changed - if (curr.parent_id() == null) _remove_top_level_entry(curr.ID()); - else _remove_child_entry(curr.parent_id(), curr.ID()); - curr.OrderStatus = order_status; - OrderBookEntry parent_order = get_order(order_status.ParentId); - mbts.Logger.assert(parent_order != null); - parent_order.ChildOrders.Add(curr); - } - } - } - - public void update_fills(OrderID order_id, IEnumerable fills) { - OrderBookEntry o = get_order(order_id); - Logger.assert(o != null); - o.Fills.AddRange(fills); - } - - public void update_price(OrderID order_id, double new_price) { - OrderBookEntry o = get_order(order_id); - Logger.assert(o != null); - o.OrderStatus.Order.Price = new_price; - } - - internal IOrderBook clone() { return new OrderBook() { _orderbook = _orderbook.Select(o => o.Clone()).ToList() }; } - - #endregion - - #region IOrderBook - public OrderBookEntry get_order(OrderID order_id) { - return _orderbook.FirstOrDefault(o => o.ID().Equals(order_id)); + return null; } public IEnumerable get_all_orders() { - return _get_all_orders(_orderbook); + return Enumerable.Empty(); } - #endregion - - private void _remove_child_entry(OrderID parent_order_id, OrderID child_order_id) { - OrderBookEntry parent_order = get_order(parent_order_id); - if (parent_order != null) { - int index = parent_order.ChildOrders.find_first_index(o => o.ID().Equals(child_order_id)); - if (index != -1) parent_order.ChildOrders.RemoveAt(index); - } - } - - private void _remove_top_level_entry(OrderID order_id) { - int index = _orderbook.FindLastIndex(o => o.ID().Equals(order_id)); - if (index != -1) _orderbook.RemoveAt(index); - } - - - private static bool _contains_order(IEnumerable working_orders, OrderID order_id) { - HashSet order_id_map = new HashSet(working_orders.Select(o => o.Order.Id)); - return order_id_map.Contains(order_id); - } - - #region Stateless functions - - private static IEnumerable _get_all_orders(IEnumerable curr) { - foreach (var o in curr) { - yield return o; - foreach (var co in _get_all_orders(o.ChildOrders)) yield return co; - } - } - - #endregion } } \ No newline at end of file diff --git a/src/client/spark/view/Spark/Orders/OrdersModel.cs b/src/client/spark/view/Spark/Orders/OrdersModel.cs index 6a27457fd..29ec60a05 100644 --- a/src/client/spark/view/Spark/Orders/OrdersModel.cs +++ b/src/client/spark/view/Spark/Orders/OrdersModel.cs @@ -180,11 +180,6 @@ namespace mbts.spark public void cancel_order(IEnumerable order_ids) { } - public void tick_up(IEnumerable order_ids) { } - public void tick_down(IEnumerable order_ids) { } - public void pause(IEnumerable order_ids) { } - public void unpause(IEnumerable orders) { } - public void cancel_security_orders (IEnumerable sec_keys, bool all_buys, bool all_sells) { } @@ -194,12 +189,6 @@ namespace mbts.spark return true; } - public bool change_qty(OrderID order_id, UInt32 new_qty) - { - return true; - } - internal void change_price_and_quantity(OrderID id, double price, uint qty) { } - public bool modify_order(Order modified_order) { return true; } @@ -208,7 +197,6 @@ namespace mbts.spark public void show_order_ticket(Order order) { _bus.post(SparkTags.ShowNotImplemented, null); } public void show_order_ticket(IReadOnlyCollection orders) { _bus.post(SparkTags.ShowNotImplemented, null); } public void show_order_modify(Order order) { _bus.post(SparkTags.ShowOrderModifyTag, new SparkBusData.ShowOrderModifyMessage(order)); } - public void show_order_modify(IReadOnlyCollection orders) { _bus.post(SparkTags.ShowOrderModifyTag, new SparkBusData.ShowOrderModifyMessage(orders)); } internal void show_order_details(OrderID order_id) { _bus.post(SparkTags.ShowOrderDetailsTag, order_id);