private async Task <RateResult> GetRuleValue(List <Task <QueryRateResult> > dependentQueries, RateRule rateRule) { var result = new RateResult(); result.Cached = true; foreach (var queryAsync in dependentQueries) { var query = await queryAsync; if (!query.CachedResult) { result.Cached = false; } result.ExchangeExceptions.AddRange(query.Exceptions); foreach (var rule in query.ExchangeRates) { rateRule.ExchangeRates.Add(rule); } } rateRule.Reevaluate(); result.Value = rateRule.Value; result.Errors = rateRule.Errors; result.EvaluatedRule = rateRule.ToString(true); result.Rule = rateRule.ToString(false); return(result); }
private async Task <RateResult> GetRuleValue(List <Task <QueryRateResult> > dependentQueries, RateRule rateRule) { var result = new RateResult(); result.Cached = true; foreach (var queryAsync in dependentQueries) { var query = await queryAsync; if (!query.CachedResult) { result.Cached = false; } result.ExchangeExceptions.AddRange(query.Exceptions); foreach (var rule in query.ExchangeRates) { rateRule.ExchangeRates.Add(rule); } } rateRule.Reevaluate(); result.Value = rateRule.Value; var currencyData = _CurrencyTable?.GetCurrencyData(rateRule.CurrencyPair.Right); if (currencyData != null && result.Value.HasValue) { result.Value = decimal.Round(result.Value.Value, currencyData.Divisibility, MidpointRounding.AwayFromZero); } result.Errors = rateRule.Errors; result.EvaluatedRule = rateRule.ToString(true); result.Rule = rateRule.ToString(false); return(result); }
private async Task <RateResult> GetRuleValue(List <Task <QueryRateResult> > dependentQueries, RateRule rateRule) { var result = new RateResult(); foreach (var queryAsync in dependentQueries) { var query = await queryAsync; result.Latency = query.Latency; if (query.Exception != null) { result.ExchangeExceptions.Add(query.Exception); } foreach (var rule in query.PairRates) { rateRule.ExchangeRates.SetRate(query.Exchange, rule.CurrencyPair, rule.BidAsk); } } rateRule.Reevaluate(); result.BidAsk = rateRule.BidAsk; result.Errors = rateRule.Errors; result.EvaluatedRule = rateRule.ToString(true); result.Rule = rateRule.ToString(false); return(result); }