public async Task HandleQuote(OrderBook orderBook) { if (_requiredExchanges.All(x => x != orderBook.Source)) { return; } var bestPriceQuote = ConvertToBestPriceQuote(orderBook); if (string.IsNullOrEmpty(bestPriceQuote?.ExchangeName) || string.IsNullOrEmpty(bestPriceQuote.Instrument) || bestPriceQuote.Bid == 0 || bestPriceQuote.Ask == 0) { await _log.WriteWarningAsync("QuoteService", "HandleQuote", "Incoming quote is incorrect: " + (bestPriceQuote?.ToString() ?? "null")); return; } _quoteCache.Set(new ExchangeInstrumentQuote { ExchangeName = bestPriceQuote.ExchangeName, Instrument = bestPriceQuote.Instrument, Base = "", Quote = "", Bid = bestPriceQuote.Bid, Ask = bestPriceQuote.Ask }); }
public async Task HandleQuote(OrderBook orderBook) { var bestPriceQuote = ConvertToBestPriceQuote(orderBook); if (string.IsNullOrEmpty(bestPriceQuote?.ExchangeName) || string.IsNullOrEmpty(bestPriceQuote.Instrument) || bestPriceQuote.Bid == 0 || bestPriceQuote.Ask == 0) { await _log.WriteWarningAsync("QuoteService", "HandleQuote", "Incoming quote is incorrect: " + (bestPriceQuote?.ToString() ?? "null")); return; } _quoteCache.Set(new ExchangeInstrumentQuote { ExchangeName = bestPriceQuote.ExchangeName, Instrument = bestPriceQuote.Instrument, Base = "", Quote = "", Bid = bestPriceQuote.Bid, Ask = bestPriceQuote.Ask }); var swappedInstrument = SwapInstrument(bestPriceQuote.Instrument); if (bestPriceQuote.ExchangeName == "bitmex" && swappedInstrument != null && swappedInstrument == "USDBTC") { _quoteCache.Set(new ExchangeInstrumentQuote { ExchangeName = bestPriceQuote.ExchangeName, Instrument = swappedInstrument, Base = "", Quote = "", Bid = bestPriceQuote.Bid, Ask = bestPriceQuote.Ask }); } }