private Decimal calculateMaximumDrawdown(TimeSeries series, CashFlow cashFlow) {
    """
	Calculates the maximum drawdown from a cash flow over a series.
	@param series the time series
	@param cashFlow the cash flow
	@return the maximum drawdown from a cash flow over a series
    """
        Decimal maximumDrawdown = Decimal.ZERO;
        Decimal maxPeak = Decimal.ZERO;
        if (!series.isEmpty()) {
        	// The series is not empty
	        for (int i = series.getBeginIndex(); i <= series.getEndIndex(); i++) {
	            Decimal value = cashFlow.getValue(i);
	            if (value.isGreaterThan(maxPeak)) {
	                maxPeak = value;
	            }
	
	            Decimal drawdown = maxPeak.minus(value).dividedBy(maxPeak);
	            if (drawdown.isGreaterThan(maximumDrawdown)) {
	                maximumDrawdown = drawdown;
	            }
	        }
        }
        return maximumDrawdown;
    }
private Decimal calculateMaximumDrawdown(TimeSeries series, CashFlow cashFlow) {
        Decimal maximumDrawdown = Decimal.ZERO;
        Decimal maxPeak = Decimal.ZERO;
        if (!series.isEmpty()) {
        	// The series is not empty
	        for (int i = series.getBeginIndex(); i <= series.getEndIndex(); i++) {
	            Decimal value = cashFlow.getValue(i);
	            if (value.isGreaterThan(maxPeak)) {
	                maxPeak = value;
	            }
	
	            Decimal drawdown = maxPeak.minus(value).dividedBy(maxPeak);
	            if (drawdown.isGreaterThan(maximumDrawdown)) {
	                maximumDrawdown = drawdown;
	            }
	        }
        }
        return maximumDrawdown;
    }
private Decimal calculateMaximumDrawdown ( TimeSeries series , CashFlow cashFlow ) { Decimal maximumDrawdown = Decimal . ZERO ; Decimal maxPeak = Decimal . ZERO ; if ( ! series . isEmpty ( ) ) { // The series is not empty for ( int i = series . getBeginIndex ( ) ; i <= series . getEndIndex ( ) ; i ++ ) { Decimal value = cashFlow . getValue ( i ) ; if ( value . isGreaterThan ( maxPeak ) ) { maxPeak = value ; } Decimal drawdown = maxPeak . minus ( value ) . dividedBy ( maxPeak ) ; if ( drawdown . isGreaterThan ( maximumDrawdown ) ) { maximumDrawdown = drawdown ; } } } return maximumDrawdown ; }
Calculates the maximum drawdown from a cash flow over a series.
@param series the time series
@param cashFlow the cash flow
@return the maximum drawdown from a cash flow over a series
Calculates the maximum drawdown from a cash flow over a series .