public static double Calculate(IEnumerable<double> returns, IEnumerable<double> signals, double transactionCost, out OnlineCalculatorError errorState) {
      IEnumerator<double> returnsEnumerator = returns.GetEnumerator();
      IEnumerator<double> signalsEnumerator = signals.GetEnumerator();
      OnlineSharpeRatioCalculator calculator = new OnlineSharpeRatioCalculator(transactionCost);

      // always move forward both enumerators (do not use short-circuit evaluation!)
      while (returnsEnumerator.MoveNext() & signalsEnumerator.MoveNext()) {
        double signal = signalsEnumerator.Current;
        double @return = returnsEnumerator.Current;
        calculator.Add(@return, signal);
      }

      // check if both enumerators are at the end to make sure both enumerations have the same length
      if (returnsEnumerator.MoveNext() || signalsEnumerator.MoveNext()) {
        throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
      } else {
        errorState = calculator.ErrorState;
        return calculator.SharpeRatio;
      }
    }