Exemple #1
0
 public void Setup()
 {
     this.fixedIncomeHighProfitJudgement = A.Fake <IFixedIncomeHighProfitJudgement>();
     this.ruleBreachContext     = A.Fake <IRuleBreachContext>();
     this.fixedIncomeParameters = A.Fake <IHighProfitsRuleFixedIncomeParameters>();
     this.profitBreakdown       = A.Fake <IExchangeRateProfitBreakdown>();
 }
            /// <summary>
            /// Initializes a new instance of the <see cref="HighProfitJudgementDto"/> class.
            /// </summary>
            /// <param name="judgement">
            /// The judgement.
            /// </param>
            public HighProfitJudgementDto(IFixedIncomeHighProfitJudgement judgement)
                : base(
                    !judgement?.NoAnalysis ?? false,
                    judgement?.ClientOrderId,
                    judgement?.OrderId,
                    judgement?.SerialisedParameters,
                    judgement?.RuleRunCorrelationId,
                    judgement?.RuleRunId)
            {
                if (judgement == null)
                {
                    return;
                }

                this.AbsoluteHighProfit         = judgement.AbsoluteHighProfit;
                this.AbsoluteHighProfitCurrency = judgement.AbsoluteHighProfitCurrency;
                this.PercentageHighProfit       = judgement.PercentageHighProfit;
            }
 /// <summary>
 /// Initializes a new instance of the <see cref="FixedIncomeHighProfitJudgementContext"/> class.
 /// </summary>
 /// <param name="judgement">
 /// The judgement.
 /// </param>
 /// <param name="projectToAlert">
 /// The project to alert.
 /// </param>
 /// <param name="ruleBreachContext">
 /// The rule breach context.
 /// </param>
 /// <param name="fixedIncomeParameters">
 /// The fixed income parameters.
 /// </param>
 /// <param name="absoluteProfits">
 /// The absolute profits.
 /// </param>
 /// <param name="absoluteProfitCurrency">
 /// The absolute profit currency.
 /// </param>
 /// <param name="relativeProfits">
 /// The relative profits.
 /// </param>
 /// <param name="hasAbsoluteProfitBreach">
 /// The has absolute profit breach.
 /// </param>
 /// <param name="hasRelativeProfitBreach">
 /// The has relative profit breach.
 /// </param>
 /// <param name="profitBreakdown">
 /// The profit breakdown.
 /// </param>
 public FixedIncomeHighProfitJudgementContext(
     IFixedIncomeHighProfitJudgement judgement,
     bool projectToAlert,
     IRuleBreachContext ruleBreachContext,
     IHighProfitsRuleFixedIncomeParameters fixedIncomeParameters,
     Money?absoluteProfits,
     string absoluteProfitCurrency,
     decimal?relativeProfits,
     bool hasAbsoluteProfitBreach,
     bool hasRelativeProfitBreach,
     IExchangeRateProfitBreakdown profitBreakdown)
 {
     this.Judgement               = judgement;
     this.RaiseRuleViolation      = projectToAlert;
     this.RuleBreachContext       = ruleBreachContext;
     this.FixedIncomeParameters   = fixedIncomeParameters;
     this.AbsoluteProfits         = absoluteProfits;
     this.AbsoluteProfitCurrency  = absoluteProfitCurrency;
     this.RelativeProfits         = relativeProfits;
     this.HasAbsoluteProfitBreach = hasAbsoluteProfitBreach;
     this.HasRelativeProfitBreach = hasRelativeProfitBreach;
     this.ExchangeRateProfits     = profitBreakdown;
 }
        /// <summary>
        /// The save.
        /// </summary>
        /// <param name="highProfit">
        /// The high profit.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task SaveAsync(IFixedIncomeHighProfitJudgement highProfit)
        {
            this.logger?.LogInformation($"Fixed Income High profit judgement saving for rule run {highProfit.RuleRunId}");

            if (highProfit == null)
            {
                this.logger?.LogError("Fixed Income High profit judgement was null");
                return;
            }

            var dto = new HighProfitJudgementDto(highProfit);

            try
            {
                using (var databaseConnection = this.databaseConnectionFactory.BuildConn())
                {
                    var result = await databaseConnection.ExecuteAsync(SaveHighProfit, dto);
                }
            }
            catch (Exception e)
            {
                this.logger?.LogError(e, $"Error in save insert for high profit");
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="FixedIncomeHighProfitJudgementContext"/> class.
 /// </summary>
 /// <param name="judgement">
 /// The judgement.
 /// </param>
 /// <param name="projectToAlert">
 /// The project to alert.
 /// </param>
 public FixedIncomeHighProfitJudgementContext(IFixedIncomeHighProfitJudgement judgement, bool projectToAlert)
 {
     this.Judgement          = judgement ?? throw new ArgumentNullException(nameof(judgement));
     this.RaiseRuleViolation = projectToAlert;
 }