private static async Task<MarketDepth> GetBestBid(IExchange exchange, MarketId marketId) { Book book = await exchange.GetMarketDepth(marketId); MarketDepth bestBid = null; foreach (MarketDepth bid in book.Bids) { if (null == bestBid || bid.Price > bestBid.Price) { bestBid = bid; } } return bestBid; }
private static async Task<MarketDepth> GetBestAsk(IExchange exchange, MarketId marketId) { Book book = await exchange.GetMarketDepth(marketId); MarketDepth bestAsk = null; foreach (MarketDepth ask in book.Asks) { if (null == bestAsk || ask.Price < bestAsk.Price) { bestAsk = ask; } } return bestAsk; }