public decimal?GetPriceForClose(Order order) { using (_contextFactory.GetWriteSyncContext($"{nameof(MarketMakerMatchingEngine)}.{nameof(GetPriceForClose)}")) { var orderBookTypeToMatch = order.GetCloseType().GetOrderTypeToMatchInOrderBook(); var matchedOrders = _orderBooks.Match(order, orderBookTypeToMatch, Math.Abs(order.GetRemainingCloseVolume())); return(matchedOrders.Any() ? matchedOrders.WeightedAveragePrice : (decimal?)null); } // lock }
public (string externalProviderId, decimal?price) GetBestPriceForOpen(string assetPairId, decimal volume) { using (_contextFactory.GetWriteSyncContext($"{nameof(MarketMakerMatchingEngine)}.{nameof(GetBestPriceForOpen)}")) { var orderBookTypeToMatch = volume.GetOrderDirection().GetOrderDirectionToMatchInOrderBook(); var matchedOrders = _orderBooks.Match(assetPairId, orderBookTypeToMatch, Math.Abs(volume)); var price = matchedOrders.Any() ? matchedOrders.WeightedAveragePrice : (decimal?)null; return(null, price); } // lock }