/// <summary>
        /// The pass judgement for daily breach async.
        /// </summary>
        /// <param name="mostRecentTrade">
        /// The most recent trade.
        /// </param>
        /// <param name="tradePosition">
        /// The trade position.
        /// </param>
        /// <param name="dailyAnalysis">
        /// The daily Analysis.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        private async Task PassJudgementForDailyBreachAsync(
            Order mostRecentTrade,
            TradePosition tradePosition,
            FixedIncomeHighVolumeJudgement.BreachDetails dailyAnalysis)
        {
            var serialisedParameters = JsonConvert.SerializeObject(this.parameters);

            var judgement =
                new FixedIncomeHighVolumeJudgement(
                    mostRecentTrade?.Market,
                    this.RuleCtx.RuleParameterId(),
                    this.RuleCtx.CorrelationId(),
                    mostRecentTrade?.ReddeerOrderId?.ToString(),
                    mostRecentTrade?.OrderId?.ToString(),
                    serialisedParameters,
                    this.hadMissingMarketData,
                    false,
                    FixedIncomeHighVolumeJudgement.BreachDetails.None(),
                    dailyAnalysis);

            var fixedIncomeHighVolumeContext =
                new FixedIncomeHighVolumeJudgementContext(
                    judgement,
                    true,
                    tradePosition,
                    mostRecentTrade?.Market);

            await this.judgementService.Judgement(fixedIncomeHighVolumeContext);
        }
Example #2
0
        public void BuildDescriptionForDailyBreachReturnsExpectedDescription()
        {
            var mapper = this.BuildMapper();

            A.CallTo(() => this.context.IsIssuanceBreach).Returns(false);
            A.CallTo(() => this.financialInstrument.Name).Returns("ryan-test-security");

            var dailyAnalysis =
                new FixedIncomeHighVolumeJudgement.BreachDetails(
                    69,
                    0.1m,
                    230,
                    0.3m,
                    true);

            A.CallTo(() => this.context.Judgement.DailyAnalysisAnalysis).Returns(dailyAnalysis);

            var description = mapper.BuildDescription(this.context);

            Assert.AreEqual("Fixed Income High Volume rule breach detected for ryan-test-security. Percentage of daily volume breach has occured. A daily volume limit of 10% was exceeded by trading 30% of daily volume at the venue () . 230 volume was the allocated fill against a breach threshold volume of 69.", description);
        }
Example #3
0
        public void BuildDescriptionForWindowBreachReturnsExpectedDescription()
        {
            var mapper = this.BuildMapper();

            A.CallTo(() => this.context.IsIssuanceBreach).Returns(false);
            A.CallTo(() => this.financialInstrument.Name).Returns("ryan-test-security");

            var windowAnalysis =
                new FixedIncomeHighVolumeJudgement.BreachDetails(
                    100,
                    0.2m,
                    300,
                    0.6m,
                    true);

            A.CallTo(() => this.context.Judgement.WindowAnalysisAnalysis).Returns(windowAnalysis);

            var description = mapper.BuildDescription(this.context);

            Assert.AreEqual("Fixed Income High Volume rule breach detected for ryan-test-security. Percentage of window volume breach has occured. A window volume limit of 20% was exceeded by trading 60% of window volume within the window of 0 minutes at the venue () . 300 volume was the allocated fill against a breach threshold volume of 100.", description);
        }
 /// <summary>
 /// The has no breach.
 /// </summary>
 /// <param name="dailyBreach">
 /// The daily breach.
 /// </param>
 /// <param name="windowBreach">
 /// The window breach.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 private bool HasNoBreach(
     FixedIncomeHighVolumeJudgement.BreachDetails dailyBreach,
     FixedIncomeHighVolumeJudgement.BreachDetails windowBreach)
 {
     return(!dailyBreach.VolumeBreach && !windowBreach.VolumeBreach);
 }