Esempio n. 1
0
        public async Task Send(IPlacingOrdersWithNoIntentToExecuteRuleBreach ruleBreach)
        {
            if (ruleBreach == null)
            {
                this.Logger?.LogInformation(
                    "SpoofingRuleMessageSender Send received a null rule breach for op ctx. Returning.");
                return;
            }

            var description = this.BuildDescription(ruleBreach);

            await this.Send(ruleBreach, description);
        }
        public void Send(IPlacingOrdersWithNoIntentToExecuteRuleBreach ruleBreach)
        {
            if (ruleBreach == null)
            {
                // ReSharper disable once InconsistentlySynchronizedField
                this._logger.LogInformation("received a null rule breach. Returning.");
                return;
            }

            lock (this._lock)
            {
                this._logger.LogInformation($"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(IPlacingOrdersWithNoIntentToExecuteRuleBreach ruleBreach)
        {
            var sdBreakdown =
                ruleBreach?.ProbabilityForOrders?.Select(_ => _.Sd).GroupBy(_ => (int)_)
                .Select(_ => new StandardDeviationCount(_.Count(), _.Key)).ToList()
                ?? new List <StandardDeviationCount>();

            var sdBreakdownText = !sdBreakdown.Any()
                                      ? string.Empty
                                      : sdBreakdown.Aggregate(
                string.Empty,
                (a, b) => $"{a} SD-{b.StandardDeviation} Trades-{b.Count}");

            var fullSdText = !sdBreakdown.Any()
                                 ? string.Empty
                                 : $"The distribution of trades by standard deviation from the mean was {sdBreakdownText}.";

            var description =
                $"Placing Orders With No Intent To Execute Rule Breach. Traded {ruleBreach?.Trades?.Get()?.Count} trades separately over configured sigma {ruleBreach?.Parameters?.Sigma} probability of reaching their limit price. The standard deviation for the trading day was {ruleBreach?.StandardDeviationPrice} and the mean price was {ruleBreach?.MeanPrice}. {fullSdText}";

            return(description);
        }