public async Task Send(ILayeringRuleBreach breach) { if (breach == null) { this.Logger.LogInformation("LayeringAlertSender Send received a null rule breach. Returning."); return; } var description = this.BuildDescription(breach); await this.Send(breach, description); }
/// <summary> /// Receive and cache rule breach in memory /// </summary> public void Send(ILayeringRuleBreach ruleBreach) { if (ruleBreach == null) { // ReSharper disable once InconsistentlySynchronizedField this._logger.LogInformation( "Layering Rule Cached Message Sender received a null rule breach. Returning."); return; } lock (this._lock) { this._logger.LogInformation( $"Layering Rule Cached Message Sender received rule breach for {ruleBreach.Security.Identifiers}"); var duplicates = this._messages.Where(msg => msg.Trades.PositionIsSubsetOf(ruleBreach.Trades)).ToList(); this._messages = this._messages.Except(duplicates).ToList(); this._messages.Add(ruleBreach); } }
private string BuildDescription(ILayeringRuleBreach breach) { return ($"Layering rule breach detected for {breach.Security.Name}.{breach.BidirectionalTradeBreach.Description}{breach.DailyVolumeTradeBreach.Description}{breach.WindowVolumeTradeBreach.Description}{breach.PriceMovementBreach.Description}"); }