//private decimal? TryCalculate(CandleBuffer buffer, Func<Candle, decimal> getPart) //{ // return _security.Calculate(buffer.Candles.ToDictionary(c => _securityToSecurity[c.Security], getPart)); //} private decimal Calculate(CandleBuffer buffer, Func <Candle, decimal> getPart) { return(_security.Calculate(buffer.Candles.Select(getPart).ToArray())); //var calculate = TryCalculate(buffer, getPart); //if (calculate == null) // throw new InvalidOperationException(LocalizedStrings.Str657); //return (decimal)calculate; }
private decimal Calculate(CandleBuffer buffer, bool isPrice, Func <Candle, decimal> getPart) { var values = buffer.Candles.Select(getPart).ToArray(); try { return(_security.Calculate(values, isPrice)); } catch (ArithmeticException excp) { throw new ArithmeticException(LocalizedStrings.BuildIndexError.Put(_security, _security.InnerSecurityIds.Zip(values, (s, v) => "{0}: {1}".Put(s, v)).Join(", ")), excp); } }
private decimal Calculate(CandleBuffer buffer, Func <Candle, decimal> getPart) { var values = buffer.Candles.Select(getPart).ToArray(); try { return(_security.Calculate(values)); } catch (ArithmeticException excp) { throw new ArithmeticException("Build index candle {0} for {1} error.".Put(_security, _security.InnerSecurities.Zip(values, (s, v) => "{0}: {1}".Put(s, v)).Join(", ")), excp); } }
private decimal?TryCalculate(CandleBuffer buffer, Func <Candle, decimal> getPart) { return(_security.Calculate(buffer.Candles.ToDictionary(c => _securityToSecurity[c.Security], getPart))); }