Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        /// <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);
            }
        }
Esempio n. 3
0
 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}");
 }