private void FilterAndUpdateQuotes(float?bid, float?ask, string symbol) { PartialQuote quote; quotes.TryGetValue(symbol, out quote); if (quote != null) { if (ask.HasValue) { var delta = quote.Ask.HasValue ? Math.Abs(100 * (ask.Value - quote.Ask.Value) / quote.Ask.Value) : 0; if (delta > maxQuoteDeltaPercent) { logNoFlood.LogMessageFormatCheckFlood(LogEntryType.Error, LogMsgWrongQuote, 1000 * 60 * 15, "Неверная котировка {0}: ask={1:f4}, старое значение {2:f4}", symbol, ask.Value, quote.Ask ?? 0); } else { quote.Ask = ask; } } if (bid.HasValue) { var delta = quote.Bid.HasValue ? Math.Abs(100 * (bid.Value - quote.Bid.Value) / quote.Bid.Value) : 0; if (delta > maxQuoteDeltaPercent) { logNoFlood.LogMessageFormatCheckFlood(LogEntryType.Error, LogMsgWrongQuote, 1000 * 60 * 15, "Неверная котировка {0}: bid={1:f4}, старое значение {2:f4}", symbol, bid.Value, quote.Bid ?? 0); } else { quote.Bid = bid; } } return; } quote = new PartialQuote(ask, bid); quotes.Add(symbol, quote); }
private void FilterAndUpdateQuotes(float? bid, float? ask, string symbol) { PartialQuote quote; quotes.TryGetValue(symbol, out quote); if (quote != null) { if (ask.HasValue) { var delta = quote.Ask.HasValue ? Math.Abs(100*(ask.Value - quote.Ask.Value)/quote.Ask.Value) : 0; if (delta > maxQuoteDeltaPercent) { logNoFlood.LogMessageFormatCheckFlood(LogEntryType.Error, LogMsgWrongQuote, 1000 * 60 * 15, "Неверная котировка {0}: ask={1:f4}, старое значение {2:f4}", symbol, ask.Value, quote.Ask ?? 0); } else quote.Ask = ask; } if (bid.HasValue) { var delta = quote.Bid.HasValue ? Math.Abs(100 * (bid.Value - quote.Bid.Value) / quote.Bid.Value) : 0; if (delta > maxQuoteDeltaPercent) { logNoFlood.LogMessageFormatCheckFlood(LogEntryType.Error, LogMsgWrongQuote, 1000 * 60 * 15, "Неверная котировка {0}: bid={1:f4}, старое значение {2:f4}", symbol, bid.Value, quote.Bid ?? 0); } else quote.Bid = bid; } return; } quote = new PartialQuote(ask, bid); quotes.Add(symbol, quote); }