private static LimitOrder[] GetRankedOrders(MarketOrder marketOrder, OrderList orderList) { var worsSpread = orderList.CalcWorstSpread(marketOrder.Asset); if (worsSpread <= 0) { return(marketOrder.Action == OrderAction.Buy ? orderList.LimitOrdersSell.Where( itm => itm.Order.Asset == marketOrder.Asset && itm.Order.TraderId != marketOrder.TraderId) .OrderBy(itm => itm.Order.Price) .Select(itm => itm.Order) .ToArray() : orderList.LimitOrdersBuy.Where( itm => itm.Order.Asset == marketOrder.Asset && itm.Order.TraderId != marketOrder.TraderId) .OrderByDescending(itm => itm.Order.Price) .Select(itm => itm.Order) .ToArray()); } var resultOrderList = marketOrder.Action == OrderAction.Buy ? orderList.LimitOrdersSell.Where( itm => itm.Order.Asset == marketOrder.Asset && itm.Order.TraderId != marketOrder.TraderId).ToArray() : orderList.LimitOrdersBuy.Where( itm => itm.Order.Asset == marketOrder.Asset && itm.Order.TraderId != marketOrder.TraderId).ToArray(); foreach (var orderWrapper in resultOrderList) { orderWrapper.Rank = orderWrapper.Order.Price; } return(marketOrder.Action == OrderAction.Buy ? resultOrderList.OrderBy(itm => itm.Rank).Select(itm => itm.Order).ToArray() : resultOrderList.OrderByDescending(itm => itm.Rank).Select(itm => itm.Order).ToArray()); }
private static LimitOrder[] GetRankedOrders(MarketOrder marketOrder, OrderList orderList) { var worsSpread = orderList.CalcWorstSpread(marketOrder.Asset); if (worsSpread <= 0) return marketOrder.Action == OrderAction.Buy ? orderList.LimitOrdersSell.Where( itm => itm.Order.Asset == marketOrder.Asset && itm.Order.TraderId != marketOrder.TraderId) .OrderBy(itm => itm.Order.Price) .Select(itm => itm.Order) .ToArray() : orderList.LimitOrdersBuy.Where( itm => itm.Order.Asset == marketOrder.Asset && itm.Order.TraderId != marketOrder.TraderId) .OrderByDescending(itm => itm.Order.Price) .Select(itm => itm.Order) .ToArray(); var resultOrderList = marketOrder.Action == OrderAction.Buy ? orderList.LimitOrdersSell.Where( itm => itm.Order.Asset == marketOrder.Asset && itm.Order.TraderId != marketOrder.TraderId).ToArray() : orderList.LimitOrdersBuy.Where( itm => itm.Order.Asset == marketOrder.Asset && itm.Order.TraderId != marketOrder.TraderId).ToArray(); foreach (var orderWrapper in resultOrderList) orderWrapper.Rank = orderWrapper.Order.Price; return marketOrder.Action == OrderAction.Buy ? resultOrderList.OrderBy(itm => itm.Rank).Select(itm => itm.Order).ToArray() : resultOrderList.OrderByDescending(itm => itm.Rank).Select(itm => itm.Order).ToArray(); }